xref: /llvm-project/clang/test/SemaObjC/objc-cf-audited-warning.m (revision 0f1c1be1968076d6f96f8a7bcc4a15cf195ecd97)
1// RUN: %clang_cc1  -fobjc-arc -verify %s
2
3#if __has_feature(arc_cf_code_audited)
4#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin")
5#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end")
6#endif
7#define CF_BRIDGED_TYPE(T)              __attribute__((objc_bridge(T)))
8
9typedef const struct CF_BRIDGED_TYPE(NSURL) __CFURL * CFURLRef;
10typedef signed long long CFIndex;
11typedef unsigned char           Boolean;
12typedef unsigned char                   UInt8;
13typedef const struct __CFAllocator * CFAllocatorRef;
14const CFAllocatorRef kCFAllocatorDefault;
15
16CF_IMPLICIT_BRIDGING_ENABLED
17CFURLRef CFURLCreateFromFileSystemRepresentation(CFAllocatorRef allocator, const UInt8 *buffer, CFIndex bufLen, Boolean isDirectory); // expected-note {{passing argument to parameter 'buffer' here}}
18CF_IMPLICIT_BRIDGING_DISABLED
19
20void saveImageToJPG(const char *filename)
21{
22    CFURLRef url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, filename, 10, 0); // expected-warning {{passing 'const char *' to parameter of type 'const UInt8 *' (aka 'const unsigned char *') converts between pointers to integer types where one is of the unique plain 'char' type and the other is not}}
23}
24