@@ -34,6 +34,11 @@ @interface NSSimpleCString : NSString {} @end
34
34
@interface NSConstantString : NSSimpleCString @end
35
35
extern void *_NSConstantStringClassReference;
36
36
37
+ @interface NSAttributedString : NSObject
38
+ +(instancetype )stringWithFormat : (NSAttributedString *)fmt , ...
39
+ __attribute__((format(__NSString__, 1 , 2 )));
40
+ @end
41
+
37
42
typedef const struct __CFString * CFStringRef;
38
43
extern void CFStringCreateWithFormat (CFStringRef format, ...) __attribute__((format(CFString, 1 , 2 )));
39
44
#define CFSTR (cStr ) ((CFStringRef) __builtin___CFStringMakeConstantString (" " cStr " " ))
@@ -317,6 +322,9 @@ - (NSString *)someRandomMethod:(NSString *)key
317
322
value : (nullable NSString *)value
318
323
table : (nullable NSString *)tableName
319
324
__attribute__((format_arg(1 )));
325
+
326
+ - (NSAttributedString *)someMethod2 : (NSString *)key
327
+ __attribute__((format_arg(1 )));
320
328
@end
321
329
322
330
void useLocalizedStringForKey (NSBundle *bndl) {
@@ -341,4 +349,9 @@ void useLocalizedStringForKey(NSBundle *bndl) {
341
349
[bndl someRandomMethod: @" flerp"
342
350
value: 0
343
351
table: 0 ], 42 ]; // expected-warning{{data argument not used by format string}}
352
+
353
+ [NSAttributedString stringWithFormat:
354
+ [bndl someMethod2: @" test" ], 5 ]; // expected-warning{{data argument not used by format string}}
355
+ [NSAttributedString stringWithFormat:
356
+ [bndl someMethod2: @" %f " ], 42 ]; // expected-warning{{format specifies type 'double' but the argument has type 'int'}}
344
357
}
0 commit comments