[PATCH] D51329: [Attribute/Diagnostics] Print macro instead of whole attribute for address_space

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 28 15:44:38 PDT 2018

rsmith added a comment.

+ at aaron.ballman for attributes-related changes.

It would be easier and more precise to track the macro corresponding to an attribute in the `Parser` rather than in `Sema` (and stash it on the `ParsedAttr` for consumers such as `Sema` that want it). That way, we still have the information about where the attribute delimiters were, and whether there were multiple attributes in the same set of delimiter brackets. Specifically, in `Parser::ParseGNUAttributes`, if we find that we parsed exactly one attribute, look through the source location information for the outermost macro expansion that exactly covers the token sequence in question, and that's your corresponding macro name. (Note that we don't need to check what the expansion of the macro is, nor track what attribute-like macros have been defined, to support this approach.)

Sorry for not thinking of this sooner.

Comment at: lib/AST/TypePrinter.cpp:1370
+    // Remove the underlying address space so it won't be printed.
+    SplitQualType SplitTy = T->getModifiedType().split();
leonardchan wrote:
> rsmith wrote:
> > This is unnecessary; just print the modified type here. (The modified type by definition does not have the attribute applied to it.)
> When you say the modified type, do you mean just the type without it's qualifiers? I wasn't sure if removing all the qualifiers would suffice since there were also other  non-address_space qualifiers that could be printed.
I mean `T->getModifiedType()`, which tracks what the type was before the attribute was applied.

  rC Clang


More information about the cfe-commits mailing list