From: Ted Kremenek Date: Thu, 14 Jul 2011 15:43:21 +0000 (+0000) Subject: Add extra sanity checking in FormatString::matchesType() that we are comparing intege... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9dbe16eb808ed3b58be6be48bf4ae7317db63e89;p=clang 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 --- 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()) + if (const BuiltinType *BT = argTy->getAs()) { + 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; }