36 lines · c
1// Like the compiler, the static analyzer treats some functions differently if2// they come from a system header -- for example, it is assumed that system3// functions do not arbitrarily free() their parameters, and that some bugs4// found in system headers cannot be fixed by the user and should be5// suppressed.6#pragma clang system_header7 8typedef __typeof(sizeof(int)) size_t;9void *malloc(size_t);10void *calloc(size_t, size_t);11void free(void *);12void *alloca(size_t);13 14 15#if __OBJC__16 17#import "system-header-simulator-objc.h"18 19@interface Wrapper : NSData20- (id)initWithBytesNoCopy:(void *)bytes length:(NSUInteger)len;21@end22 23@implementation Wrapper24- (id)initWithBytesNoCopy:(void *)bytes length:(NSUInteger)len {25 return [self initWithBytesNoCopy:bytes length:len freeWhenDone:1]; // no-warning26}27@end28 29@interface CustomData : NSData30+ (id)somethingNoCopy:(char *)bytes;31+ (id)somethingNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)freeBuffer;32+ (id)something:(char *)bytes freeWhenDone:(BOOL)freeBuffer;33@end34 35#endif36