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 | f8a6b4d4fcf158743eaea13c981d13d950f03cab (patch) | |
| tree | dbf4c89f3075e03cf810ceaf7210b3202070c286 /clang | |
| parent | 2a3569b5d95e1c34379914818a339db36ce7a4d8 (diff) | |
| download | bcm5719-llvm-f8a6b4d4fcf158743eaea13c981d13d950f03cab.tar.gz bcm5719-llvm-f8a6b4d4fcf158743eaea13c981d13d950f03cab.zip  | |
simplify vector type compatibility testing.
llvm-svn: 49314
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang/AST/ASTContext.h | 1 | ||||
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 19 | 
2 files changed, 8 insertions, 12 deletions
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index bec9efa2b13..9f1caf48297 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -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 { diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 439a99c4b26..31537947a0d 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/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));  | 

