[PATCH] D114235: [clang] Extend ParsedAttr to allow custom handling for type attributes

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 14 09:16:20 PST 2022


erichkeane added a comment.

Right, yeah, so there are a couple of problems with AttributedType.  First, it gets lost almost as soon as you get out of SemaType about 90% of the time.  Anything that does some level of canonicalization ends up losing it, so the AttributedType information is lost almost immediately.  This is why the current ones all store information in the ExtInfo.  The worst place for this ends up being in the template instantiator, which immediately canonicalizes/desugars types all over the place.

However, making AttributedType 'survive' is actually going to be troublesome as well. A lot of the type-checking compares types using == on their pointer values, so that would be broken if they are an AttributedType.

So I think the 'first' thing that needs to happen is to make the entire CFE 'AttributedType' maintaining, AND tolerant. I can't think of a good way to do that reliably (my naive thought would be to come up with some way to temporarily (during development) wrap EVERY type in an AttributedType with a random attribute (so that they are all unique!) and do comparisons that way. Additionally, you'd need SOMETHING to validate that the AttributedTypes are the only one that survives (again, during development) to make sure it 'works right'.

Additionally, you'll likely  have a lot of work to do in the template engine to make sure that the attributes are inherited correctly through  instantiations, specializations, etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114235



More information about the cfe-commits mailing list