[cfe-commits] r135147 - /cfe/trunk/lib/Analysis/FormatString.cpp

Ted Kremenek kremenek at apple.com
Thu Jul 14 08:43:21 PDT 2011


Author: kremenek
Date: Thu Jul 14 10:43:21 2011
New Revision: 135147

URL: http://llvm.org/viewvc/llvm-project?rev=135147&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Analysis/FormatString.cpp

Modified: cfe/trunk/lib/Analysis/FormatString.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/FormatString.cpp?rev=135147&r1=135146&r2=135147&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/FormatString.cpp (original)
+++ cfe/trunk/lib/Analysis/FormatString.cpp Thu Jul 14 10:43:21 2011
@@ -224,15 +224,17 @@
       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 @@
           case BuiltinType::ULongLong:
             return hasSameSize(C, T, C.LongLongTy);
         }
+      }
       return false;
     }
 





More information about the cfe-commits mailing list