зеркало из https://github.com/microsoft/clang-1.git
Fix NSLog format string checking for %@.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148885 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
d814eaf0df
Коммит
e6ca97f2ae
|
@ -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')}}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче