aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Analysis/FormatString.cpp19
-rw-r--r--test/Sema/format-strings-i386.c14
2 files changed, 10 insertions, 23 deletions
diff --git a/lib/Analysis/FormatString.cpp b/lib/Analysis/FormatString.cpp
index 74f1e92794..5f3cd4c615 100644
--- a/lib/Analysis/FormatString.cpp
+++ b/lib/Analysis/FormatString.cpp
@@ -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:
@@ -230,21 +226,26 @@ bool ArgTypeResult::matchesType(ASTContext &C, QualType argTy) const {
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);
+ 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;
}
diff --git a/test/Sema/format-strings-i386.c b/test/Sema/format-strings-i386.c
deleted file mode 100644
index d2d9862796..0000000000
--- a/test/Sema/format-strings-i386.c
+++ /dev/null
@@ -1,14 +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 *'}}
-}