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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 13 07:12:39 PDT 2024


================
@@ -493,9 +500,11 @@ class ParsedAttr final
   /// Set the macro identifier info object that this parsed attribute was
   /// declared in if it was declared in a macro. Also set the expansion location
   /// of the macro.
-  void setMacroIdentifier(IdentifierInfo *MacroName, SourceLocation Loc) {
+  void setMacroIdentifier(IdentifierInfo *MacroName, SourceLocation Loc,
+                          bool PrintAsMac) {
----------------
AaronBallman wrote:

On the one hand, this seems like a natural thing to do -- if the user associated the attribute with a macro name, then defaulting to wanting to print it as the macro name makes sense. On the other hand, this feels like a layering violation -- the printing policy for the attribute really should be what determines whether it should or should not be printed as a macro because the use case may be for printing the expanded attribute name. e.g., `conflicting attribute 'MACRO_FOO' (aka 'foo')`, or when manually printing AST nodes as tools sometimes do.

CC @erichkeane for more opinions.

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


More information about the cfe-commits mailing list