diff options
author | Chris Lattner <sabre@nondot.org> | 2008-04-07 05:36:14 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-04-07 05:36:14 +0000 |
commit | f62f9cd5a78e5445a02e37b277f7a2df9c19b7a3 (patch) | |
tree | 6b0f4bf2334649df3d8df8da3e5645b2046f682a /lib/AST/ASTContext.cpp | |
parent | eca7be6b7ebd93682eeaab2c71d59f2995dacdcc (diff) |
simplify vector type compatibility testing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49314 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r-- | lib/AST/ASTContext.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 439a99c4b2..31537947a0 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -1507,16 +1507,13 @@ areCompatObjCQualInterfaces(const ObjCQualifiedInterfaceType *LHS, return false; } - -bool ASTContext::vectorTypesAreCompatible(QualType lhs, QualType rhs) { - const VectorType *lVector = lhs->getAsVectorType(); - const VectorType *rVector = rhs->getAsVectorType(); - - if ((lVector->getElementType().getCanonicalType() == - rVector->getElementType().getCanonicalType()) && - (lVector->getNumElements() == rVector->getNumElements())) - return true; - return false; +/// areCompatVectorTypes - Return true if the two specified vector types are +/// compatible. +static bool areCompatVectorTypes(const VectorType *LHS, + const VectorType *RHS) { + assert(LHS->isCanonical() && RHS->isCanonical()); + return LHS->getElementType() == RHS->getElementType() && + LHS->getNumElements() == RHS->getNumElements(); } // C99 6.2.7p1: If both are complete types, then the following additional @@ -1704,7 +1701,7 @@ bool ASTContext::typesAreCompatible(QualType LHS_NC, QualType RHS_NC) { cast<ObjCInterfaceType>(RHS)->getDecl()); case Type::Vector: case Type::OCUVector: - return vectorTypesAreCompatible(LHS, RHS); + return areCompatVectorTypes(cast<VectorType>(LHS), cast<VectorType>(RHS)); case Type::ObjCQualifiedInterface: return areCompatObjCQualInterfaces(cast<ObjCQualifiedInterfaceType>(LHS), cast<ObjCQualifiedInterfaceType>(RHS)); |