forked from OSchip/llvm-project
Fix NSLog format string checking for %@.
llvm-svn: 148885
This commit is contained in:
parent
086cbfac7d
commit
9b1f3d46d0
|
@ -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!");
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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')}}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue