Fix NSLog format string checking for %@.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148885 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/FormatString.cpp b/lib/Analysis/FormatString.cpp
index a4d97fd..a0633c8 100644
--- a/lib/Analysis/FormatString.cpp
+++ b/lib/Analysis/FormatString.cpp
@@ -337,7 +337,8 @@
         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 dbe73c8..e5566f1 100644
--- a/lib/Analysis/PrintfFormatString.cpp
+++ b/lib/Analysis/PrintfFormatString.cpp
@@ -319,6 +319,8 @@
       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 3fb7c9e..a2fe841 100644
--- a/test/SemaObjC/format-strings-objc.m
+++ b/test/SemaObjC/format-strings-objc.m
@@ -13,6 +13,7 @@
 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 @@
   [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')}}
+}
+