Add extra sanity checking in FormatString::matchesType() that we are comparing integers to integers. This happens not to be an issue now, but the extra check helps future proof in case of future refactorings.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135147 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2011-07-14 15:43:21 +00:00
Родитель ba7537febd
Коммит 9dbe16eb80
1 изменённых файлов: 6 добавлений и 3 удалений

Просмотреть файл

@ -224,15 +224,17 @@ bool ArgTypeResult::matchesType(ASTContext &C, QualType argTy) const {
if (T == argTy)
return true;
// Check for "compatible types".
if (const BuiltinType *BT = argTy->getAs<BuiltinType>())
if (const BuiltinType *BT = argTy->getAs<BuiltinType>()) {
if (!T->isIntegerType())
return false;
switch (BT->getKind()) {
default:
break;
case BuiltinType::Char_S:
case BuiltinType::SChar:
case BuiltinType::Char_U:
case BuiltinType::UChar:
return hasSameSize(C, T, C.UnsignedCharTy);
case BuiltinType::UChar:
return hasSameSize(C, T, C.UnsignedCharTy);
case BuiltinType::Short:
case BuiltinType::UShort:
return hasSameSize(C, T, C.ShortTy);
@ -246,6 +248,7 @@ bool ArgTypeResult::matchesType(ASTContext &C, QualType argTy) const {
case BuiltinType::ULongLong:
return hasSameSize(C, T, C.LongLongTy);
}
}
return false;
}