[clang] [BoundsSafety] unify ParseLexedAttribute (PR #186033)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 12 06:23:44 PDT 2026
================
@@ -751,38 +753,56 @@ void Parser::ParseLexedAttribute(LateParsedAttribute &LA,
if (LA.Decls.size() > 0) {
Decl *D = LA.Decls[0];
- NamedDecl *ND = dyn_cast<NamedDecl>(D);
- RecordDecl *RD = dyn_cast_or_null<RecordDecl>(D->getDeclContext());
- // Allow 'this' within late-parsed attributes.
- Sema::CXXThisScopeRAII ThisScope(Actions, RD, Qualifiers(),
- ND && ND->isCXXInstanceMember());
+ if (getLangOpts().CPlusPlus) {
+ NamedDecl *ND = dyn_cast<NamedDecl>(D);
+ RecordDecl *RD = dyn_cast_or_null<RecordDecl>(D->getDeclContext());
- if (LA.Decls.size() == 1) {
- // If the Decl is templatized, add template parameters to scope.
- ReenterTemplateScopeRAII InDeclScope(*this, D, EnterScope);
+ // Allow 'this' within late-parsed attributes.
+ Sema::CXXThisScopeRAII ThisScope(Actions, RD, Qualifiers(),
+ ND && ND->isCXXInstanceMember());
- // If the Decl is on a function, add function parameters to the scope.
+ if (LA.Decls.size() == 1) {
+ // If the Decl is templatized, add template parameters to scope.
+ ReenterTemplateScopeRAII InDeclScope(*this, D, EnterScope);
+
+ // If the Decl is on a function, add function parameters to the scope.
+ bool HasFunScope = EnterScope && D->isFunctionOrFunctionTemplate();
----------------
erichkeane wrote:
```suggestion
bool HasFuncScope = EnterScope && D->isFunctionOrFunctionTemplate();
```
https://github.com/llvm/llvm-project/pull/186033
More information about the cfe-commits
mailing list