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

Leonard Chan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 7 16:50:22 PST 2018

leonardchan added inline comments.

Comment at: lib/Sema/SemaType.cpp:5817-5822
+      IdentifierInfo *AddressSpaceMacroII = nullptr;
+      auto FoundMacro = S.PP.AddressSpaceMacros.find(
+          S.SourceMgr.getSpellingLoc(Attr.getLoc()));
+      if (FoundMacro != S.PP.AddressSpaceMacros.end())
+        AddressSpaceMacroII = FoundMacro->second;
rsmith wrote:
> This is not the right way to find the macro.
> What you should do is this: look at the source range of the attribute, and find the object-like macro expansion(s) common to both the start and end location. Search through those for the outermost macro expansion whose range is that of the attribute plus the enclosing syntax (`__attribute__((` ... `))` or `[[` ... `]]` or similar). That macro name is the name that was used to write this type, and that's the name we should preserve.
> Plus, please do this all from `getAttributedType` itself so that it applies to all type attributes, not just address space attributes.
Moved the saved identifier into the new type sugar.

  rC Clang


More information about the cfe-commits mailing list