forked from OSchip/llvm-project
Eliminate UnaryTypeTraitExpr
Remove UnaryTypeTraitExpr and switch all remaining type trait related handling over to TypeTraitExpr. The UTT/BTT/TT enum prefix and evaluation code is retained pending further cleanup. This is part of the ongoing work to unify type traits following the removal of BinaryTypeTraitExpr in r197273. llvm-svn: 198271
This commit is contained in:
parent
383d2c478c
commit
95e7ff2ed1
|
@ -2149,10 +2149,6 @@ DEF_TRAVERSE_STMT(CXXUuidofExpr, {
|
||||||
TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
|
TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
|
||||||
})
|
})
|
||||||
|
|
||||||
DEF_TRAVERSE_STMT(UnaryTypeTraitExpr, {
|
|
||||||
TRY_TO(TraverseTypeLoc(S->getQueriedTypeSourceInfo()->getTypeLoc()));
|
|
||||||
})
|
|
||||||
|
|
||||||
DEF_TRAVERSE_STMT(TypeTraitExpr, {
|
DEF_TRAVERSE_STMT(TypeTraitExpr, {
|
||||||
for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
|
for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
|
||||||
TRY_TO(TraverseTypeLoc(S->getArg(I)->getTypeLoc()));
|
TRY_TO(TraverseTypeLoc(S->getArg(I)->getTypeLoc()));
|
||||||
|
|
|
@ -2110,68 +2110,12 @@ public:
|
||||||
child_range children() { return child_range(&Base, &Base + 1); }
|
child_range children() { return child_range(&Base, &Base + 1); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief Represents a GCC or MS unary type trait, as used in the
|
|
||||||
/// implementation of TR1/C++11 type trait templates.
|
|
||||||
///
|
|
||||||
/// Example:
|
|
||||||
/// \code
|
|
||||||
/// __is_pod(int) == true
|
|
||||||
/// __is_enum(std::string) == false
|
|
||||||
/// \endcode
|
|
||||||
class UnaryTypeTraitExpr : public Expr {
|
|
||||||
/// \brief The trait. A UnaryTypeTrait enum in MSVC compatible unsigned.
|
|
||||||
unsigned UTT : 31;
|
|
||||||
/// 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 type being queried.
|
|
||||||
TypeSourceInfo *QueriedType;
|
|
||||||
|
|
||||||
public:
|
|
||||||
UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt,
|
|
||||||
TypeSourceInfo *queried, bool value,
|
|
||||||
SourceLocation rparen, QualType ty)
|
|
||||||
: Expr(UnaryTypeTraitExprClass, ty, VK_RValue, OK_Ordinary,
|
|
||||||
false, queried->getType()->isDependentType(),
|
|
||||||
queried->getType()->isInstantiationDependentType(),
|
|
||||||
queried->getType()->containsUnexpandedParameterPack()),
|
|
||||||
UTT(utt), Value(value), Loc(loc), RParen(rparen), QueriedType(queried) { }
|
|
||||||
|
|
||||||
explicit UnaryTypeTraitExpr(EmptyShell Empty)
|
|
||||||
: Expr(UnaryTypeTraitExprClass, Empty), UTT(0), Value(false),
|
|
||||||
QueriedType() { }
|
|
||||||
|
|
||||||
SourceLocation getLocStart() const LLVM_READONLY { return Loc; }
|
|
||||||
SourceLocation getLocEnd() const LLVM_READONLY { return RParen; }
|
|
||||||
|
|
||||||
UnaryTypeTrait getTrait() const { return static_cast<UnaryTypeTrait>(UTT); }
|
|
||||||
|
|
||||||
QualType getQueriedType() const { return QueriedType->getType(); }
|
|
||||||
|
|
||||||
TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; }
|
|
||||||
|
|
||||||
bool getValue() const { return Value; }
|
|
||||||
|
|
||||||
static bool classof(const Stmt *T) {
|
|
||||||
return T->getStmtClass() == UnaryTypeTraitExprClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Iterators
|
|
||||||
child_range children() { return child_range(); }
|
|
||||||
|
|
||||||
friend class ASTStmtReader;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// \brief A type trait used in the implementation of various C++11 and
|
/// \brief A type trait used in the implementation of various C++11 and
|
||||||
/// Library TR1 trait templates.
|
/// Library TR1 trait templates.
|
||||||
///
|
///
|
||||||
/// \code
|
/// \code
|
||||||
|
/// __is_pod(int) == true
|
||||||
|
/// __is_enum(std::string) == false
|
||||||
/// __is_trivially_constructible(vector<int>, int*, int*)
|
/// __is_trivially_constructible(vector<int>, int*, int*)
|
||||||
/// \endcode
|
/// \endcode
|
||||||
class TypeTraitExpr : public Expr {
|
class TypeTraitExpr : public Expr {
|
||||||
|
|
|
@ -2173,10 +2173,6 @@ DEF_TRAVERSE_STMT(CXXUuidofExpr, {
|
||||||
TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
|
TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
|
||||||
})
|
})
|
||||||
|
|
||||||
DEF_TRAVERSE_STMT(UnaryTypeTraitExpr, {
|
|
||||||
TRY_TO(TraverseTypeLoc(S->getQueriedTypeSourceInfo()->getTypeLoc()));
|
|
||||||
})
|
|
||||||
|
|
||||||
DEF_TRAVERSE_STMT(TypeTraitExpr, {
|
DEF_TRAVERSE_STMT(TypeTraitExpr, {
|
||||||
for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
|
for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
|
||||||
TRY_TO(TraverseTypeLoc(S->getArg(I)->getTypeLoc()));
|
TRY_TO(TraverseTypeLoc(S->getArg(I)->getTypeLoc()));
|
||||||
|
|
|
@ -115,7 +115,6 @@ def CXXNewExpr : DStmt<Expr>;
|
||||||
def CXXDeleteExpr : DStmt<Expr>;
|
def CXXDeleteExpr : DStmt<Expr>;
|
||||||
def CXXPseudoDestructorExpr : DStmt<Expr>;
|
def CXXPseudoDestructorExpr : DStmt<Expr>;
|
||||||
def TypeTraitExpr : DStmt<Expr>;
|
def TypeTraitExpr : DStmt<Expr>;
|
||||||
def UnaryTypeTraitExpr : DStmt<Expr>;
|
|
||||||
def ArrayTypeTraitExpr : DStmt<Expr>;
|
def ArrayTypeTraitExpr : DStmt<Expr>;
|
||||||
def ExpressionTraitExpr : DStmt<Expr>;
|
def ExpressionTraitExpr : DStmt<Expr>;
|
||||||
def DependentScopeDeclRefExpr : DStmt<Expr>;
|
def DependentScopeDeclRefExpr : DStmt<Expr>;
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace clang {
|
namespace clang {
|
||||||
|
|
||||||
/// \brief Names for the unary type traits.
|
/// \brief Names for traits that operate specifically on types.
|
||||||
enum UnaryTypeTrait {
|
enum TypeTrait {
|
||||||
UTT_HasNothrowAssign,
|
UTT_HasNothrowAssign,
|
||||||
UTT_HasNothrowMoveAssign,
|
UTT_HasNothrowMoveAssign,
|
||||||
UTT_HasNothrowCopy,
|
UTT_HasNothrowCopy,
|
||||||
|
@ -65,7 +65,16 @@ namespace clang {
|
||||||
UTT_IsUnion,
|
UTT_IsUnion,
|
||||||
UTT_IsUnsigned,
|
UTT_IsUnsigned,
|
||||||
UTT_IsVoid,
|
UTT_IsVoid,
|
||||||
UTT_IsVolatile
|
UTT_IsVolatile,
|
||||||
|
UTT_Last = UTT_IsVolatile,
|
||||||
|
BTT_IsBaseOf,
|
||||||
|
BTT_IsConvertible,
|
||||||
|
BTT_IsConvertibleTo,
|
||||||
|
BTT_IsSame,
|
||||||
|
BTT_TypeCompatible,
|
||||||
|
BTT_IsTriviallyAssignable,
|
||||||
|
BTT_Last = BTT_IsTriviallyAssignable,
|
||||||
|
TT_IsTriviallyConstructible
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief Names for the array type traits.
|
/// \brief Names for the array type traits.
|
||||||
|
@ -80,19 +89,6 @@ namespace clang {
|
||||||
UETT_AlignOf,
|
UETT_AlignOf,
|
||||||
UETT_VecStep
|
UETT_VecStep
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \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
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4211,18 +4211,6 @@ public:
|
||||||
ExprResult BuildCXXNoexceptExpr(SourceLocation KeyLoc, Expr *Operand,
|
ExprResult BuildCXXNoexceptExpr(SourceLocation KeyLoc, Expr *Operand,
|
||||||
SourceLocation RParen);
|
SourceLocation RParen);
|
||||||
|
|
||||||
/// ActOnUnaryTypeTrait - Parsed one of the unary type trait support
|
|
||||||
/// pseudo-functions.
|
|
||||||
ExprResult ActOnUnaryTypeTrait(UnaryTypeTrait OTT,
|
|
||||||
SourceLocation KWLoc,
|
|
||||||
ParsedType Ty,
|
|
||||||
SourceLocation RParen);
|
|
||||||
|
|
||||||
ExprResult BuildUnaryTypeTrait(UnaryTypeTrait OTT,
|
|
||||||
SourceLocation KWLoc,
|
|
||||||
TypeSourceInfo *T,
|
|
||||||
SourceLocation RParen);
|
|
||||||
|
|
||||||
/// \brief Parsed one of the type trait support pseudo-functions.
|
/// \brief Parsed one of the type trait support pseudo-functions.
|
||||||
ExprResult ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
|
ExprResult ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
|
||||||
ArrayRef<ParsedType> Args,
|
ArrayRef<ParsedType> Args,
|
||||||
|
|
|
@ -1302,7 +1302,6 @@ namespace clang {
|
||||||
EXPR_CXX_UNRESOLVED_MEMBER, // UnresolvedMemberExpr
|
EXPR_CXX_UNRESOLVED_MEMBER, // UnresolvedMemberExpr
|
||||||
EXPR_CXX_UNRESOLVED_LOOKUP, // UnresolvedLookupExpr
|
EXPR_CXX_UNRESOLVED_LOOKUP, // UnresolvedLookupExpr
|
||||||
|
|
||||||
EXPR_CXX_UNARY_TYPE_TRAIT, // UnaryTypeTraitExpr
|
|
||||||
EXPR_CXX_EXPRESSION_TRAIT, // ExpressionTraitExpr
|
EXPR_CXX_EXPRESSION_TRAIT, // ExpressionTraitExpr
|
||||||
EXPR_CXX_NOEXCEPT, // CXXNoexceptExpr
|
EXPR_CXX_NOEXCEPT, // CXXNoexceptExpr
|
||||||
|
|
||||||
|
|
|
@ -2798,7 +2798,6 @@ bool Expr::HasSideEffects(const ASTContext &Ctx) const {
|
||||||
case CXXThisExprClass:
|
case CXXThisExprClass:
|
||||||
case CXXScalarValueInitExprClass:
|
case CXXScalarValueInitExprClass:
|
||||||
case TypeTraitExprClass:
|
case TypeTraitExprClass:
|
||||||
case UnaryTypeTraitExprClass:
|
|
||||||
case ArrayTypeTraitExprClass:
|
case ArrayTypeTraitExprClass:
|
||||||
case ExpressionTraitExprClass:
|
case ExpressionTraitExprClass:
|
||||||
case CXXNoexceptExprClass:
|
case CXXNoexceptExprClass:
|
||||||
|
|
|
@ -165,7 +165,6 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) {
|
||||||
case Expr::FloatingLiteralClass:
|
case Expr::FloatingLiteralClass:
|
||||||
case Expr::CXXNoexceptExprClass:
|
case Expr::CXXNoexceptExprClass:
|
||||||
case Expr::CXXScalarValueInitExprClass:
|
case Expr::CXXScalarValueInitExprClass:
|
||||||
case Expr::UnaryTypeTraitExprClass:
|
|
||||||
case Expr::TypeTraitExprClass:
|
case Expr::TypeTraitExprClass:
|
||||||
case Expr::ArrayTypeTraitExprClass:
|
case Expr::ArrayTypeTraitExprClass:
|
||||||
case Expr::ExpressionTraitExprClass:
|
case Expr::ExpressionTraitExprClass:
|
||||||
|
|
|
@ -5727,10 +5727,6 @@ public:
|
||||||
return ZeroInitialization(E);
|
return ZeroInitialization(E);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VisitUnaryTypeTraitExpr(const UnaryTypeTraitExpr *E) {
|
|
||||||
return Success(E->getValue(), E);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VisitTypeTraitExpr(const TypeTraitExpr *E) {
|
bool VisitTypeTraitExpr(const TypeTraitExpr *E) {
|
||||||
return Success(E->getValue(), E);
|
return Success(E->getValue(), E);
|
||||||
}
|
}
|
||||||
|
@ -8323,7 +8319,6 @@ static ICEDiag CheckICE(const Expr* E, const ASTContext &Ctx) {
|
||||||
case Expr::ObjCBoolLiteralExprClass:
|
case Expr::ObjCBoolLiteralExprClass:
|
||||||
case Expr::CXXBoolLiteralExprClass:
|
case Expr::CXXBoolLiteralExprClass:
|
||||||
case Expr::CXXScalarValueInitExprClass:
|
case Expr::CXXScalarValueInitExprClass:
|
||||||
case Expr::UnaryTypeTraitExprClass:
|
|
||||||
case Expr::TypeTraitExprClass:
|
case Expr::TypeTraitExprClass:
|
||||||
case Expr::ArrayTypeTraitExprClass:
|
case Expr::ArrayTypeTraitExprClass:
|
||||||
case Expr::ExpressionTraitExprClass:
|
case Expr::ExpressionTraitExprClass:
|
||||||
|
|
|
@ -2582,7 +2582,6 @@ recurse:
|
||||||
case Expr::ShuffleVectorExprClass:
|
case Expr::ShuffleVectorExprClass:
|
||||||
case Expr::ConvertVectorExprClass:
|
case Expr::ConvertVectorExprClass:
|
||||||
case Expr::StmtExprClass:
|
case Expr::StmtExprClass:
|
||||||
case Expr::UnaryTypeTraitExprClass:
|
|
||||||
case Expr::TypeTraitExprClass:
|
case Expr::TypeTraitExprClass:
|
||||||
case Expr::ArrayTypeTraitExprClass:
|
case Expr::ArrayTypeTraitExprClass:
|
||||||
case Expr::ExpressionTraitExprClass:
|
case Expr::ExpressionTraitExprClass:
|
||||||
|
|
|
@ -1682,17 +1682,10 @@ void StmtPrinter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *Node) {
|
||||||
OS, Node->getTemplateArgs(), Node->getNumTemplateArgs(), Policy);
|
OS, Node->getTemplateArgs(), Node->getNumTemplateArgs(), Policy);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *getTypeTraitName(UnaryTypeTrait UTT) {
|
|
||||||
switch (UTT) {
|
|
||||||
#define TYPE_TRAIT_1(Spelling, Name, Key) \
|
|
||||||
case clang::UTT_##Name: return #Spelling;
|
|
||||||
#include "clang/Basic/TokenKinds.def"
|
|
||||||
}
|
|
||||||
llvm_unreachable("Type trait not covered by switch statement");
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *getTypeTraitName(TypeTrait TT) {
|
static const char *getTypeTraitName(TypeTrait TT) {
|
||||||
switch (TT) {
|
switch (TT) {
|
||||||
|
#define TYPE_TRAIT_1(Spelling, Name, Key) \
|
||||||
|
case clang::UTT_##Name: return #Spelling;
|
||||||
#define TYPE_TRAIT_2(Spelling, Name, Key) \
|
#define TYPE_TRAIT_2(Spelling, Name, Key) \
|
||||||
case clang::BTT_##Name: return #Spelling;
|
case clang::BTT_##Name: return #Spelling;
|
||||||
#define TYPE_TRAIT_N(Spelling, Name, Key) \
|
#define TYPE_TRAIT_N(Spelling, Name, Key) \
|
||||||
|
@ -1718,12 +1711,6 @@ static const char *getExpressionTraitName(ExpressionTrait ET) {
|
||||||
llvm_unreachable("Expression type trait not covered by switch");
|
llvm_unreachable("Expression type trait not covered by switch");
|
||||||
}
|
}
|
||||||
|
|
||||||
void StmtPrinter::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
|
|
||||||
OS << getTypeTraitName(E->getTrait()) << '(';
|
|
||||||
E->getQueriedType().print(OS, Policy);
|
|
||||||
OS << ')';
|
|
||||||
}
|
|
||||||
|
|
||||||
void StmtPrinter::VisitTypeTraitExpr(TypeTraitExpr *E) {
|
void StmtPrinter::VisitTypeTraitExpr(TypeTraitExpr *E) {
|
||||||
OS << getTypeTraitName(E->getTrait()) << "(";
|
OS << getTypeTraitName(E->getTrait()) << "(";
|
||||||
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
|
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
|
||||||
|
|
|
@ -948,12 +948,6 @@ StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) {
|
||||||
VisitOverloadExpr(S);
|
VisitOverloadExpr(S);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StmtProfiler::VisitUnaryTypeTraitExpr(const UnaryTypeTraitExpr *S) {
|
|
||||||
VisitExpr(S);
|
|
||||||
ID.AddInteger(S->getTrait());
|
|
||||||
VisitType(S->getQueriedType());
|
|
||||||
}
|
|
||||||
|
|
||||||
void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) {
|
void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) {
|
||||||
VisitExpr(S);
|
VisitExpr(S);
|
||||||
ID.AddInteger(S->getTrait());
|
ID.AddInteger(S->getTrait());
|
||||||
|
|
|
@ -367,9 +367,6 @@ public:
|
||||||
CGF.EmitCXXDeleteExpr(E);
|
CGF.EmitCXXDeleteExpr(E);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Value *VisitUnaryTypeTraitExpr(const UnaryTypeTraitExpr *E) {
|
|
||||||
return Builder.getInt1(E->getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
Value *VisitTypeTraitExpr(const TypeTraitExpr *E) {
|
Value *VisitTypeTraitExpr(const TypeTraitExpr *E) {
|
||||||
return llvm::ConstantInt::get(ConvertType(E->getType()), E->getValue());
|
return llvm::ConstantInt::get(ConvertType(E->getType()), E->getValue());
|
||||||
|
|
|
@ -2684,18 +2684,11 @@ Parser::ParseCXXDeleteExpression(bool UseGlobal, SourceLocation Start) {
|
||||||
return Actions.ActOnCXXDelete(Start, UseGlobal, ArrayDelete, Operand.take());
|
return Actions.ActOnCXXDelete(Start, UseGlobal, ArrayDelete, Operand.take());
|
||||||
}
|
}
|
||||||
|
|
||||||
static UnaryTypeTrait UnaryTypeTraitFromTokKind(tok::TokenKind kind) {
|
|
||||||
switch(kind) {
|
|
||||||
default: llvm_unreachable("Not a known unary type trait.");
|
|
||||||
#define TYPE_TRAIT_1(Spelling, Name, Key) \
|
|
||||||
case tok::kw_ ## Spelling: return UTT_ ## Name;
|
|
||||||
#include "clang/Basic/TokenKinds.def"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static TypeTrait TypeTraitFromTokKind(tok::TokenKind kind) {
|
static TypeTrait TypeTraitFromTokKind(tok::TokenKind kind) {
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
default: llvm_unreachable("Not a known type trait");
|
default: llvm_unreachable("Not a known type trait");
|
||||||
|
#define TYPE_TRAIT_1(Spelling, Name, Key) \
|
||||||
|
case tok::kw_ ## Spelling: return UTT_ ## Name;
|
||||||
#define TYPE_TRAIT_2(Spelling, Name, Key) \
|
#define TYPE_TRAIT_2(Spelling, Name, Key) \
|
||||||
case tok::kw_ ## Spelling: return BTT_ ## Name;
|
case tok::kw_ ## Spelling: return BTT_ ## Name;
|
||||||
#include "clang/Basic/TokenKinds.def"
|
#include "clang/Basic/TokenKinds.def"
|
||||||
|
@ -2789,10 +2782,6 @@ ExprResult Parser::ParseTypeTrait() {
|
||||||
return ExprError();
|
return ExprError();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Arity == 1)
|
|
||||||
return Actions.ActOnUnaryTypeTrait(UnaryTypeTraitFromTokKind(Kind), Loc,
|
|
||||||
Args[0], EndLoc);
|
|
||||||
|
|
||||||
return Actions.ActOnTypeTrait(TypeTraitFromTokKind(Kind), Loc, Args, EndLoc);
|
return Actions.ActOnTypeTrait(TypeTraitFromTokKind(Kind), Loc, Args, EndLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1085,7 +1085,6 @@ CanThrowResult Sema::canThrow(const Expr *E) {
|
||||||
case Expr::PredefinedExprClass:
|
case Expr::PredefinedExprClass:
|
||||||
case Expr::SizeOfPackExprClass:
|
case Expr::SizeOfPackExprClass:
|
||||||
case Expr::StringLiteralClass:
|
case Expr::StringLiteralClass:
|
||||||
case Expr::UnaryTypeTraitExprClass:
|
|
||||||
// These expressions can never throw.
|
// These expressions can never throw.
|
||||||
return CT_Cannot;
|
return CT_Cannot;
|
||||||
|
|
||||||
|
|
|
@ -3290,7 +3290,7 @@ static void warnOnSizeofOnArrayDecay(Sema &S, SourceLocation Loc, QualType T,
|
||||||
<< ICE->getSubExpr()->getType();
|
<< ICE->getSubExpr()->getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Check the constrains on expression operands to unary type expression
|
/// \brief Check the constraints on expression operands to unary type expression
|
||||||
/// and type traits.
|
/// and type traits.
|
||||||
///
|
///
|
||||||
/// Completes any types necessary and validates the constraints on the operand
|
/// Completes any types necessary and validates the constraints on the operand
|
||||||
|
|
|
@ -3082,26 +3082,13 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
|
||||||
return Owned(From);
|
return Owned(From);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprResult Sema::ActOnUnaryTypeTrait(UnaryTypeTrait UTT,
|
|
||||||
SourceLocation KWLoc,
|
|
||||||
ParsedType Ty,
|
|
||||||
SourceLocation RParen) {
|
|
||||||
TypeSourceInfo *TSInfo;
|
|
||||||
QualType T = GetTypeFromParser(Ty, &TSInfo);
|
|
||||||
|
|
||||||
if (!TSInfo)
|
|
||||||
TSInfo = Context.getTrivialTypeSourceInfo(T);
|
|
||||||
return BuildUnaryTypeTrait(UTT, KWLoc, TSInfo, RParen);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// \brief Check the completeness of a type in a unary type trait.
|
/// \brief Check the completeness of a type in a unary type trait.
|
||||||
///
|
///
|
||||||
/// If the particular type trait requires a complete type, tries to complete
|
/// If the particular type trait requires a complete type, tries to complete
|
||||||
/// it. If completing the type fails, a diagnostic is emitted and false
|
/// it. If completing the type fails, a diagnostic is emitted and false
|
||||||
/// returned. If completing the type succeeds or no completion was required,
|
/// returned. If completing the type succeeds or no completion was required,
|
||||||
/// returns true.
|
/// returns true.
|
||||||
static bool CheckUnaryTypeTraitTypeCompleteness(Sema &S,
|
static bool CheckUnaryTypeTraitTypeCompleteness(Sema &S, TypeTrait UTT,
|
||||||
UnaryTypeTrait UTT,
|
|
||||||
SourceLocation Loc,
|
SourceLocation Loc,
|
||||||
QualType ArgTy) {
|
QualType ArgTy) {
|
||||||
// C++0x [meta.unary.prop]p3:
|
// C++0x [meta.unary.prop]p3:
|
||||||
|
@ -3114,6 +3101,7 @@ static bool CheckUnaryTypeTraitTypeCompleteness(Sema &S,
|
||||||
// these class templates. We also try to follow any GCC documented behavior
|
// these class templates. We also try to follow any GCC documented behavior
|
||||||
// in these expressions to ensure portability of standard libraries.
|
// in these expressions to ensure portability of standard libraries.
|
||||||
switch (UTT) {
|
switch (UTT) {
|
||||||
|
default: llvm_unreachable("not a UTT");
|
||||||
// is_complete_type somewhat obviously cannot require a complete type.
|
// is_complete_type somewhat obviously cannot require a complete type.
|
||||||
case UTT_IsCompleteType:
|
case UTT_IsCompleteType:
|
||||||
// Fall-through
|
// Fall-through
|
||||||
|
@ -3200,7 +3188,6 @@ static bool CheckUnaryTypeTraitTypeCompleteness(Sema &S,
|
||||||
return !S.RequireCompleteType(
|
return !S.RequireCompleteType(
|
||||||
Loc, ElTy, diag::err_incomplete_type_used_in_type_trait_expr);
|
Loc, ElTy, diag::err_incomplete_type_used_in_type_trait_expr);
|
||||||
}
|
}
|
||||||
llvm_unreachable("Type trait not handled by switch");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool HasNoThrowOperator(const RecordType *RT, OverloadedOperatorKind Op,
|
static bool HasNoThrowOperator(const RecordType *RT, OverloadedOperatorKind Op,
|
||||||
|
@ -3239,12 +3226,13 @@ static bool HasNoThrowOperator(const RecordType *RT, OverloadedOperatorKind Op,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool EvaluateUnaryTypeTrait(Sema &Self, UnaryTypeTrait UTT,
|
static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT,
|
||||||
SourceLocation KeyLoc, QualType T) {
|
SourceLocation KeyLoc, QualType T) {
|
||||||
assert(!T->isDependentType() && "Cannot evaluate traits of dependent type");
|
assert(!T->isDependentType() && "Cannot evaluate traits of dependent type");
|
||||||
|
|
||||||
ASTContext &C = Self.Context;
|
ASTContext &C = Self.Context;
|
||||||
switch(UTT) {
|
switch(UTT) {
|
||||||
|
default: llvm_unreachable("not a UTT");
|
||||||
// Type trait expressions corresponding to the primary type category
|
// Type trait expressions corresponding to the primary type category
|
||||||
// predicates in C++0x [meta.unary.cat].
|
// predicates in C++0x [meta.unary.cat].
|
||||||
case UTT_IsVoid:
|
case UTT_IsVoid:
|
||||||
|
@ -3576,23 +3564,6 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, UnaryTypeTrait UTT,
|
||||||
// function call.
|
// function call.
|
||||||
return !T->isIncompleteType();
|
return !T->isIncompleteType();
|
||||||
}
|
}
|
||||||
llvm_unreachable("Type trait not covered by switch");
|
|
||||||
}
|
|
||||||
|
|
||||||
ExprResult Sema::BuildUnaryTypeTrait(UnaryTypeTrait UTT,
|
|
||||||
SourceLocation KWLoc,
|
|
||||||
TypeSourceInfo *TSInfo,
|
|
||||||
SourceLocation RParen) {
|
|
||||||
QualType T = TSInfo->getType();
|
|
||||||
if (!CheckUnaryTypeTraitTypeCompleteness(*this, UTT, KWLoc, T))
|
|
||||||
return ExprError();
|
|
||||||
|
|
||||||
bool Value = false;
|
|
||||||
if (!T->isDependentType())
|
|
||||||
Value = EvaluateUnaryTypeTrait(*this, UTT, KWLoc, T);
|
|
||||||
|
|
||||||
return Owned(new (Context) UnaryTypeTraitExpr(KWLoc, UTT, TSInfo, Value,
|
|
||||||
RParen, Context.BoolTy));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Determine whether T has a non-trivial Objective-C lifetime in
|
/// \brief Determine whether T has a non-trivial Objective-C lifetime in
|
||||||
|
@ -3620,6 +3591,9 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, QualType LhsT,
|
||||||
static bool evaluateTypeTrait(Sema &S, TypeTrait Kind, SourceLocation KWLoc,
|
static bool evaluateTypeTrait(Sema &S, TypeTrait Kind, SourceLocation KWLoc,
|
||||||
ArrayRef<TypeSourceInfo *> Args,
|
ArrayRef<TypeSourceInfo *> Args,
|
||||||
SourceLocation RParenLoc) {
|
SourceLocation RParenLoc) {
|
||||||
|
if (Kind <= UTT_Last)
|
||||||
|
return EvaluateUnaryTypeTrait(S, Kind, KWLoc, Args[0]->getType());
|
||||||
|
|
||||||
if (Kind <= BTT_Last)
|
if (Kind <= BTT_Last)
|
||||||
return EvaluateBinaryTypeTrait(S, Kind, Args[0]->getType(),
|
return EvaluateBinaryTypeTrait(S, Kind, Args[0]->getType(),
|
||||||
Args[1]->getType(), RParenLoc);
|
Args[1]->getType(), RParenLoc);
|
||||||
|
@ -3709,6 +3683,10 @@ ExprResult Sema::BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
|
||||||
SourceLocation RParenLoc) {
|
SourceLocation RParenLoc) {
|
||||||
QualType ResultType = Context.getLogicalOperationType();
|
QualType ResultType = Context.getLogicalOperationType();
|
||||||
|
|
||||||
|
if (Kind <= UTT_Last && !CheckUnaryTypeTraitTypeCompleteness(
|
||||||
|
*this, Kind, KWLoc, Args[0]->getType()))
|
||||||
|
return ExprError();
|
||||||
|
|
||||||
bool Dependent = false;
|
bool Dependent = false;
|
||||||
for (unsigned I = 0, N = Args.size(); I != N; ++I) {
|
for (unsigned I = 0, N = Args.size(); I != N; ++I) {
|
||||||
if (Args[I]->getType()->isDependentType()) {
|
if (Args[I]->getType()->isDependentType()) {
|
||||||
|
|
|
@ -2135,17 +2135,6 @@ public:
|
||||||
Operand);
|
Operand);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Build a new unary type trait expression.
|
|
||||||
///
|
|
||||||
/// By default, performs semantic analysis to build the new expression.
|
|
||||||
/// Subclasses may override this routine to provide different behavior.
|
|
||||||
ExprResult RebuildUnaryTypeTrait(UnaryTypeTrait Trait,
|
|
||||||
SourceLocation StartLoc,
|
|
||||||
TypeSourceInfo *T,
|
|
||||||
SourceLocation RParenLoc) {
|
|
||||||
return getSema().BuildUnaryTypeTrait(Trait, StartLoc, T, RParenLoc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// \brief Build a new type trait expression.
|
/// \brief Build a new type trait expression.
|
||||||
///
|
///
|
||||||
/// By default, performs semantic analysis to build the new expression.
|
/// By default, performs semantic analysis to build the new expression.
|
||||||
|
@ -7864,23 +7853,6 @@ TreeTransform<Derived>::TransformUnresolvedLookupExpr(
|
||||||
Old->requiresADL(), &TransArgs);
|
Old->requiresADL(), &TransArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Derived>
|
|
||||||
ExprResult
|
|
||||||
TreeTransform<Derived>::TransformUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
|
|
||||||
TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo());
|
|
||||||
if (!T)
|
|
||||||
return ExprError();
|
|
||||||
|
|
||||||
if (!getDerived().AlwaysRebuild() &&
|
|
||||||
T == E->getQueriedTypeSourceInfo())
|
|
||||||
return SemaRef.Owned(E);
|
|
||||||
|
|
||||||
return getDerived().RebuildUnaryTypeTrait(E->getTrait(),
|
|
||||||
E->getLocStart(),
|
|
||||||
T,
|
|
||||||
E->getLocEnd());
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
ExprResult
|
ExprResult
|
||||||
TreeTransform<Derived>::TransformTypeTraitExpr(TypeTraitExpr *E) {
|
TreeTransform<Derived>::TransformTypeTraitExpr(TypeTraitExpr *E) {
|
||||||
|
|
|
@ -1484,16 +1484,6 @@ void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
|
||||||
E->NamingClass = ReadDeclAs<CXXRecordDecl>(Record, Idx);
|
E->NamingClass = ReadDeclAs<CXXRecordDecl>(Record, Idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
|
|
||||||
VisitExpr(E);
|
|
||||||
E->UTT = (UnaryTypeTrait)Record[Idx++];
|
|
||||||
E->Value = (bool)Record[Idx++];
|
|
||||||
SourceRange Range = ReadSourceRange(Record, Idx);
|
|
||||||
E->Loc = Range.getBegin();
|
|
||||||
E->RParen = Range.getEnd();
|
|
||||||
E->QueriedType = GetTypeSourceInfo(Record, Idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
|
void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
|
||||||
VisitExpr(E);
|
VisitExpr(E);
|
||||||
E->TypeTraitExprBits.NumArgs = Record[Idx++];
|
E->TypeTraitExprBits.NumArgs = Record[Idx++];
|
||||||
|
@ -2385,10 +2375,6 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
|
||||||
? Record[ASTStmtReader::NumExprFields + 1]
|
? Record[ASTStmtReader::NumExprFields + 1]
|
||||||
: 0);
|
: 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EXPR_CXX_UNARY_TYPE_TRAIT:
|
|
||||||
S = new (Context) UnaryTypeTraitExpr(Empty);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EXPR_TYPE_TRAIT:
|
case EXPR_TYPE_TRAIT:
|
||||||
S = TypeTraitExpr::CreateDeserialized(Context,
|
S = TypeTraitExpr::CreateDeserialized(Context,
|
||||||
|
|
|
@ -773,7 +773,6 @@ static void AddStmtsExprs(llvm::BitstreamWriter &Stream,
|
||||||
RECORD(EXPR_CXX_UNRESOLVED_CONSTRUCT);
|
RECORD(EXPR_CXX_UNRESOLVED_CONSTRUCT);
|
||||||
RECORD(EXPR_CXX_UNRESOLVED_MEMBER);
|
RECORD(EXPR_CXX_UNRESOLVED_MEMBER);
|
||||||
RECORD(EXPR_CXX_UNRESOLVED_LOOKUP);
|
RECORD(EXPR_CXX_UNRESOLVED_LOOKUP);
|
||||||
RECORD(EXPR_CXX_UNARY_TYPE_TRAIT);
|
|
||||||
RECORD(EXPR_CXX_NOEXCEPT);
|
RECORD(EXPR_CXX_NOEXCEPT);
|
||||||
RECORD(EXPR_OPAQUE_VALUE);
|
RECORD(EXPR_OPAQUE_VALUE);
|
||||||
RECORD(EXPR_PACK_EXPANSION);
|
RECORD(EXPR_PACK_EXPANSION);
|
||||||
|
|
|
@ -1486,15 +1486,6 @@ void ASTStmtWriter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
|
||||||
Code = serialization::EXPR_CXX_UNRESOLVED_LOOKUP;
|
Code = serialization::EXPR_CXX_UNRESOLVED_LOOKUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASTStmtWriter::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
|
|
||||||
VisitExpr(E);
|
|
||||||
Record.push_back(E->getTrait());
|
|
||||||
Record.push_back(E->getValue());
|
|
||||||
Writer.AddSourceRange(E->getSourceRange(), Record);
|
|
||||||
Writer.AddTypeSourceInfo(E->getQueriedTypeSourceInfo(), Record);
|
|
||||||
Code = serialization::EXPR_CXX_UNARY_TYPE_TRAIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASTStmtWriter::VisitTypeTraitExpr(TypeTraitExpr *E) {
|
void ASTStmtWriter::VisitTypeTraitExpr(TypeTraitExpr *E) {
|
||||||
VisitExpr(E);
|
VisitExpr(E);
|
||||||
Record.push_back(E->TypeTraitExprBits.NumArgs);
|
Record.push_back(E->TypeTraitExprBits.NumArgs);
|
||||||
|
|
|
@ -663,7 +663,6 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
|
||||||
case Stmt::MSPropertyRefExprClass:
|
case Stmt::MSPropertyRefExprClass:
|
||||||
case Stmt::CXXUnresolvedConstructExprClass:
|
case Stmt::CXXUnresolvedConstructExprClass:
|
||||||
case Stmt::DependentScopeDeclRefExprClass:
|
case Stmt::DependentScopeDeclRefExprClass:
|
||||||
case Stmt::UnaryTypeTraitExprClass:
|
|
||||||
case Stmt::TypeTraitExprClass:
|
case Stmt::TypeTraitExprClass:
|
||||||
case Stmt::ArrayTypeTraitExprClass:
|
case Stmt::ArrayTypeTraitExprClass:
|
||||||
case Stmt::ExpressionTraitExprClass:
|
case Stmt::ExpressionTraitExprClass:
|
||||||
|
|
|
@ -310,7 +310,7 @@ void test_unexpanded_exprs(Types ...values) {
|
||||||
t.~Types(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
|
t.~Types(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
|
||||||
t.Types::~T(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
|
t.Types::~T(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
|
||||||
|
|
||||||
// UnaryTypeTraitExpr
|
// Unary TypeTraitExpr
|
||||||
__is_pod(Types); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
|
__is_pod(Types); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
|
||||||
|
|
||||||
// Binary TypeTraitExpr
|
// Binary TypeTraitExpr
|
||||||
|
|
|
@ -1839,7 +1839,6 @@ public:
|
||||||
void VisitStmt(const Stmt *S);
|
void VisitStmt(const Stmt *S);
|
||||||
void VisitSwitchStmt(const SwitchStmt *S);
|
void VisitSwitchStmt(const SwitchStmt *S);
|
||||||
void VisitWhileStmt(const WhileStmt *W);
|
void VisitWhileStmt(const WhileStmt *W);
|
||||||
void VisitUnaryTypeTraitExpr(const UnaryTypeTraitExpr *E);
|
|
||||||
void VisitTypeTraitExpr(const TypeTraitExpr *E);
|
void VisitTypeTraitExpr(const TypeTraitExpr *E);
|
||||||
void VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *E);
|
void VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *E);
|
||||||
void VisitExpressionTraitExpr(const ExpressionTraitExpr *E);
|
void VisitExpressionTraitExpr(const ExpressionTraitExpr *E);
|
||||||
|
@ -2184,10 +2183,6 @@ void EnqueueVisitor::VisitWhileStmt(const WhileStmt *W) {
|
||||||
AddDecl(W->getConditionVariable());
|
AddDecl(W->getConditionVariable());
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnqueueVisitor::VisitUnaryTypeTraitExpr(const UnaryTypeTraitExpr *E) {
|
|
||||||
AddTypeLoc(E->getQueriedTypeSourceInfo());
|
|
||||||
}
|
|
||||||
|
|
||||||
void EnqueueVisitor::VisitTypeTraitExpr(const TypeTraitExpr *E) {
|
void EnqueueVisitor::VisitTypeTraitExpr(const TypeTraitExpr *E) {
|
||||||
for (unsigned I = E->getNumArgs(); I > 0; --I)
|
for (unsigned I = E->getNumArgs(); I > 0; --I)
|
||||||
AddTypeLoc(E->getArg(I-1));
|
AddTypeLoc(E->getArg(I-1));
|
||||||
|
|
|
@ -235,7 +235,6 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
|
||||||
case Stmt::ShuffleVectorExprClass:
|
case Stmt::ShuffleVectorExprClass:
|
||||||
case Stmt::ConvertVectorExprClass:
|
case Stmt::ConvertVectorExprClass:
|
||||||
case Stmt::UnaryExprOrTypeTraitExprClass:
|
case Stmt::UnaryExprOrTypeTraitExprClass:
|
||||||
case Stmt::UnaryTypeTraitExprClass:
|
|
||||||
case Stmt::VAArgExprClass:
|
case Stmt::VAArgExprClass:
|
||||||
case Stmt::ObjCArrayLiteralClass:
|
case Stmt::ObjCArrayLiteralClass:
|
||||||
case Stmt::ObjCDictionaryLiteralClass:
|
case Stmt::ObjCDictionaryLiteralClass:
|
||||||
|
|
Loading…
Reference in New Issue