AaronBallman wrote:

> > One possibility would be to use a type qualifier? It has basically the kind 
> > of properties you want... the underlying type is
> > still there, and places that strip qualifiers will automatically do the 
> > right thing in a lot of cases. It might require a bit more
> > work to handle it in various places in semantic analysis, though.
> 
> Thanks @efriedma-quic! We also thought about using qualifiers before but it's 
> tricky because we would like the bounds annotations to be able to apply to 
> function return types. WDYT?

To clarify the problem, qualifiers are stripped from the return type in C when 
forming the function type itself (see C23 6.7.6.3p4).

> We haven't experimented these alternative designs so I'm curious about 
> @AaronBallman's thoughts.

I think that encoding this into `Qualifiers` would be difficult because that's 
a 32-bit opaque value and I think counted_by needs to store more information 
than we have room for: 
https://github.com/llvm/llvm-project/blob/b0c6fc81fe132f20eed38bd836620dfcb5ac17e9/clang/include/clang/AST/Type.h#L147

I think `AttributedType` might be a reasonable way forward. That's how we model 
nullability qualifiers, for example: 
https://github.com/llvm/llvm-project/blob/0aacd44a4698da012ee0704815123b28f2a06d0f/clang/lib/AST/Type.cpp#L4514
 and 
https://github.com/llvm/llvm-project/blob/b0c6fc81fe132f20eed38bd836620dfcb5ac17e9/clang/include/clang/AST/Type.h#L5189
 and counted_by feels roughly similar in terms of behavior (not able to 
overload based on presence/absence of the attribute, etc).

CC @erichkeane as attributes code owner.

https://github.com/llvm/llvm-project/pull/78000
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to