From 28eeb384d6910b897f3cef846f2232b9235fca59 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sun, 1 May 2011 06:11:03 +0000 Subject: [PATCH] Begin cleaning up type trait expression implementations and settling on a single pattern for implementing each. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130638 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExprCXX.cpp | 42 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 85a65a43a3..ef6e2c35d3 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -2364,33 +2364,33 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, UnaryTypeTrait UTT, QualType T, ASTContext &C = Self.Context; switch(UTT) { default: assert(false && "Unknown type trait or not implemented"); - case UTT_IsPOD: return T->isPODType(); - case UTT_IsLiteral: return T->isLiteralType(); - case UTT_IsTrivial: return T->isTrivialType(); - case UTT_IsClass: // Fallthrough + case UTT_IsPOD: + return T->isPODType(); + case UTT_IsLiteral: + return T->isLiteralType(); + case UTT_IsTrivial: + return T->isTrivialType(); + case UTT_IsClass: + if (const RecordType *Record = T->getAs()) + return !Record->getDecl()->isUnion(); + return false; case UTT_IsUnion: - if (const RecordType *Record = T->getAs()) { - bool Union = Record->getDecl()->isUnion(); - return UTT == UTT_IsUnion ? Union : !Union; - } + if (const RecordType *Record = T->getAs()) + return Record->getDecl()->isUnion(); return false; - case UTT_IsEnum: return T->isEnumeralType(); + case UTT_IsEnum: + return T->isEnumeralType(); case UTT_IsPolymorphic: - if (const RecordType *Record = T->getAs()) { - // Type traits are only parsed in C++, so we've got CXXRecords. - return cast(Record->getDecl())->isPolymorphic(); - } + if (const CXXRecordDecl *RD = T->getAsCXXRecordDecl()) + return RD->isPolymorphic(); return false; case UTT_IsAbstract: - if (const RecordType *RT = T->getAs()) - if (!Self.RequireCompleteType(KeyLoc, T, diag::err_incomplete_typeid)) - return cast(RT->getDecl())->isAbstract(); + if (const CXXRecordDecl *RD = T->getAsCXXRecordDecl()) + return RD->isAbstract(); return false; case UTT_IsEmpty: - if (const RecordType *Record = T->getAs()) { - return !Record->getDecl()->isUnion() - && cast(Record->getDecl())->isEmpty(); - } + if (const CXXRecordDecl *RD = T->getAsCXXRecordDecl()) + return !RD->isUnion() && RD->isEmpty(); return false; case UTT_IsIntegral: return T->isIntegralType(C); @@ -2401,7 +2401,7 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, UnaryTypeTrait UTT, QualType T, case UTT_IsArray: return T->isArrayType(); case UTT_IsCompleteType: - return ! T->isIncompleteType(); + return !T->isIncompleteType(); case UTT_IsCompound: return ! (T->isVoidType() || T->isArithmeticType()) || T->isEnumeralType(); case UTT_IsConst: -- 2.40.0