]> granicus.if.org Git - clang/commitdiff
simplify vector type compatibility testing.
authorChris Lattner <sabre@nondot.org>
Mon, 7 Apr 2008 05:36:14 +0000 (05:36 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 7 Apr 2008 05:36:14 +0000 (05:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49314 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/ASTContext.h
lib/AST/ASTContext.cpp

index bec9efa2b13b80d90aca208e2baf52f8e866b6f3..9f1caf482974deb7f876110a12564315cc6ce968 100644 (file)
@@ -333,7 +333,6 @@ public:
   bool functionTypesAreCompatible(QualType, QualType); // C99 6.7.5.3p15
   bool arrayTypesAreCompatible(QualType, QualType); // C99 6.7.5.2p6
   bool builtinTypesAreCompatible(QualType, QualType);
-  bool vectorTypesAreCompatible(QualType, QualType);
   
   bool objcTypesAreCompatible(QualType, QualType);
   bool isObjCIdType(QualType T) const {
index 439a99c4b266388c87d8a60d685341e6b65fd183..31537947a0da164a99b77edea1ff891376dd0f0d 100644 (file)
@@ -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));