diff options
author | Chris Lattner <sabre@nondot.org> | 2008-07-25 23:18:17 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-07-25 23:18:17 +0000 |
commit | 834a72ac74cf4ff07ba6215545dba3db578f8a07 (patch) | |
tree | f960808436ff542480fe7577898626489185d0bf /lib/AST/Type.cpp | |
parent | e8e4f928e51091c1f9c7f5b4595941e33dc0bfec (diff) |
Fix rdar://6095136, various crashes with incomplete enum types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54074 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Type.cpp')
-rw-r--r-- | lib/AST/Type.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 0082b2f7b3..275406eaba 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -476,7 +476,8 @@ bool Type::isIntegerType() const { return BT->getKind() >= BuiltinType::Bool && BT->getKind() <= BuiltinType::LongLong; if (const TagType *TT = dyn_cast<TagType>(CanonicalType)) - if (TT->getDecl()->isEnum()) + // Incomplete enum types are not treated as integer types. + if (TT->getDecl()->isEnum() && TT->getDecl()->isDefinition()) return true; if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType)) return VT->getElementType()->isIntegerType(); @@ -490,8 +491,8 @@ bool Type::isIntegralType() const { return BT->getKind() >= BuiltinType::Bool && BT->getKind() <= BuiltinType::LongLong; if (const TagType *TT = dyn_cast<TagType>(CanonicalType)) - if (TT->getDecl()->isEnum()) - return true; + if (TT->getDecl()->isEnum() && TT->getDecl()->isDefinition()) + return true; // Complete enum types are integral. if (const ASQualType *ASQT = dyn_cast<ASQualType>(CanonicalType)) return ASQT->getBaseType()->isIntegralType(); return false; @@ -593,7 +594,7 @@ bool Type::isRealType() const { return BT->getKind() >= BuiltinType::Bool && BT->getKind() <= BuiltinType::LongDouble; if (const TagType *TT = dyn_cast<TagType>(CanonicalType)) - return TT->getDecl()->isEnum(); + return TT->getDecl()->isEnum() && TT->getDecl()->isDefinition(); if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType)) return VT->getElementType()->isRealType(); if (const ASQualType *ASQT = dyn_cast<ASQualType>(CanonicalType)) @@ -617,7 +618,9 @@ bool Type::isScalarType() const { if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType)) return BT->getKind() != BuiltinType::Void; if (const TagType *TT = dyn_cast<TagType>(CanonicalType)) { - if (TT->getDecl()->isEnum()) + // Enums are scalar types, but only if they are defined. Incomplete enums + // are not treated as scalar types. + if (TT->getDecl()->isEnum() && TT->getDecl()->isDefinition()) return true; return false; } |