зеркало из https://github.com/microsoft/clang-1.git
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
This commit is contained in:
Родитель
6c6a2dbb4d
Коммит
770951b5bb
|
@ -784,7 +784,7 @@ static int getFloatingRank(QualType T) {
|
||||||
return getFloatingRank(CT->getElementType());
|
return getFloatingRank(CT->getElementType());
|
||||||
|
|
||||||
switch (cast<BuiltinType>(T)->getKind()) {
|
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::Float: return FloatRank;
|
||||||
case BuiltinType::Double: return DoubleRank;
|
case BuiltinType::Double: return DoubleRank;
|
||||||
case BuiltinType::LongDouble: return LongDoubleRank;
|
case BuiltinType::LongDouble: return LongDoubleRank;
|
||||||
|
@ -1141,6 +1141,17 @@ bool ASTContext::interfaceTypesAreCompatible(QualType lhs, QualType rhs) {
|
||||||
return true; // FIXME: IMPLEMENT.
|
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
|
// C99 6.2.7p1: If both are complete types, then the following additional
|
||||||
// requirements apply...FIXME (handle compatibility across source files).
|
// requirements apply...FIXME (handle compatibility across source files).
|
||||||
bool ASTContext::tagTypesAreCompatible(QualType lhs, QualType rhs) {
|
bool ASTContext::tagTypesAreCompatible(QualType lhs, QualType rhs) {
|
||||||
|
@ -1279,6 +1290,9 @@ bool ASTContext::typesAreCompatible(QualType lhs, QualType rhs) {
|
||||||
return builtinTypesAreCompatible(lcanon, rcanon);
|
return builtinTypesAreCompatible(lcanon, rcanon);
|
||||||
case Type::ObjcInterface:
|
case Type::ObjcInterface:
|
||||||
return interfaceTypesAreCompatible(lcanon, rcanon);
|
return interfaceTypesAreCompatible(lcanon, rcanon);
|
||||||
|
case Type::Vector:
|
||||||
|
case Type::OCUVector:
|
||||||
|
return vectorTypesAreCompatible(lcanon, rcanon);
|
||||||
default:
|
default:
|
||||||
assert(0 && "unexpected type");
|
assert(0 && "unexpected type");
|
||||||
}
|
}
|
||||||
|
|
|
@ -756,6 +756,7 @@
|
||||||
08FB7793FE84155DC02AAC07 /* Project object */ = {
|
08FB7793FE84155DC02AAC07 /* Project object */ = {
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
|
buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
|
||||||
|
compatibilityVersion = "Xcode 2.4";
|
||||||
hasScannedForEncodings = 1;
|
hasScannedForEncodings = 1;
|
||||||
mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
|
mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
|
||||||
projectDirPath = "";
|
projectDirPath = "";
|
||||||
|
|
|
@ -267,6 +267,7 @@ public:
|
||||||
bool functionTypesAreCompatible(QualType, QualType); // C99 6.7.5.3p15
|
bool functionTypesAreCompatible(QualType, QualType); // C99 6.7.5.3p15
|
||||||
bool arrayTypesAreCompatible(QualType, QualType); // C99 6.7.5.2p6
|
bool arrayTypesAreCompatible(QualType, QualType); // C99 6.7.5.2p6
|
||||||
bool builtinTypesAreCompatible(QualType, QualType);
|
bool builtinTypesAreCompatible(QualType, QualType);
|
||||||
|
bool vectorTypesAreCompatible(QualType, QualType);
|
||||||
|
|
||||||
/// Objective-C specific type checking.
|
/// Objective-C specific type checking.
|
||||||
bool interfaceTypesAreCompatible(QualType, QualType);
|
bool interfaceTypesAreCompatible(QualType, QualType);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче