[cfe-commits] r49314 - in /cfe/trunk: include/clang/AST/ASTContext.h lib/AST/ASTContext.cpp

Chris Lattner sabre at nondot.org
Sun Apr 6 22:36:14 PDT 2008


Author: lattner
Date: Mon Apr  7 00:36:14 2008
New Revision: 49314

URL: http://llvm.org/viewvc/llvm-project?rev=49314&view=rev
Log:
simplify vector type compatibility testing.

Modified:
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=49314&r1=49313&r2=49314&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Apr  7 00:36:14 2008
@@ -333,7 +333,6 @@
   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 {

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=49314&r1=49313&r2=49314&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Apr  7 00:36:14 2008
@@ -1507,16 +1507,13 @@
   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 @@
                                    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));





More information about the cfe-commits mailing list