[clang] [Parser][BoundsSafety] Print attribute as macro if it's system defined (PR #107619)

Dan Liew via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 10 16:11:37 PDT 2024


================
@@ -5080,6 +5083,17 @@ void Parser::ParseLexedCAttribute(LateParsedAttribute &LA, bool EnterScope,
   ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs, nullptr, nullptr,
                         SourceLocation(), ParsedAttr::Form::GNU(), nullptr);
 
+  const auto &SM = PP.getSourceManager();
+  CharSourceRange ExpansionRange = SM.getExpansionRange(LA.AttrNameLoc);
+  StringRef FoundName =
+      Lexer::getSourceText(ExpansionRange, SM, PP.getLangOpts())
+          .split('(')
+          .first;
+  IdentifierInfo *MacroII = PP.getIdentifierInfo(FoundName);
----------------
delcypher wrote:

What's the failure path here when the attribute isn't a macro? We seem to be calling `setMacroIdentifier` unconditionally.

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


More information about the cfe-commits mailing list