diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-07-14 15:43:21 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-07-14 15:43:21 +0000 |
commit | 9dbe16eb808ed3b58be6be48bf4ae7317db63e89 (patch) | |
tree | 8708b8e8a21067c52537cb027bfe81209ca7cfbd /lib/Analysis/FormatString.cpp | |
parent | ba7537febdf1bc1cc617e1f1746f2644feba6274 (diff) |
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
Diffstat (limited to 'lib/Analysis/FormatString.cpp')
-rw-r--r-- | lib/Analysis/FormatString.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Analysis/FormatString.cpp b/lib/Analysis/FormatString.cpp index 74f1e92794..144d62b67d 100644 --- a/lib/Analysis/FormatString.cpp +++ b/lib/Analysis/FormatString.cpp @@ -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; } |