diff options
author | Dan Liew <dan@su-root.co.uk> | 2024-06-12 15:43:12 -0700 |
---|---|---|
committer | Dan Liew <dan@su-root.co.uk> | 2024-06-12 15:43:12 -0700 |
commit | c9d580033f29196223cd56a0fa238c3ba51d23e4 (patch) | |
tree | 81982f690f8bf7261ca91fe6b03d622b5883e419 /clang/lib/Parse/ParseDecl.cpp | |
parent | f074500b229837b482c4b88d4bdd0e53d1e24ed5 (diff) | |
download | llvm-c9d580033f29196223cd56a0fa238c3ba51d23e4.zip llvm-c9d580033f29196223cd56a0fa238c3ba51d23e4.tar.gz llvm-c9d580033f29196223cd56a0fa238c3ba51d23e4.tar.bz2 |
Revert "Support `guarded_by` attribute and related attributes inside C structs and support late parsing them (#94216)"
This reverts commit af0d7128c8fd053d3de8af208d7d1682bc7a525a.
Reverting due to likely regression:
https://github.com/llvm/llvm-project/pull/94216#issuecomment-2164013300
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 118 |
1 files changed, 1 insertions, 117 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index c7663d4..c528917 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -671,16 +671,6 @@ void Parser::ParseGNUAttributeArgs( ParseBoundsAttribute(*AttrName, AttrNameLoc, Attrs, ScopeName, ScopeLoc, Form); return; - } else if (AttrKind == ParsedAttr::AT_GuardedBy || - AttrKind == ParsedAttr::AT_PtGuardedBy) { - ParseGuardedByAttribute(*AttrName, AttrNameLoc, Attrs, ScopeName, ScopeLoc, - EndLoc, Form); - return; - } else if (AttrKind == ParsedAttr::AT_AcquiredAfter || - AttrKind == ParsedAttr::AT_AcquiredBefore) { - ParseAcquiredAttribute(*AttrName, AttrNameLoc, Attrs, ScopeName, ScopeLoc, - EndLoc, Form); - return; } else if (AttrKind == ParsedAttr::AT_CXXAssume) { ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, EndLoc, Form); return; @@ -3340,112 +3330,6 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl, } } -/// GuardedBy attributes (e.g., guarded_by): -/// AttrName '(' expression ')' -void Parser::ParseGuardedByAttribute( - IdentifierInfo &AttrName, SourceLocation AttrNameLoc, - ParsedAttributes &Attrs, IdentifierInfo *ScopeName, SourceLocation ScopeLoc, - SourceLocation *EndLoc, ParsedAttr::Form Form) { - assert(Tok.is(tok::l_paren) && "Attribute arg list not starting with '('"); - - BalancedDelimiterTracker Parens(*this, tok::l_paren); - Parens.consumeOpen(); - - if (Tok.is(tok::r_paren)) { - Diag(Tok.getLocation(), diag::err_argument_required_after_attribute); - Parens.consumeClose(); - return; - } - - ArgsVector ArgExprs; - // Don't evaluate argument when the attribute is ignored. - using ExpressionKind = - Sema::ExpressionEvaluationContextRecord::ExpressionKind; - EnterExpressionEvaluationContext EC( - Actions, Sema::ExpressionEvaluationContext::PotentiallyEvaluated, nullptr, - ExpressionKind::EK_AttrArgument); - - ExprResult ArgExpr( - Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression())); - - if (ArgExpr.isInvalid()) { - Parens.skipToEnd(); - return; - } - - ArgExprs.push_back(ArgExpr.get()); - - auto RParens = Tok.getLocation(); - auto &AL = - *Attrs.addNew(&AttrName, SourceRange(AttrNameLoc, RParens), ScopeName, - ScopeLoc, ArgExprs.data(), ArgExprs.size(), Form); - - if (EndLoc) - *EndLoc = RParens; - - if (!Tok.is(tok::r_paren)) { - Diag(Tok.getLocation(), diag::err_attribute_wrong_number_arguments) - << AL << 1; - Parens.skipToEnd(); - return; - } - - Parens.consumeClose(); -} - -/// Acquired attributes (e.g., acquired_before, acquired_after): -/// AttrName '(' expression-list ')' -void Parser::ParseAcquiredAttribute( - IdentifierInfo &AttrName, SourceLocation AttrNameLoc, - ParsedAttributes &Attrs, IdentifierInfo *ScopeName, SourceLocation ScopeLoc, - SourceLocation *EndLoc, ParsedAttr::Form Form) { - assert(Tok.is(tok::l_paren) && "Attribute arg list not starting with '('"); - - BalancedDelimiterTracker Parens(*this, tok::l_paren); - Parens.consumeOpen(); - - if (Tok.is(tok::r_paren)) { - Diag(Tok.getLocation(), diag::err_argument_required_after_attribute); - Parens.consumeClose(); - return; - } - - auto ArgStart = Tok.getLocation(); - - ArgsVector ArgExprs; - - do { - - // Don't evaluate argument when the attribute is ignored. - using ExpressionKind = - Sema::ExpressionEvaluationContextRecord::ExpressionKind; - EnterExpressionEvaluationContext EC( - Actions, Sema::ExpressionEvaluationContext::PotentiallyEvaluated, - nullptr, ExpressionKind::EK_AttrArgument); - - ExprResult ArgExpr( - Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression())); - - if (ArgExpr.isInvalid()) { - Parens.skipToEnd(); - return; - } - - ArgExprs.push_back(ArgExpr.get()); - - } while (TryConsumeToken(tok::comma)); - - auto ArgEnd = Tok.getLocation(); - - Attrs.addNew(&AttrName, SourceRange(ArgStart, ArgEnd), ScopeName, ScopeLoc, - ArgExprs.data(), ArgExprs.size(), Form); - - if (EndLoc) - *EndLoc = ArgEnd; - - Parens.consumeClose(); -} - /// Bounds attributes (e.g., counted_by): /// AttrName '(' expression ')' void Parser::ParseBoundsAttribute(IdentifierInfo &AttrName, @@ -3471,7 +3355,7 @@ void Parser::ParseBoundsAttribute(IdentifierInfo &AttrName, Sema::ExpressionEvaluationContextRecord::ExpressionKind; EnterExpressionEvaluationContext EC( Actions, Sema::ExpressionEvaluationContext::PotentiallyEvaluated, nullptr, - ExpressionKind::EK_AttrArgument); + ExpressionKind::EK_BoundsAttrArgument); ExprResult ArgExpr( Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression())); |