[clang] Turn 'counted_by' into a type attribute and parse it into 'CountAttributedType' (PR #78000)

Yeoul Na via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 7 09:05:02 PST 2024


rapidsna wrote:

Thanks @AaronBallman! 

> I think AttributedType might be a reasonable way forward. That's how we model nullability qualifiers, for example:

The difference from nullability qualifiers is that they are actually encoded as `AttributeKind`, whereas `__counted_by` has to store more than `Kind`, i.e., an expression and some dependent declarations.   

And the reason why we created a new sugar type instead of using `AttributedType` is that `AttributedType` itself doesn't have an extended data other than `AttributeKind` as an integer value. And more data seems to be stored in `TypeLoc`.  

Related to this, I remember we talked about having `CountAttributedType` to inherit `AttributedType`. I didn't want this to be picked up by `getAs<AttributedType>` so that we won't have to conditionalize `CountAttributedType` where `AttributeType` is generally handled and there's no other type inheriting `AttributedType` so far. E.g., BTagAttributedType is a sugar type that doesn't inherit `AttributedType`.

https://github.com/llvm/llvm-project/pull/78000


More information about the cfe-commits mailing list