[cfe-commits] r130638 - /cfe/trunk/lib/Sema/SemaExprCXX.cpp
Chandler Carruth
chandlerc at gmail.com
Sat Apr 30 23:11:03 PDT 2011
Author: chandlerc
Date: Sun May 1 01:11:03 2011
New Revision: 130638
URL: http://llvm.org/viewvc/llvm-project?rev=130638&view=rev
Log:
Begin cleaning up type trait expression implementations and settling on
a single pattern for implementing each.
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=130638&r1=130637&r2=130638&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Sun May 1 01:11:03 2011
@@ -2364,33 +2364,33 @@
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<RecordType>())
+ return !Record->getDecl()->isUnion();
+ return false;
case UTT_IsUnion:
- if (const RecordType *Record = T->getAs<RecordType>()) {
- bool Union = Record->getDecl()->isUnion();
- return UTT == UTT_IsUnion ? Union : !Union;
- }
+ if (const RecordType *Record = T->getAs<RecordType>())
+ 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<RecordType>()) {
- // Type traits are only parsed in C++, so we've got CXXRecords.
- return cast<CXXRecordDecl>(Record->getDecl())->isPolymorphic();
- }
+ if (const CXXRecordDecl *RD = T->getAsCXXRecordDecl())
+ return RD->isPolymorphic();
return false;
case UTT_IsAbstract:
- if (const RecordType *RT = T->getAs<RecordType>())
- if (!Self.RequireCompleteType(KeyLoc, T, diag::err_incomplete_typeid))
- return cast<CXXRecordDecl>(RT->getDecl())->isAbstract();
+ if (const CXXRecordDecl *RD = T->getAsCXXRecordDecl())
+ return RD->isAbstract();
return false;
case UTT_IsEmpty:
- if (const RecordType *Record = T->getAs<RecordType>()) {
- return !Record->getDecl()->isUnion()
- && cast<CXXRecordDecl>(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 @@
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:
More information about the cfe-commits
mailing list