diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-04-07 06:49:41 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-04-07 06:49:41 +0000 |
| commit | ec646834e7bb008ee3f58d4fe1445ac64f0382c2 (patch) | |
| tree | abbe4197161c58556bde5a37ac5657a92cf35c47 /clang/lib/AST | |
| parent | 3c7961597f8e06637191b7d3ebd9f37791838a8e (diff) | |
| download | bcm5719-llvm-ec646834e7bb008ee3f58d4fe1445ac64f0382c2.tar.gz bcm5719-llvm-ec646834e7bb008ee3f58d4fe1445ac64f0382c2.zip | |
simplify compatibility testing for tag types.
llvm-svn: 49323
Diffstat (limited to 'clang/lib/AST')
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index f6330f67ab5..4d0fa755b39 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1499,17 +1499,20 @@ static bool areCompatVectorTypes(const VectorType *LHS, LHS->getNumElements() == RHS->getNumElements(); } -// C99 6.2.7p1: If both are complete types, then the following additional -// requirements apply...FIXME (handle compatibility across source files). -bool ASTContext::tagTypesAreCompatible(QualType lhs, QualType rhs) { +/// C99 6.2.7p1: If both are complete types, then the following additional +/// requirements apply. +/// FIXME (handle compatibility across source files). +static bool areCompatTagTypes(TagType *LHS, TagType *RHS, + const ASTContext &C) { // "Class" and "id" are compatible built-in structure types. - if (isObjCIdType(lhs) && isObjCClassType(rhs) || - isObjCClassType(lhs) && isObjCIdType(rhs)) + if (C.isObjCIdType(QualType(LHS, 0)) && C.isObjCClassType(QualType(RHS, 0)) || + C.isObjCClassType(QualType(LHS, 0)) && C.isObjCIdType(QualType(RHS, 0))) return true; - // Within a translation unit a tag type is - // only compatible with itself. - return lhs.getCanonicalType() == rhs.getCanonicalType(); + // Within a translation unit a tag type is only compatible with itself. Self + // equality is already handled by the time we get here. + assert(LHS != RHS && "Self equality not handled!"); + return false; } bool ASTContext::pointerTypesAreCompatible(QualType lhs, QualType rhs) { @@ -1695,7 +1698,7 @@ bool ASTContext::typesAreCompatible(QualType LHS_NC, QualType RHS_NC) { case Type::FunctionNoProto: return functionTypesAreCompatible(LHS, RHS); case Type::Tagged: // handle structures, unions - return tagTypesAreCompatible(LHS, RHS); + return areCompatTagTypes(cast<TagType>(LHS), cast<TagType>(RHS), *this); case Type::Builtin: // Only exactly equal builtin types are compatible, which is tested above. return false; |

