[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
Wed Oct 3 17:56:36 PDT 2018


rsmith added a comment.

In https://reviews.llvm.org/D51329#1229061, @leonardchan wrote:

> @rsmith So I chose to go with the type sugar route since we would prefer to have multiple attributes in one attribute list. This type just contains the underlying type and the macro identifier originally held by the `AttributedType`. Do you have any recommendations on where this type should be created?


I think the most natural thing to do would be to create the sugar node in `processTypeAttrs` after parsing each "chunk" of attributes produced by the same macro. (You'll need to extend `ParsedAttributesView` so it can tell you which ranges came from which macros.)

> I'm thinking I could either make this type a subclass of `AttributedType` since we will essentially be using this only for attributes declared in a macro (I think this would allow me to not have to change some of the stuff that happens under `GetTypeSourceInfoForDeclarator`), or somehow find a way to make this in another part of `Sema`, although I would still need access to the parsed attributes so I would know what the macro identifiers are.

Your new type sugar node should be a new subclass of `Type` unrelated to `AttributedType`, maybe `MacroQualifiedType`. You'll need to teach `TypeSpecLocFiller` to fill in location information from it, but you can save that into the `ParsedAttributesView` when you parse the attributes and identify the macro expansions therein.


Repository:
  rC Clang

https://reviews.llvm.org/D51329





More information about the cfe-commits mailing list