aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Analysis/FormatString.cpp3
-rw-r--r--lib/Analysis/PrintfFormatString.cpp2
-rw-r--r--test/SemaObjC/format-strings-objc.m7
3 files changed, 11 insertions, 1 deletions
diff --git a/lib/Analysis/FormatString.cpp b/lib/Analysis/FormatString.cpp
index a4d97fd90a..a0633c80d3 100644
--- a/lib/Analysis/FormatString.cpp
+++ b/lib/Analysis/FormatString.cpp
@@ -337,7 +337,8 @@ bool ArgTypeResult::matchesType(ASTContext &C, QualType argTy) const {
argTy->isNullPtrType();
case ObjCPointerTy:
- return argTy->getAs<ObjCObjectPointerType>() != NULL;
+ return argTy->getAs<ObjCObjectPointerType>() ||
+ argTy->getAs<BlockPointerType>();
}
llvm_unreachable("Invalid ArgTypeResult Kind!");
diff --git a/lib/Analysis/PrintfFormatString.cpp b/lib/Analysis/PrintfFormatString.cpp
index dbe73c8f83..e5566f1411 100644
--- a/lib/Analysis/PrintfFormatString.cpp
+++ b/lib/Analysis/PrintfFormatString.cpp
@@ -319,6 +319,8 @@ ArgTypeResult PrintfSpecifier::getArgType(ASTContext &Ctx) const {
return ArgTypeResult(Ctx.WCharTy, "wchar_t");
case ConversionSpecifier::pArg:
return ArgTypeResult::CPointerTy;
+ case ConversionSpecifier::ObjCObjArg:
+ return ArgTypeResult::ObjCPointerTy;
default:
break;
}
diff --git a/test/SemaObjC/format-strings-objc.m b/test/SemaObjC/format-strings-objc.m
index 3fb7c9e435..a2fe841ced 100644
--- a/test/SemaObjC/format-strings-objc.m
+++ b/test/SemaObjC/format-strings-objc.m
@@ -13,6 +13,7 @@ typedef signed char BOOL;
typedef unsigned int NSUInteger;
@class NSString, Protocol;
extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
typedef struct _NSZone NSZone;
@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
@protocol NSObject - (BOOL)isEqual:(id)object; @end
@@ -82,3 +83,9 @@ void check_method() {
[Foo fooWithFormat:@"%@"]; // expected-warning {{more '%' conversions than data arguments}}
[Foo fooWithCStringFormat:"%@"]; // expected-warning {{invalid conversion specifier '@'}}
}
+
+// Warn about using BOOL with %@
+void rdar10743758(id x) {
+ NSLog(@"%@ %@", x, (BOOL) 1); // expected-warning {{format specifies type 'id' but the argument has type 'BOOL' (aka 'signed char')}}
+}
+