]> granicus.if.org Git - clang/commitdiff
Revert r135147 and r135075. The consensus was that this wasn't the right thing to do.
authorTed Kremenek <kremenek@apple.com>
Thu, 14 Jul 2011 17:05:32 +0000 (17:05 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 14 Jul 2011 17:05:32 +0000 (17:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135152 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/FormatString.cpp
test/Sema/format-strings-fixit.c
test/Sema/format-strings-i386.c [deleted file]
test/Sema/format-strings.c

index 144d62b67d11cdef56459af9177b4fba8f439556..5f3cd4c61549872d761740770ee5a14412ea9464 100644 (file)
@@ -206,10 +206,6 @@ clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS,
 // Methods on ArgTypeResult.
 //===----------------------------------------------------------------------===//
 
-static bool hasSameSize(ASTContext &astContext, QualType typeA, QualType typeB) {
-  return astContext.getTypeSize(typeA) == astContext.getTypeSize(typeB);
-}
-
 bool ArgTypeResult::matchesType(ASTContext &C, QualType argTy) const {
   switch (K) {
     case InvalidTy:
@@ -224,31 +220,33 @@ 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 (!T->isIntegerType())
-          return false;
+      if (const BuiltinType *BT = argTy->getAs<BuiltinType>())
         switch (BT->getKind()) {
           default:
             break;
           case BuiltinType::Char_S:
           case BuiltinType::SChar:
+            return T == C.UnsignedCharTy;
           case BuiltinType::Char_U:
-          case BuiltinType::UChar:
-            return hasSameSize(C, T, C.UnsignedCharTy);
+          case BuiltinType::UChar:                    
+            return T == C.SignedCharTy;
           case BuiltinType::Short:
+            return T == C.UnsignedShortTy;
           case BuiltinType::UShort:
-            return hasSameSize(C, T, C.ShortTy);
+            return T == C.ShortTy;
           case BuiltinType::Int:
+            return T == C.UnsignedIntTy;
           case BuiltinType::UInt:
-            return hasSameSize(C, T, C.IntTy);
+            return T == C.IntTy;
           case BuiltinType::Long:
+            return T == C.UnsignedLongTy;
           case BuiltinType::ULong:
-            return hasSameSize(C, T, C.LongTy);
+            return T == C.LongTy;
           case BuiltinType::LongLong:
+            return T == C.UnsignedLongLongTy;
           case BuiltinType::ULongLong:
-            return hasSameSize(C, T, C.LongLongTy);
+            return T == C.LongLongTy;
         }
-      }
       return false;
     }
 
index b4ab2306aa254d0d754a89f510cf59bd33749ebd..c2fa2f7707450cfb36b64535b99a7bd2692dfefe 100644 (file)
@@ -1,7 +1,7 @@
 // RUN: cp %s %t
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 -pedantic -Wall -fixit %t || true
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 -fsyntax-only -pedantic -Wall -Werror %t
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 -E -o - %t | FileCheck %s
+// RUN: %clang_cc1 -pedantic -Wall -fixit %t || true
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror %t
+// RUN: %clang_cc1 -E -o - %t | FileCheck %s
 
 /* This is a test of the various code modification hints that are
    provided as part of warning or extension diagnostics. All of the
diff --git a/test/Sema/format-strings-i386.c b/test/Sema/format-strings-i386.c
deleted file mode 100644 (file)
index 45d10a7..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// RUN: %clang_cc1 -triple i386-apple-macosx10.7.0 -fsyntax-only -verify -Wformat-nonliteral %s
-
-int printf(const char *restrict, ...);
-
-// Test that 'long' is compatible with 'int' on 32-bit.
-typedef unsigned int UInt32;
-void test_rdar_9763999() {
- UInt32 x = 7;
- printf("x = %u\n", x); // no-warning
-}
-
-void test_positive() {
-  printf("%d", "hello"); // expected-warning {{conversion specifies type 'int' but the argument has type 'char *'}}
-}
-
index d128d8ccc01bd367fb3828e30dc222f9b8db33a7..b47d3ca2616cf25c681a2361e3fade6e254c11b8 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 -fsyntax-only -verify -Wformat-nonliteral %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral %s
 
 #include <stdarg.h>
 typedef __typeof(sizeof(int)) size_t;