summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-04-30 10:31:50 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-04-30 10:31:50 +0000
commit7623757cd015dfbbbdefbc7b911b09eccf860a73 (patch)
tree52800d6fe1bc1de30211990f3186d5c6de48802c /clang/lib
parentb077620c025b65d5782c666dabc9f5db286d40ec (diff)
downloadbcm5719-llvm-7623757cd015dfbbbdefbc7b911b09eccf860a73.tar.gz
bcm5719-llvm-7623757cd015dfbbbdefbc7b911b09eccf860a73.zip
Switch the type-trait like APIs on the AST to only check for incomplete
types after looking through arrays. Arrays with an unknown bound seem to be specifically allowed in the library type traits in C++0x, and GCC's builtin __is_trivial returns 'true' for the type 'int[]'. Now Clang agrees with GCC about __is_trivial here. Also hardens these methods against dependent types by just returning false. llvm-svn: 130605
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/Type.cpp33
1 files changed, 28 insertions, 5 deletions
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index d359265090a..ae52ff06faf 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -869,7 +869,7 @@ bool Type::isPODType() const {
}
bool Type::isLiteralType() const {
- if (isIncompleteType())
+ if (isDependentType())
return false;
// C++0x [basic.types]p10:
@@ -878,11 +878,16 @@ bool Type::isLiteralType() const {
// -- an array of literal type
// Extension: variable arrays cannot be literal types, since they're
// runtime-sized.
- if (isArrayType() && !isConstantArrayType())
+ if (isVariableArrayType())
return false;
const Type *BaseTy = getBaseElementTypeUnsafe();
assert(BaseTy && "NULL element type");
+ // Return false for incomplete types after skipping any incomplete array
+ // types; those are expressly allowed by the standard and thus our API.
+ if (BaseTy->isIncompleteType())
+ return false;
+
// C++0x [basic.types]p10:
// A type is a literal type if it is:
// -- a scalar type; or
@@ -916,7 +921,7 @@ bool Type::isLiteralType() const {
}
bool Type::isTrivialType() const {
- if (isIncompleteType())
+ if (isDependentType())
return false;
// C++0x [basic.types]p9:
@@ -925,6 +930,12 @@ bool Type::isTrivialType() const {
// types.
const Type *BaseTy = getBaseElementTypeUnsafe();
assert(BaseTy && "NULL element type");
+
+ // Return false for incomplete types after skipping any incomplete array
+ // types which are expressly allowed by the standard and thus our API.
+ if (BaseTy->isIncompleteType())
+ return false;
+
if (BaseTy->isScalarType()) return true;
if (const RecordType *RT = BaseTy->getAs<RecordType>()) {
if (const CXXRecordDecl *ClassDecl =
@@ -944,7 +955,7 @@ bool Type::isTrivialType() const {
}
bool Type::isStandardLayoutType() const {
- if (isIncompleteType())
+ if (isDependentType())
return false;
// C++0x [basic.types]p9:
@@ -953,6 +964,12 @@ bool Type::isStandardLayoutType() const {
// standard-layout types.
const Type *BaseTy = getBaseElementTypeUnsafe();
assert(BaseTy && "NULL element type");
+
+ // Return false for incomplete types after skipping any incomplete array
+ // types which are expressly allowed by the standard and thus our API.
+ if (BaseTy->isIncompleteType())
+ return false;
+
if (BaseTy->isScalarType()) return true;
if (const RecordType *RT = BaseTy->getAs<RecordType>()) {
if (const CXXRecordDecl *ClassDecl =
@@ -974,7 +991,7 @@ bool Type::isStandardLayoutType() const {
// isStandardLayoutType. We implement it dircetly to avoid redundant
// conversions from a type to a CXXRecordDecl.
bool Type::isCXX11PODType() const {
- if (isIncompleteType())
+ if (isDependentType())
return false;
// C++11 [basic.types]p9:
@@ -982,6 +999,12 @@ bool Type::isCXX11PODType() const {
// versions of these types are collectively called trivial types.
const Type *BaseTy = getBaseElementTypeUnsafe();
assert(BaseTy && "NULL element type");
+
+ // Return false for incomplete types after skipping any incomplete array
+ // types which are expressly allowed by the standard and thus our API.
+ if (BaseTy->isIncompleteType())
+ return false;
+
if (BaseTy->isScalarType()) return true;
if (const RecordType *RT = BaseTy->getAs<RecordType>()) {
if (const CXXRecordDecl *ClassDecl =
OpenPOWER on IntegriCloud