[clang] [clang] CTAD: implement the missing IsDeducible constraint for alias templates (PR #89358)

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 23 01:09:46 PDT 2024


hokein wrote:

> > > Regarding the __is_deducible type trait, GCC also provides one, but it was hidden from users and only used for internal CTAD implementation. I'm not sure if we should follow the same strategy in clang, ideas?
> > 
> > 
> > I have mixed feeling. What do you think @AaronBallman ?
> 
> Personally, I do not like exposing type traits that aren't for use with the STL. 

This is a valid argument. This type trait is supposed to be clang-internal only and should not be used in other places. The main benefit of exposing it is for testing purposes, and I personally found it to be really useful for debugging.

> One idea would be to remove the type trait from TokenKinds.def and instead manually add `BTT_IsDeducible` to:
> 
> https://github.com/llvm/llvm-project/blob/c61f0a8e94004b05d9ec115d3bff8cff331b4491/clang/include/clang/Basic/TypeTraits.h#L21
> 
> along with a comment explaining that this is for internal use only rather than be exposed to users. (You'd have to see if there are other places using `TYPE_TRAIT_2` that might need adjustment as well.) Then we can remove the release note, error checking can become assertions, etc.

This approach is doable technically, but it feels hacky and fragile. What if we emit an error (or warning) diagnostic and reject the code when we parse the `__is_deducible` type trait?

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


More information about the cfe-commits mailing list