Eliminate BinaryTypeTraitExpr
There's nothing special about type traits accepting two arguments.
This commit eliminates BinaryTypeTraitExpr and switches all related handling
over to TypeTraitExpr.
Also fixes a CodeGen failure with variadic type traits appearing in a
non-constant expression.
The BTT/TT prefix and evaluation code is retained as-is for now but will soon
be further cleaned up.
This is part of the ongoing work to unify type traits.
llvm-svn: 197273
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index 846995e..9c2cfcc 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -2693,18 +2693,12 @@
}
}
-static BinaryTypeTrait BinaryTypeTraitFromTokKind(tok::TokenKind kind) {
- switch(kind) {
- default: llvm_unreachable("Not a known binary type trait");
-#define TYPE_TRAIT_2(Spelling, Name, Key) \
- case tok::kw_ ## Spelling: return BTT_ ## Name;
-#include "clang/Basic/TokenKinds.def"
- }
-}
-
static TypeTrait TypeTraitFromTokKind(tok::TokenKind kind) {
switch (kind) {
default: llvm_unreachable("Not a known type trait");
+#define TYPE_TRAIT_2(Spelling, Name, Key) \
+case tok::kw_ ## Spelling: return BTT_ ## Name;
+#include "clang/Basic/TokenKinds.def"
#define TYPE_TRAIT_N(Spelling, Name, Key) \
case tok::kw_ ## Spelling: return TT_ ## Name;
#include "clang/Basic/TokenKinds.def"
@@ -2805,15 +2799,9 @@
if (Arity == 1)
return Actions.ActOnUnaryTypeTrait(UnaryTypeTraitFromTokKind(Kind), Loc,
Args[0], EndLoc);
- if (Arity == 2)
- return Actions.ActOnBinaryTypeTrait(BinaryTypeTraitFromTokKind(Kind), Loc,
- Args[0], Args[1], EndLoc);
- if (!Arity)
- return Actions.ActOnTypeTrait(TypeTraitFromTokKind(Kind), Loc, Args,
- EndLoc);
- llvm_unreachable("unhandled type trait rank");
- return ExprError();
+ return Actions.ActOnTypeTrait(TypeTraitFromTokKind(Kind), Arity, Loc, Args,
+ EndLoc);
}
/// ParseArrayTypeTrait - Parse the built-in array type-trait