[cfe-commits] r135129 - in /cfe/trunk: lib/Analysis/FormatString.cpp test/Sema/format-strings-i386.c
NAKAMURA Takumi
geek4civic at gmail.com
Wed Jul 13 22:16:18 PDT 2011
Author: chapuni
Date: Thu Jul 14 00:16:18 2011
New Revision: 135129
URL: http://llvm.org/viewvc/llvm-project?rev=135129&view=rev
Log:
Revert r135075, "format string checking: long and int have the same widths on 32-bit, so we shouldn't warn about using"
It fails on freebsd, mingw and msvc10.
Removed:
cfe/trunk/test/Sema/format-strings-i386.c
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=135129&r1=135128&r2=135129&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/FormatString.cpp (original)
+++ cfe/trunk/lib/Analysis/FormatString.cpp Thu Jul 14 00:16:18 2011
@@ -206,10 +206,6 @@
// 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 @@
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;
}
Removed: cfe/trunk/test/Sema/format-strings-i386.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings-i386.c?rev=135128&view=auto
==============================================================================
--- cfe/trunk/test/Sema/format-strings-i386.c (original)
+++ cfe/trunk/test/Sema/format-strings-i386.c (removed)
@@ -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 *'}}
-}
More information about the cfe-commits
mailing list