add support for vector type compatibility checking. Patch by Nate Begeman.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43604 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp
index b83d33d..266871b 100644
--- a/AST/ASTContext.cpp
+++ b/AST/ASTContext.cpp
@@ -784,7 +784,7 @@
return getFloatingRank(CT->getElementType());
switch (cast<BuiltinType>(T)->getKind()) {
- default: assert(0 && "getFloatingPointRank(): not a floating type");
+ default: assert(0 && "getFloatingRank(): not a floating type");
case BuiltinType::Float: return FloatRank;
case BuiltinType::Double: return DoubleRank;
case BuiltinType::LongDouble: return LongDoubleRank;
@@ -1141,6 +1141,17 @@
return true; // FIXME: IMPLEMENT.
}
+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;
+}
+
// 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) {
@@ -1279,6 +1290,9 @@
return builtinTypesAreCompatible(lcanon, rcanon);
case Type::ObjcInterface:
return interfaceTypesAreCompatible(lcanon, rcanon);
+ case Type::Vector:
+ case Type::OCUVector:
+ return vectorTypesAreCompatible(lcanon, rcanon);
default:
assert(0 && "unexpected type");
}