[cfe-commits] r135048 - in /cfe/trunk: lib/Analysis/FormatString.cpp test/Sema/format-strings.c

Ted Kremenek kremenek at apple.com
Wed Jul 13 10:35:15 PDT 2011


Author: kremenek
Date: Wed Jul 13 12:35:14 2011
New Revision: 135048

URL: http://llvm.org/viewvc/llvm-project?rev=135048&view=rev
Log:
Re-relax conversion specifier checking for printf format strings and conversion specifiers.  My recent change was a mistake.

Modified:
    cfe/trunk/lib/Analysis/FormatString.cpp
    cfe/trunk/test/Sema/format-strings.c

Modified: cfe/trunk/lib/Analysis/FormatString.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/FormatString.cpp?rev=135048&r1=135047&r2=135048&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/FormatString.cpp (original)
+++ cfe/trunk/lib/Analysis/FormatString.cpp Wed Jul 13 12:35:14 2011
@@ -219,16 +219,17 @@
       argTy = C.getCanonicalType(argTy).getUnqualifiedType();
       if (T == argTy)
         return true;
+      // Check for "compatible types".
       if (const BuiltinType *BT = argTy->getAs<BuiltinType>())
         switch (BT->getKind()) {
           default:
             break;
           case BuiltinType::Char_S:
           case BuiltinType::SChar:
-            return T == C.SignedCharTy;
-          case BuiltinType::Char_U:
-          case BuiltinType::UChar:
             return T == C.UnsignedCharTy;
+          case BuiltinType::Char_U:
+          case BuiltinType::UChar:                    
+            return T == C.SignedCharTy;
           case BuiltinType::Short:
             return T == C.UnsignedShortTy;
           case BuiltinType::UShort:

Modified: cfe/trunk/test/Sema/format-strings.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings.c?rev=135048&r1=135047&r2=135048&view=diff
==============================================================================
--- cfe/trunk/test/Sema/format-strings.c (original)
+++ cfe/trunk/test/Sema/format-strings.c Wed Jul 13 12:35:14 2011
@@ -368,7 +368,7 @@
   printf("%c", y); // no-warning
   printf("%hhu", x); // no-warning
   printf("%hhi", y); // no-warning
-  printf("%hhi", x); // expected-warning{{conversion specifies type 'signed char' but the argument has type 'unsigned char'}}
+  printf("%hhi", x); // no-warning
   printf("%c", x); // no-warning
-  printf("%hhu", y); // expected-warning{{conversion specifies type 'unsigned char' but the argument has type 'signed char'}}
+  printf("%hhu", y); // no-warning
 }





More information about the cfe-commits mailing list