summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2013-12-13 20:49:58 +0000
committerAlp Toker <alp@nuanti.com>2013-12-13 20:49:58 +0000
commitcbb29af710b6536a7e901a9980aa89c4df7d8d43 (patch)
tree5dd9a07284256900ffae7fb98c936a2380499d4a
parentc614b2d1a9b89b73f991b454be1299bd0adeed01 (diff)
downloadclang-cbb29af710b6536a7e901a9980aa89c4df7d8d43.tar.gz
clang-cbb29af710b6536a7e901a9980aa89c4df7d8d43.tar.bz2
clang-cbb29af710b6536a7e901a9980aa89c4df7d8d43.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197273 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/ExprCXX.h72
-rw-r--r--include/clang/AST/RecursiveASTVisitor.h5
-rw-r--r--include/clang/Basic/StmtNodes.td1
-rw-r--r--include/clang/Basic/TypeTraits.h17
-rw-r--r--include/clang/Sema/Sema.h18
-rw-r--r--include/clang/Serialization/ASTBitCodes.h1
-rw-r--r--lib/AST/Expr.cpp1
-rw-r--r--lib/AST/ExprClassification.cpp1
-rw-r--r--lib/AST/ExprConstant.cpp5
-rw-r--r--lib/AST/ItaniumMangle.cpp1
-rw-r--r--lib/AST/StmtPrinter.cpp20
-rw-r--r--lib/AST/StmtProfile.cpp7
-rw-r--r--lib/CodeGen/CGExprScalar.cpp2
-rw-r--r--lib/Parse/ParseExprCXX.cpp24
-rw-r--r--lib/Sema/SemaExceptionSpec.cpp1
-rw-r--r--lib/Sema/SemaExprCXX.cpp89
-rw-r--r--lib/Sema/TreeTransform.h33
-rw-r--r--lib/Serialization/ASTReaderStmt.cpp15
-rw-r--r--lib/Serialization/ASTWriter.cpp1
-rw-r--r--lib/Serialization/ASTWriterStmt.cpp10
-rw-r--r--lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp1
-rw-r--r--lib/StaticAnalyzer/Core/ExprEngine.cpp1
-rw-r--r--test/CXX/temp/temp.decls/temp.variadic/p5.cpp2
-rw-r--r--test/CodeGenCXX/type-traits.cpp (renamed from test/CodeGenCXX/unary-type-trait.cpp)2
-rw-r--r--tools/libclang/CIndex.cpp6
-rw-r--r--tools/libclang/CXCursor.cpp1
-rw-r--r--tools/libclang/RecursiveASTVisitor.h5
27 files changed, 54 insertions, 288 deletions
diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h
index 6356ee7aee..ee46e1a59d 100644
--- a/include/clang/AST/ExprCXX.h
+++ b/include/clang/AST/ExprCXX.h
@@ -2168,76 +2168,6 @@ public:
friend class ASTStmtReader;
};
-/// \brief Represents a GCC or MS binary type trait, as used in the
-/// implementation of TR1/C++11 type trait templates.
-///
-/// Example:
-/// \code
-/// __is_base_of(Base, Derived) == true
-/// \endcode
-class BinaryTypeTraitExpr : public Expr {
- /// \brief The trait. A BinaryTypeTrait enum in MSVC compatible unsigned.
- unsigned BTT : 8;
-
- /// The value of the type trait. Unspecified if dependent.
- bool Value : 1;
-
- /// \brief The location of the type trait keyword.
- SourceLocation Loc;
-
- /// \brief The location of the closing paren.
- SourceLocation RParen;
-
- /// \brief The lhs type being queried.
- TypeSourceInfo *LhsType;
-
- /// \brief The rhs type being queried.
- TypeSourceInfo *RhsType;
-
-public:
- BinaryTypeTraitExpr(SourceLocation loc, BinaryTypeTrait btt,
- TypeSourceInfo *lhsType, TypeSourceInfo *rhsType,
- bool value, SourceLocation rparen, QualType ty)
- : Expr(BinaryTypeTraitExprClass, ty, VK_RValue, OK_Ordinary, false,
- lhsType->getType()->isDependentType() ||
- rhsType->getType()->isDependentType(),
- (lhsType->getType()->isInstantiationDependentType() ||
- rhsType->getType()->isInstantiationDependentType()),
- (lhsType->getType()->containsUnexpandedParameterPack() ||
- rhsType->getType()->containsUnexpandedParameterPack())),
- BTT(btt), Value(value), Loc(loc), RParen(rparen),
- LhsType(lhsType), RhsType(rhsType) { }
-
-
- explicit BinaryTypeTraitExpr(EmptyShell Empty)
- : Expr(BinaryTypeTraitExprClass, Empty), BTT(0), Value(false),
- LhsType(), RhsType() { }
-
- SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
- SourceLocation getLocEnd() const LLVM_READONLY { return RParen; }
-
- BinaryTypeTrait getTrait() const {
- return static_cast<BinaryTypeTrait>(BTT);
- }
-
- QualType getLhsType() const { return LhsType->getType(); }
- QualType getRhsType() const { return RhsType->getType(); }
-
- TypeSourceInfo *getLhsTypeSourceInfo() const { return LhsType; }
- TypeSourceInfo *getRhsTypeSourceInfo() const { return RhsType; }
-
- bool getValue() const { assert(!isTypeDependent()); return Value; }
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == BinaryTypeTraitExprClass;
- }
-
- // Iterators
- child_range children() { return child_range(); }
-
- friend class ASTStmtReader;
-};
-
/// \brief A type trait used in the implementation of various C++11 and
/// Library TR1 trait templates.
///
@@ -2334,7 +2264,7 @@ public:
friend class ASTStmtWriter;
};
-
+
/// \brief An Embarcadero array type trait, as used in the implementation of
/// __array_rank and __array_extent.
///
diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h
index 3c615c3035..58034e8dc4 100644
--- a/include/clang/AST/RecursiveASTVisitor.h
+++ b/include/clang/AST/RecursiveASTVisitor.h
@@ -2145,11 +2145,6 @@ DEF_TRAVERSE_STMT(UnaryTypeTraitExpr, {
TRY_TO(TraverseTypeLoc(S->getQueriedTypeSourceInfo()->getTypeLoc()));
})
-DEF_TRAVERSE_STMT(BinaryTypeTraitExpr, {
- TRY_TO(TraverseTypeLoc(S->getLhsTypeSourceInfo()->getTypeLoc()));
- TRY_TO(TraverseTypeLoc(S->getRhsTypeSourceInfo()->getTypeLoc()));
- })
-
DEF_TRAVERSE_STMT(TypeTraitExpr, {
for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
TRY_TO(TraverseTypeLoc(S->getArg(I)->getTypeLoc()));
diff --git a/include/clang/Basic/StmtNodes.td b/include/clang/Basic/StmtNodes.td
index 69851a9d52..e43e022f95 100644
--- a/include/clang/Basic/StmtNodes.td
+++ b/include/clang/Basic/StmtNodes.td
@@ -116,7 +116,6 @@ def CXXDeleteExpr : DStmt<Expr>;
def CXXPseudoDestructorExpr : DStmt<Expr>;
def TypeTraitExpr : DStmt<Expr>;
def UnaryTypeTraitExpr : DStmt<Expr>;
-def BinaryTypeTraitExpr : DStmt<Expr>;
def ArrayTypeTraitExpr : DStmt<Expr>;
def ExpressionTraitExpr : DStmt<Expr>;
def DependentScopeDeclRefExpr : DStmt<Expr>;
diff --git a/include/clang/Basic/TypeTraits.h b/include/clang/Basic/TypeTraits.h
index fc53527188..87d9d01d8f 100644
--- a/include/clang/Basic/TypeTraits.h
+++ b/include/clang/Basic/TypeTraits.h
@@ -68,16 +68,6 @@ namespace clang {
UTT_IsVolatile
};
- /// \brief Names for the binary type traits.
- enum BinaryTypeTrait {
- BTT_IsBaseOf,
- BTT_IsConvertible,
- BTT_IsConvertibleTo,
- BTT_IsSame,
- BTT_TypeCompatible,
- BTT_IsTriviallyAssignable
- };
-
/// \brief Names for the array type traits.
enum ArrayTypeTrait {
ATT_ArrayRank,
@@ -93,6 +83,13 @@ namespace clang {
/// \brief Names for type traits that operate specifically on types.
enum TypeTrait {
+ BTT_IsBaseOf,
+ BTT_IsConvertible,
+ BTT_IsConvertibleTo,
+ BTT_IsSame,
+ BTT_TypeCompatible,
+ BTT_IsTriviallyAssignable,
+ BTT_Last = BTT_IsTriviallyAssignable,
TT_IsTriviallyConstructible
};
diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h
index 67f62ce702..fbb0cd06c2 100644
--- a/include/clang/Sema/Sema.h
+++ b/include/clang/Sema/Sema.h
@@ -4218,23 +4218,9 @@ public:
TypeSourceInfo *T,
SourceLocation RParen);
- /// ActOnBinaryTypeTrait - Parsed one of the bianry type trait support
- /// pseudo-functions.
- ExprResult ActOnBinaryTypeTrait(BinaryTypeTrait OTT,
- SourceLocation KWLoc,
- ParsedType LhsTy,
- ParsedType RhsTy,
- SourceLocation RParen);
-
- ExprResult BuildBinaryTypeTrait(BinaryTypeTrait BTT,
- SourceLocation KWLoc,
- TypeSourceInfo *LhsT,
- TypeSourceInfo *RhsT,
- SourceLocation RParen);
-
/// \brief Parsed one of the type trait support pseudo-functions.
- ExprResult ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
- ArrayRef<ParsedType> Args,
+ ExprResult ActOnTypeTrait(TypeTrait Kind, unsigned Arity,
+ SourceLocation KWLoc, ArrayRef<ParsedType> Args,
SourceLocation RParenLoc);
ExprResult BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
ArrayRef<TypeSourceInfo *> Args,
diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h
index 440e9a714d..7195368616 100644
--- a/include/clang/Serialization/ASTBitCodes.h
+++ b/include/clang/Serialization/ASTBitCodes.h
@@ -1308,7 +1308,6 @@ namespace clang {
EXPR_OPAQUE_VALUE, // OpaqueValueExpr
EXPR_BINARY_CONDITIONAL_OPERATOR, // BinaryConditionalOperator
- EXPR_BINARY_TYPE_TRAIT, // BinaryTypeTraitExpr
EXPR_TYPE_TRAIT, // TypeTraitExpr
EXPR_ARRAY_TYPE_TRAIT, // ArrayTypeTraitIntExpr
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index d9776a1422..6060f8bf2f 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -2799,7 +2799,6 @@ bool Expr::HasSideEffects(const ASTContext &Ctx) const {
case CXXScalarValueInitExprClass:
case TypeTraitExprClass:
case UnaryTypeTraitExprClass:
- case BinaryTypeTraitExprClass:
case ArrayTypeTraitExprClass:
case ExpressionTraitExprClass:
case CXXNoexceptExprClass:
diff --git a/lib/AST/ExprClassification.cpp b/lib/AST/ExprClassification.cpp
index 54f77efef0..bea6d565dd 100644
--- a/lib/AST/ExprClassification.cpp
+++ b/lib/AST/ExprClassification.cpp
@@ -166,7 +166,6 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) {
case Expr::CXXNoexceptExprClass:
case Expr::CXXScalarValueInitExprClass:
case Expr::UnaryTypeTraitExprClass:
- case Expr::BinaryTypeTraitExprClass:
case Expr::TypeTraitExprClass:
case Expr::ArrayTypeTraitExprClass:
case Expr::ExpressionTraitExprClass:
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 60a39a552e..8ceffefb1a 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -5731,10 +5731,6 @@ public:
return Success(E->getValue(), E);
}
- bool VisitBinaryTypeTraitExpr(const BinaryTypeTraitExpr *E) {
- return Success(E->getValue(), E);
- }
-
bool VisitTypeTraitExpr(const TypeTraitExpr *E) {
return Success(E->getValue(), E);
}
@@ -8328,7 +8324,6 @@ static ICEDiag CheckICE(const Expr* E, const ASTContext &Ctx) {
case Expr::CXXBoolLiteralExprClass:
case Expr::CXXScalarValueInitExprClass:
case Expr::UnaryTypeTraitExprClass:
- case Expr::BinaryTypeTraitExprClass:
case Expr::TypeTraitExprClass:
case Expr::ArrayTypeTraitExprClass:
case Expr::ExpressionTraitExprClass:
diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp
index 245cc5e164..0abf5d186e 100644
--- a/lib/AST/ItaniumMangle.cpp
+++ b/lib/AST/ItaniumMangle.cpp
@@ -2583,7 +2583,6 @@ recurse:
case Expr::ConvertVectorExprClass:
case Expr::StmtExprClass:
case Expr::UnaryTypeTraitExprClass:
- case Expr::BinaryTypeTraitExprClass:
case Expr::TypeTraitExprClass:
case Expr::ArrayTypeTraitExprClass:
case Expr::ExpressionTraitExprClass:
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index 7f9e98a904..68f78f152f 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -1691,17 +1691,11 @@ static const char *getTypeTraitName(UnaryTypeTrait UTT) {
llvm_unreachable("Type trait not covered by switch statement");
}
-static const char *getTypeTraitName(BinaryTypeTrait BTT) {
- switch (BTT) {
-#define TYPE_TRAIT_2(Spelling, Name, Key) \
- case clang::BTT_##Name: return #Spelling;
-#include "clang/Basic/TokenKinds.def"
- }
- llvm_unreachable("Binary type trait not covered by switch");
-}
-
static const char *getTypeTraitName(TypeTrait TT) {
switch (TT) {
+#define TYPE_TRAIT_2(Spelling, Name, Key) \
+case clang::BTT_##Name: return #Spelling;
+#include "clang/Basic/TokenKinds.def"
#define TYPE_TRAIT_N(Spelling, Name, Key) \
case clang::TT_##Name: return #Spelling;
#include "clang/Basic/TokenKinds.def"
@@ -1731,14 +1725,6 @@ void StmtPrinter::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
OS << ')';
}
-void StmtPrinter::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
- OS << getTypeTraitName(E->getTrait()) << '(';
- E->getLhsType().print(OS, Policy);
- OS << ',';
- E->getRhsType().print(OS, Policy);
- OS << ')';
-}
-
void StmtPrinter::VisitTypeTraitExpr(TypeTraitExpr *E) {
OS << getTypeTraitName(E->getTrait()) << "(";
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp
index 6805e62bef..e10c59dbd8 100644
--- a/lib/AST/StmtProfile.cpp
+++ b/lib/AST/StmtProfile.cpp
@@ -954,13 +954,6 @@ void StmtProfiler::VisitUnaryTypeTraitExpr(const UnaryTypeTraitExpr *S) {
VisitType(S->getQueriedType());
}
-void StmtProfiler::VisitBinaryTypeTraitExpr(const BinaryTypeTraitExpr *S) {
- VisitExpr(S);
- ID.AddInteger(S->getTrait());
- VisitType(S->getLhsType());
- VisitType(S->getRhsType());
-}
-
void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) {
VisitExpr(S);
ID.AddInteger(S->getTrait());
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index d734e3c927..eea1bf8b82 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -371,7 +371,7 @@ public:
return Builder.getInt1(E->getValue());
}
- Value *VisitBinaryTypeTraitExpr(const BinaryTypeTraitExpr *E) {
+ Value *VisitTypeTraitExpr(const TypeTraitExpr *E) {
return llvm::ConstantInt::get(ConvertType(E->getType()), E->getValue());
}
diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp
index 846995e0ce..9c2cfcc490 100644
--- a/lib/Parse/ParseExprCXX.cpp
+++ b/lib/Parse/ParseExprCXX.cpp
@@ -2693,18 +2693,12 @@ static UnaryTypeTrait UnaryTypeTraitFromTokKind(tok::TokenKind kind) {
}
}
-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 @@ ExprResult Parser::ParseTypeTrait() {
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
diff --git a/lib/Sema/SemaExceptionSpec.cpp b/lib/Sema/SemaExceptionSpec.cpp
index 3e8f324027..72ff109af7 100644
--- a/lib/Sema/SemaExceptionSpec.cpp
+++ b/lib/Sema/SemaExceptionSpec.cpp
@@ -1063,7 +1063,6 @@ CanThrowResult Sema::canThrow(const Expr *E) {
case Expr::AddrLabelExprClass:
case Expr::ArrayTypeTraitExprClass:
case Expr::AtomicExprClass:
- case Expr::BinaryTypeTraitExprClass:
case Expr::TypeTraitExprClass:
case Expr::CXXBoolLiteralExprClass:
case Expr::CXXNoexceptExprClass:
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 2c9eb63f15..ef89490c43 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -3595,24 +3595,6 @@ ExprResult Sema::BuildUnaryTypeTrait(UnaryTypeTrait UTT,
RParen, Context.BoolTy));
}
-ExprResult Sema::ActOnBinaryTypeTrait(BinaryTypeTrait BTT,
- SourceLocation KWLoc,
- ParsedType LhsTy,
- ParsedType RhsTy,
- SourceLocation RParen) {
- TypeSourceInfo *LhsTSInfo;
- QualType LhsT = GetTypeFromParser(LhsTy, &LhsTSInfo);
- if (!LhsTSInfo)
- LhsTSInfo = Context.getTrivialTypeSourceInfo(LhsT);
-
- TypeSourceInfo *RhsTSInfo;
- QualType RhsT = GetTypeFromParser(RhsTy, &RhsTSInfo);
- if (!RhsTSInfo)
- RhsTSInfo = Context.getTrivialTypeSourceInfo(RhsT);
-
- return BuildBinaryTypeTrait(BTT, KWLoc, LhsTSInfo, RhsTSInfo, RParen);
-}
-
/// \brief Determine whether T has a non-trivial Objective-C lifetime in
/// ARC mode.
static bool hasNontrivialObjCLifetime(QualType T) {
@@ -3632,9 +3614,16 @@ static bool hasNontrivialObjCLifetime(QualType T) {
llvm_unreachable("Unknown ObjC lifetime qualifier");
}
+static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, QualType LhsT,
+ QualType RhsT, SourceLocation KeyLoc);
+
static bool evaluateTypeTrait(Sema &S, TypeTrait Kind, SourceLocation KWLoc,
ArrayRef<TypeSourceInfo *> Args,
SourceLocation RParenLoc) {
+ if (Kind <= BTT_Last)
+ return EvaluateBinaryTypeTrait(S, Kind, Args[0]->getType(),
+ Args[1]->getType(), RParenLoc);
+
switch (Kind) {
case clang::TT_IsTriviallyConstructible: {
// C++11 [meta.unary.prop]:
@@ -3709,6 +3698,7 @@ static bool evaluateTypeTrait(Sema &S, TypeTrait Kind, SourceLocation KWLoc,
// calls.
return !Result.get()->hasNonTrivialCall(S.Context);
}
+ default: llvm_unreachable("not a TT");
}
return false;
@@ -3717,6 +3707,17 @@ static bool evaluateTypeTrait(Sema &S, TypeTrait Kind, SourceLocation KWLoc,
ExprResult Sema::BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
ArrayRef<TypeSourceInfo *> Args,
SourceLocation RParenLoc) {
+ QualType ResultType = Context.BoolTy;
+ // __builtin_types_compatible_p is a GNU C extension, not a C++ type trait.
+ if (Kind == BTT_TypeCompatible) {
+ ResultType = Context.IntTy;
+ if (getLangOpts().CPlusPlus) {
+ Diag(KWLoc, diag::err_types_compatible_p_in_cplusplus)
+ << SourceRange(KWLoc, RParenLoc);
+ return ExprError();
+ }
+ }
+
bool Dependent = false;
for (unsigned I = 0, N = Args.size(); I != N; ++I) {
if (Args[I]->getType()->isDependentType()) {
@@ -3724,17 +3725,17 @@ ExprResult Sema::BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
break;
}
}
-
- bool Value = false;
+
+ bool Result = false;
if (!Dependent)
- Value = evaluateTypeTrait(*this, Kind, KWLoc, Args, RParenLoc);
-
- return TypeTraitExpr::Create(Context, Context.BoolTy, KWLoc, Kind,
- Args, RParenLoc, Value);
+ Result = evaluateTypeTrait(*this, Kind, KWLoc, Args, RParenLoc);
+
+ return TypeTraitExpr::Create(Context, ResultType, KWLoc, Kind, Args,
+ RParenLoc, Result);
}
-ExprResult Sema::ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
- ArrayRef<ParsedType> Args,
+ExprResult Sema::ActOnTypeTrait(TypeTrait Kind, unsigned Arity,
+ SourceLocation KWLoc, ArrayRef<ParsedType> Args,
SourceLocation RParenLoc) {
SmallVector<TypeSourceInfo *, 4> ConvertedArgs;
ConvertedArgs.reserve(Args.size());
@@ -3747,13 +3748,12 @@ ExprResult Sema::ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
ConvertedArgs.push_back(TInfo);
}
-
+
return BuildTypeTrait(Kind, KWLoc, ConvertedArgs, RParenLoc);
}
-static bool EvaluateBinaryTypeTrait(Sema &Self, BinaryTypeTrait BTT,
- QualType LhsT, QualType RhsT,
- SourceLocation KeyLoc) {
+static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, QualType LhsT,
+ QualType RhsT, SourceLocation KeyLoc) {
assert(!LhsT->isDependentType() && !RhsT->isDependentType() &&
"Cannot evaluate traits of dependent types");
@@ -3910,38 +3910,11 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, BinaryTypeTrait BTT,
return !Result.get()->hasNonTrivialCall(Self.Context);
}
+ default: llvm_unreachable("not a BTT");
}
llvm_unreachable("Unknown type trait or not implemented");
}
-ExprResult Sema::BuildBinaryTypeTrait(BinaryTypeTrait BTT,
- SourceLocation KWLoc,
- TypeSourceInfo *LhsTSInfo,
- TypeSourceInfo *RhsTSInfo,
- SourceLocation RParen) {
- QualType LhsT = LhsTSInfo->getType();
- QualType RhsT = RhsTSInfo->getType();
- QualType ResultType = Context.BoolTy;
-
- // __builtin_types_compatible_p is a GNU C extension, not a C++ type trait.
- if (BTT == BTT_TypeCompatible) {
- ResultType = Context.IntTy;
- if (getLangOpts().CPlusPlus) {
- Diag(KWLoc, diag::err_types_compatible_p_in_cplusplus)
- << SourceRange(KWLoc, RParen);
- return ExprError();
- }
- }
-
- bool Value = false;
- if (!LhsT->isDependentType() && !RhsT->isDependentType())
- Value = EvaluateBinaryTypeTrait(*this, BTT, LhsT, RhsT, KWLoc);
-
- return Owned(new (Context) BinaryTypeTraitExpr(KWLoc, BTT, LhsTSInfo,
- RhsTSInfo, Value, RParen,
- ResultType));
-}
-
ExprResult Sema::ActOnArrayTypeTrait(ArrayTypeTrait ATT,
SourceLocation KWLoc,
ParsedType Ty,
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index 463020a694..8c7838e6a7 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -2146,18 +2146,6 @@ public:
return getSema().BuildUnaryTypeTrait(Trait, StartLoc, T, RParenLoc);
}
- /// \brief Build a new binary type trait expression.
- ///
- /// By default, performs semantic analysis to build the new expression.
- /// Subclasses may override this routine to provide different behavior.
- ExprResult RebuildBinaryTypeTrait(BinaryTypeTrait Trait,
- SourceLocation StartLoc,
- TypeSourceInfo *LhsT,
- TypeSourceInfo *RhsT,
- SourceLocation RParenLoc) {
- return getSema().BuildBinaryTypeTrait(Trait, StartLoc, LhsT, RhsT, RParenLoc);
- }
-
/// \brief Build a new type trait expression.
///
/// By default, performs semantic analysis to build the new expression.
@@ -7895,27 +7883,6 @@ TreeTransform<Derived>::TransformUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
template<typename Derived>
ExprResult
-TreeTransform<Derived>::TransformBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
- TypeSourceInfo *LhsT = getDerived().TransformType(E->getLhsTypeSourceInfo());
- if (!LhsT)
- return ExprError();
-
- TypeSourceInfo *RhsT = getDerived().TransformType(E->getRhsTypeSourceInfo());
- if (!RhsT)
- return ExprError();
-
- if (!getDerived().AlwaysRebuild() &&
- LhsT == E->getLhsTypeSourceInfo() && RhsT == E->getRhsTypeSourceInfo())
- return SemaRef.Owned(E);
-
- return getDerived().RebuildBinaryTypeTrait(E->getTrait(),
- E->getLocStart(),
- LhsT, RhsT,
- E->getLocEnd());
-}
-
-template<typename Derived>
-ExprResult
TreeTransform<Derived>::TransformTypeTraitExpr(TypeTraitExpr *E) {
bool ArgChanged = false;
SmallVector<TypeSourceInfo *, 4> Args;
diff --git a/lib/Serialization/ASTReaderStmt.cpp b/lib/Serialization/ASTReaderStmt.cpp
index 3a3c761456..cce3fb17ae 100644
--- a/lib/Serialization/ASTReaderStmt.cpp
+++ b/lib/Serialization/ASTReaderStmt.cpp
@@ -1494,17 +1494,6 @@ void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
E->QueriedType = GetTypeSourceInfo(Record, Idx);
}
-void ASTStmtReader::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
- VisitExpr(E);
- E->BTT = (BinaryTypeTrait)Record[Idx++];
- E->Value = (bool)Record[Idx++];
- SourceRange Range = ReadSourceRange(Record, Idx);
- E->Loc = Range.getBegin();
- E->RParen = Range.getEnd();
- E->LhsType = GetTypeSourceInfo(Record, Idx);
- E->RhsType = GetTypeSourceInfo(Record, Idx);
-}
-
void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
VisitExpr(E);
E->TypeTraitExprBits.NumArgs = Record[Idx++];
@@ -2398,10 +2387,6 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
S = new (Context) UnaryTypeTraitExpr(Empty);
break;
- case EXPR_BINARY_TYPE_TRAIT:
- S = new (Context) BinaryTypeTraitExpr(Empty);
- break;
-
case EXPR_TYPE_TRAIT:
S = TypeTraitExpr::CreateDeserialized(Context,
Record[ASTStmtReader::NumExprFields]);
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp
index 56eddb77e0..0bad0941db 100644
--- a/lib/Serialization/ASTWriter.cpp
+++ b/lib/Serialization/ASTWriter.cpp
@@ -776,7 +776,6 @@ static void AddStmtsExprs(llvm::BitstreamWriter &Stream,
RECORD(EXPR_CXX_UNARY_TYPE_TRAIT);
RECORD(EXPR_CXX_NOEXCEPT);
RECORD(EXPR_OPAQUE_VALUE);
- RECORD(EXPR_BINARY_TYPE_TRAIT);
RECORD(EXPR_PACK_EXPANSION);
RECORD(EXPR_SIZEOF_PACK);
RECORD(EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK);
diff --git a/lib/Serialization/ASTWriterStmt.cpp b/lib/Serialization/ASTWriterStmt.cpp
index 433ef0755d..c5c65ef908 100644
--- a/lib/Serialization/ASTWriterStmt.cpp
+++ b/lib/Serialization/ASTWriterStmt.cpp
@@ -1495,16 +1495,6 @@ void ASTStmtWriter::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
Code = serialization::EXPR_CXX_UNARY_TYPE_TRAIT;
}
-void ASTStmtWriter::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
- VisitExpr(E);
- Record.push_back(E->getTrait());
- Record.push_back(E->getValue());
- Writer.AddSourceRange(E->getSourceRange(), Record);
- Writer.AddTypeSourceInfo(E->getLhsTypeSourceInfo(), Record);
- Writer.AddTypeSourceInfo(E->getRhsTypeSourceInfo(), Record);
- Code = serialization::EXPR_BINARY_TYPE_TRAIT;
-}
-
void ASTStmtWriter::VisitTypeTraitExpr(TypeTraitExpr *E) {
VisitExpr(E);
Record.push_back(E->TypeTraitExprBits.NumArgs);
diff --git a/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp b/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp
index 4997f8d04a..cc067e2b79 100644
--- a/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp
@@ -646,7 +646,6 @@ bool IdempotentOperationChecker::CanVary(const Expr *Ex,
case Stmt::OffsetOfExprClass:
case Stmt::CompoundLiteralExprClass:
case Stmt::AddrLabelExprClass:
- case Stmt::BinaryTypeTraitExprClass:
case Stmt::GNUNullExprClass:
case Stmt::InitListExprClass:
case Stmt::DesignatedInitExprClass:
diff --git a/lib/StaticAnalyzer/Core/ExprEngine.cpp b/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 970fecd1b4..36be970485 100644
--- a/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -664,7 +664,6 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
case Stmt::CXXUnresolvedConstructExprClass:
case Stmt::DependentScopeDeclRefExprClass:
case Stmt::UnaryTypeTraitExprClass:
- case Stmt::BinaryTypeTraitExprClass:
case Stmt::TypeTraitExprClass:
case Stmt::ArrayTypeTraitExprClass:
case Stmt::ExpressionTraitExprClass:
diff --git a/test/CXX/temp/temp.decls/temp.variadic/p5.cpp b/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
index 3681d7757e..d9c71cb77a 100644
--- a/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
+++ b/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
@@ -313,7 +313,7 @@ void test_unexpanded_exprs(Types ...values) {
// UnaryTypeTraitExpr
__is_pod(Types); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
- // BinaryTypeTraitExpr
+ // Binary TypeTraitExpr
__is_base_of(Types, T); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
__is_base_of(T, Types); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
diff --git a/test/CodeGenCXX/unary-type-trait.cpp b/test/CodeGenCXX/type-traits.cpp
index 3c6f9c03aa..93cc6b56f1 100644
--- a/test/CodeGenCXX/unary-type-trait.cpp
+++ b/test/CodeGenCXX/type-traits.cpp
@@ -2,3 +2,5 @@
// expected-no-diagnostics
bool a() { return __is_pod(int); }
+
+bool b() { return __is_trivially_constructible(int, int, int); }
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index e7da9620dc..68be23f2f5 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -1840,7 +1840,6 @@ public:
void VisitSwitchStmt(const SwitchStmt *S);
void VisitWhileStmt(const WhileStmt *W);
void VisitUnaryTypeTraitExpr(const UnaryTypeTraitExpr *E);
- void VisitBinaryTypeTraitExpr(const BinaryTypeTraitExpr *E);
void VisitTypeTraitExpr(const TypeTraitExpr *E);
void VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *E);
void VisitExpressionTraitExpr(const ExpressionTraitExpr *E);
@@ -2189,11 +2188,6 @@ void EnqueueVisitor::VisitUnaryTypeTraitExpr(const UnaryTypeTraitExpr *E) {
AddTypeLoc(E->getQueriedTypeSourceInfo());
}
-void EnqueueVisitor::VisitBinaryTypeTraitExpr(const BinaryTypeTraitExpr *E) {
- AddTypeLoc(E->getRhsTypeSourceInfo());
- AddTypeLoc(E->getLhsTypeSourceInfo());
-}
-
void EnqueueVisitor::VisitTypeTraitExpr(const TypeTraitExpr *E) {
for (unsigned I = E->getNumArgs(); I > 0; --I)
AddTypeLoc(E->getArg(I-1));
diff --git a/tools/libclang/CXCursor.cpp b/tools/libclang/CXCursor.cpp
index c75c061cf4..aaaba39363 100644
--- a/tools/libclang/CXCursor.cpp
+++ b/tools/libclang/CXCursor.cpp
@@ -213,7 +213,6 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
case Stmt::AsTypeExprClass:
case Stmt::AtomicExprClass:
case Stmt::BinaryConditionalOperatorClass:
- case Stmt::BinaryTypeTraitExprClass:
case Stmt::TypeTraitExprClass:
case Stmt::CXXBindTemporaryExprClass:
case Stmt::CXXDefaultArgExprClass:
diff --git a/tools/libclang/RecursiveASTVisitor.h b/tools/libclang/RecursiveASTVisitor.h
index 5907b1dd5a..fa574f66a1 100644
--- a/tools/libclang/RecursiveASTVisitor.h
+++ b/tools/libclang/RecursiveASTVisitor.h
@@ -2123,11 +2123,6 @@ DEF_TRAVERSE_STMT(UnaryTypeTraitExpr, {
TRY_TO(TraverseTypeLoc(S->getQueriedTypeSourceInfo()->getTypeLoc()));
})
-DEF_TRAVERSE_STMT(BinaryTypeTraitExpr, {
- TRY_TO(TraverseTypeLoc(S->getLhsTypeSourceInfo()->getTypeLoc()));
- TRY_TO(TraverseTypeLoc(S->getRhsTypeSourceInfo()->getTypeLoc()));
- })
-
DEF_TRAVERSE_STMT(TypeTraitExpr, {
for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
TRY_TO(TraverseTypeLoc(S->getArg(I)->getTypeLoc()));