@@ -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 " " ))
@@ -332,6 +337,9 @@ - (NSString *)someRandomMethod:(NSString *)key
332
337
value : (nullable NSString *)value
333
338
table : (nullable NSString *)tableName
334
339
__attribute__((format_arg(1 )));
340
+
341
+ - (NSAttributedString *)someMethod2 : (NSString *)key
342
+ __attribute__((format_arg(1 )));
335
343
@end
336
344
337
345
void useLocalizedStringForKey (NSBundle *bndl) {
@@ -356,4 +364,9 @@ void useLocalizedStringForKey(NSBundle *bndl) {
356
364
[bndl someRandomMethod: @" flerp"
357
365
value: 0
358
366
table: 0 ], 42 ]; // expected-warning{{data argument not used by format string}}
367
+
368
+ [NSAttributedString stringWithFormat:
369
+ [bndl someMethod2: @" test" ], 5 ]; // expected-warning{{data argument not used by format string}}
370
+ [NSAttributedString stringWithFormat:
371
+ [bndl someMethod2: @" %f " ], 42 ]; // expected-warning{{format specifies type 'double' but the argument has type 'int'}}
359
372
}
0 commit comments