]> granicus.if.org Git - clang/commitdiff
Add extra sanity checking in FormatString::matchesType() that we are comparing intege...
authorTed Kremenek <kremenek@apple.com>
Thu, 14 Jul 2011 15:43:21 +0000 (15:43 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 14 Jul 2011 15:43:21 +0000 (15:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135147 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/FormatString.cpp

index 74f1e9279448c3fc591332281dd372c6936890da..144d62b67d11cdef56459af9177b4fba8f439556 100644 (file)
@@ -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;
     }