[clang] [BoundsSafety] unify ParseLexedAttribute (PR #186033)

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 12 02:54:42 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.
----------------
cor3ntin wrote:

```suggestion
        // If the Decl is templatized, add template parameters to the scope.
```

https://github.com/llvm/llvm-project/pull/186033


More information about the cfe-commits mailing list