[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Analysis / cfref_rdar6080742.c
blob95ac67cb94493cf9535065eccc2f3883bbdcc0b4
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -verify %s
2 // expected-no-diagnostics
4 // This test case was reported in <rdar:problem/6080742>.
5 // It tests path-sensitivity with respect to '!(cfstring != 0)' (negation of inequality).
7 int printf(const char *restrict,...);
8 typedef unsigned long UInt32;
9 typedef signed long SInt32;
10 typedef SInt32 OSStatus;
11 typedef unsigned char Boolean;
12 enum { noErr = 0};
13 typedef const void *CFTypeRef;
14 typedef const struct __CFString *CFStringRef;
15 typedef const struct __CFAllocator *CFAllocatorRef;
16 extern void CFRelease(CFTypeRef cf);
17 typedef UInt32 CFStringEncoding;
18 enum { kCFStringEncodingMacRoman = 0, kCFStringEncodingWindowsLatin1 = 0x0500,
19 kCFStringEncodingISOLatin1 = 0x0201, kCFStringEncodingNextStepLatin = 0x0B01,
20 kCFStringEncodingASCII = 0x0600, kCFStringEncodingUnicode = 0x0100,
21 kCFStringEncodingUTF8 = 0x08000100, kCFStringEncodingNonLossyASCII = 0x0BFF,
22 kCFStringEncodingUTF16 = 0x0100, kCFStringEncodingUTF16BE = 0x10000100,
23 kCFStringEncodingUTF16LE = 0x14000100, kCFStringEncodingUTF32 = 0x0c000100,
24 kCFStringEncodingUTF32BE = 0x18000100, kCFStringEncodingUTF32LE = 0x1c000100};
25 extern CFStringRef CFStringCreateWithCString(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding);
27 enum { memROZWarn = -99, memROZError = -99, memROZErr = -99, memFullErr = -108,
28 nilHandleErr = -109, memWZErr = -111, memPurErr = -112, memAdrErr = -110,
29 memAZErr = -113, memPCErr = -114, memBCErr = -115, memSCErr = -116, memLockedErr = -117};
31 #define DEBUG1
33 void DebugStop(const char *format,...);
34 void DebugTraceIf(unsigned int condition, const char *format,...);
35 Boolean DebugDisplayOSStatusMsg(OSStatus status, const char *statusStr, const char *fileName, unsigned long lineNumber);
37 #define Assert(condition)if (!(condition)) { DebugStop("Assertion failure: %s [File: %s, Line: %lu]", #condition, __FILE__, __LINE__); }
38 #define AssertMsg(condition, message)if (!(condition)) { DebugStop("Assertion failure: %s (%s) [File: %s, Line: %lu]", #condition, message, __FILE__, __LINE__); }
39 #define Require(condition)if (!(condition)) { DebugStop("Assertion failure: %s [File: %s, Line: %lu]", #condition, __FILE__, __LINE__); }
40 #define RequireAction(condition, action)if (!(condition)) { DebugStop("Assertion failure: %s [File: %s, Line: %lu]", #condition, __FILE__, __LINE__); action }
41 #define RequireActionSilent(condition, action)if (!(condition)) { action }
42 #define AssertNoErr(err){ DebugDisplayOSStatusMsg((err), #err, __FILE__, __LINE__); }
43 #define RequireNoErr(err, action){ if( DebugDisplayOSStatusMsg((err), #err, __FILE__, __LINE__) ) { action }}
45 void DebugStop(const char *format,...); /* Not an abort function. */
47 int main(int argc, char *argv[]) {
48 CFStringRef cfString;
49 OSStatus status = noErr;
50 cfString = CFStringCreateWithCString(0, "hello", kCFStringEncodingUTF8);
51 RequireAction(cfString != 0, return memFullErr;) //no - warning
52 printf("cfstring %p\n", cfString);
53 Exit:
54 CFRelease(cfString);
55 return 0;