| 1 |
// Like the compiler, the static analyzer treats some functions differently if |
| 2 |
// they come from a system header -- for example, it is assumed that system |
| 3 |
// functions do not arbitrarily free() their parameters, and that some bugs |
| 4 |
// found in system headers cannot be fixed by the user and should be |
| 5 |
// suppressed. |
| 6 |
#pragma clang system_header |
| 7 |
|
| 8 |
typedef __typeof(sizeof(int)) size_t; |
| 9 |
void *malloc(size_t); |
| 10 |
void *calloc(size_t, size_t); |
| 11 |
void free(void *); |
| 12 |
void *alloca(size_t); |
| 13 |
|
| 14 |
|
| 15 |
#if __OBJC__ |
| 16 |
|
| 17 |
#import "system-header-simulator-objc.h" |
| 18 |
|
| 19 |
@interface Wrapper : NSData |
| 20 |
- (id)initWithBytesNoCopy:(void *)bytes length:(NSUInteger)len; |
| 21 |
@end |
| 22 |
|
| 23 |
@implementation Wrapper |
| 24 |
- (id)initWithBytesNoCopy:(void *)bytes length:(NSUInteger)len { |
| 25 |
return [self initWithBytesNoCopy:bytes length:len freeWhenDone:1]; // no-warning |
| 26 |
} |
| 27 |
@end |
| 28 |
|
| 29 |
@interface CustomData : NSData |
| 30 |
+ (id)somethingNoCopy:(char *)bytes; |
| 31 |
+ (id)somethingNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)freeBuffer; |
| 32 |
+ (id)something:(char *)bytes freeWhenDone:(BOOL)freeBuffer; |
| 33 |
@end |
| 34 |
|
| 35 |
#endif |