trailofbits / pasta

Peter's Amazing Syntax Tree Analyzer
Apache License 2.0
123 stars 9 forks source link

Investigate revertible type traits #96

Open pgoodman opened 1 year ago

pgoodman commented 1 year ago

https://github.com/llvm/llvm-project/blob/3af4590506634fa176be5cb5f53161f96609730c/clang/lib/Parse/ParseExpr.cpp#L1071

This works:

template <bool>
struct _BoolConstant {};

#if __has_builtin(__is_destructible)
template <class _Tp>
struct is_destructible : _BoolConstant<__is_destructible(_Tp)> {};
#endif

But this doesn't:

template <bool>
struct _BoolConstant {};

template <class _Tp>
struct is_destructible : _BoolConstant<__is_destructible(_Tp)> {};

This suggests there may be something stateful involved with __is_destructibe showing up first in the __has_builtin.