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 | 2df6485d51bf516d3d916ee0c9cadf2e8c4ce22a (patch) | |
tree | 0f8a57dfe5956a18ed0cb597a912f9d9117e1352 /clang/lib/Analysis/FormatString.cpp | |
parent | 34c8b0820124aec7c75c4bfc99616dd7a1101eb0 (diff) | |
download | bcm5719-llvm-2df6485d51bf516d3d916ee0c9cadf2e8c4ce22a.tar.gz bcm5719-llvm-2df6485d51bf516d3d916ee0c9cadf2e8c4ce22a.zip |
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.
llvm-svn: 135147
Diffstat (limited to 'clang/lib/Analysis/FormatString.cpp')
-rw-r--r-- | clang/lib/Analysis/FormatString.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/clang/lib/Analysis/FormatString.cpp b/clang/lib/Analysis/FormatString.cpp index 74f1e927944..144d62b67d1 100644 --- a/clang/lib/Analysis/FormatString.cpp +++ b/clang/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; } |