Before this patch type traits are checked in Parser, so use type traits
directly did not cause assertion faults. However if type traits are initialized
from a template, we didn't perform arity checks before evaluating. This
patch moves arity checks from Parser to Sema, and performing arity
checks in Sema actions, so type traits get checked corretly.
Crash input:
template<class... Ts> bool b = __is_constructible(Ts...); bool x = b<>;
After this patch:
clang/test/SemaCXX/type-trait-eval-crash-issue-57008.cpp:5:32: error: type trait requires 1 or more arguments; have 0 arguments template<class... Ts> bool b = __is_constructible(Ts...); ^~~~~~~~~~~~~~~~~~ clang/test/SemaCXX/type-trait-eval-crash-issue-57008.cpp:6:10: note: in instantiation of variable template specialization 'b<>' requested here bool x = b<>; ^ 1 error generated.
I don't believe this is the right fix, the assert below is saying that we should not be here if Args.empty() so we are doing something wrong before this point.
This will prevent the crash but cover up the real issue.
Unless we have some foundation for saying the assert is not correct but I don't see that.