[clang] [clang][ThreadSafety] Name a member through 'this' in a parameter's attribute during parsing attribute (PR #241077)

Aaron Puchert via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 15 14:47:03 PST 2026


================
@@ -7456,9 +7493,17 @@ void Parser::ParseFunctionDeclarator(Declarator &D,
     MaybeParseCXX11Attributes(FnAttrs);
     ProhibitAttributes(FnAttrs);
   } else {
-    if (Tok.isNot(tok::r_paren))
+    if (Tok.isNot(tok::r_paren)) {
+      // A nested prototype, such as a callback's, keeps the enclosing one's
+      // class. A function with an explicit object parameter, which comes
+      // first, has no 'this'.
+      CXXRecordDecl *ThisRecord = ParamAttrThisRecord;
+      if (D.isFunctionDeclaratorAFunctionDeclaration())
----------------
aaronpuchert wrote:

Can we find out in `ParseAttributeArgsCommon` what entity we're adding an attribute to? Then we don't need to clutter `ParseFunctionDeclarator` with the setup. (Note that we're going through this function for lots of function declarators, most of which have no attributes at all. It seems smarter to do this work only when needed.)

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


More information about the cfe-commits mailing list