[PATCH] D51329: [Attribute/Diagnostics] Print macro if definition is an attribute declaration

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 2 12:56:58 PDT 2019


rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Thanks, looks great!

I think the handling of the expansion location in the `MacroQualifiedTypeLoc` isn't quite right yet (it looks like it will never actually be set at all, because the code to set it is not reachable) but it's also unused at the moment, so I'm happy with that being fixed as a follow-up change after you land this.



================
Comment at: clang/lib/Sema/SemaType.cpp:5647
+    void VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) {
+      TL.setExpansionLoc(Chunk.Loc);
+    }
----------------
This should use `getMacroExpansionLoc` on the relevant attribute (you can store the location information in `TypeProcessingState` and retrieve it from here; see what we do for `AttributedType` for example).

I think we'll also need a `VisitMacroQualifiedTypeLoc` override on `TypeSpecLocFiller` for attributes in the decl-specifiers rather than attributes on declarator chunks. (See below.)


================
Comment at: clang/lib/Sema/SemaType.cpp:5727-5728
 
+    while (MacroQualifiedTypeLoc TL = CurrTL.getAs<MacroQualifiedTypeLoc>())
+      CurrTL = TL.getNextTypeLoc().getUnqualifiedLoc();
+
----------------
Skipping `MacroQualifiedTypeLoc`s here means you're never reaching the above `DeclaratorLocFiller::VisitMacroQualifiedTypeLoc`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D51329/new/

https://reviews.llvm.org/D51329





More information about the cfe-commits mailing list