aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis')
-rw-r--r--test/Analysis/CFContainers.mm204
-rw-r--r--test/Analysis/CFDateGC.m4
-rw-r--r--test/Analysis/CheckNSError.m4
-rw-r--r--test/Analysis/NSPanel.m4
-rw-r--r--test/Analysis/NSString.m22
-rw-r--r--test/Analysis/ObjCProperties.m4
-rw-r--r--test/Analysis/ObjCRetSigs.m2
-rw-r--r--test/Analysis/additive-folding.c4
-rw-r--r--test/Analysis/array-struct-region.c4
-rw-r--r--test/Analysis/auto-obj-dtors-cfg-output.cpp1422
-rw-r--r--test/Analysis/bool-assignment.cpp87
-rw-r--r--test/Analysis/bool-assignment2.c35
-rw-r--r--test/Analysis/bstring.c8
-rw-r--r--test/Analysis/casts.m3
-rw-r--r--test/Analysis/check-deserialization.cpp20
-rw-r--r--test/Analysis/coverage.c94
-rw-r--r--test/Analysis/cstring-syntax-cxx.cpp16
-rw-r--r--test/Analysis/cstring-syntax.c13
-rw-r--r--test/Analysis/dead-stores.c30
-rw-r--r--test/Analysis/dead-stores.m14
-rw-r--r--test/Analysis/debug-CallGraph.c21
-rw-r--r--test/Analysis/default-analyze.m63
-rw-r--r--test/Analysis/domtest.c165
-rw-r--r--test/Analysis/dtor.cpp2
-rw-r--r--test/Analysis/dtors-in-dtor-cfg-output.cpp42
-rw-r--r--test/Analysis/dynamic-cast.cpp230
-rw-r--r--test/Analysis/exercise-ps.c2
-rw-r--r--test/Analysis/free.c3
-rw-r--r--test/Analysis/global-region-invalidation.c75
-rw-r--r--test/Analysis/html-diags-multifile.c17
-rw-r--r--test/Analysis/html-diags-multifile.h4
-rw-r--r--test/Analysis/html-diags.c20
-rw-r--r--test/Analysis/idempotent-operations-limited-loops.c6
-rw-r--r--test/Analysis/idempotent-operations.c3
-rw-r--r--test/Analysis/idempotent-operations.cpp2
-rw-r--r--test/Analysis/idempotent-operations.m2
-rw-r--r--test/Analysis/initializers-cfg-output.cpp109
-rw-r--r--test/Analysis/inline-not-supported.c29
-rw-r--r--test/Analysis/inline-plist.c369
-rw-r--r--test/Analysis/inline-unique-reports.c184
-rw-r--r--test/Analysis/inline.c65
-rw-r--r--test/Analysis/inline2.c2
-rw-r--r--test/Analysis/inline3.c4
-rw-r--r--test/Analysis/inline4.c2
-rw-r--r--test/Analysis/keychainAPI.m94
-rw-r--r--test/Analysis/lambdas.cpp20
-rw-r--r--test/Analysis/malloc-annotations.c271
-rw-r--r--test/Analysis/malloc-interprocedural.c98
-rw-r--r--test/Analysis/malloc-plist.c2814
-rw-r--r--test/Analysis/malloc-sizeof.c27
-rw-r--r--test/Analysis/malloc.c722
-rw-r--r--test/Analysis/malloc.cpp16
-rw-r--r--test/Analysis/malloc.m37
-rw-r--r--test/Analysis/malloc.mm156
-rw-r--r--test/Analysis/method-arg-decay.m5
-rw-r--r--test/Analysis/method-call-intra-p.cpp32
-rw-r--r--test/Analysis/misc-ps-cxx0x.cpp5
-rw-r--r--test/Analysis/misc-ps-region-store.cpp115
-rw-r--r--test/Analysis/misc-ps-region-store.m26
-rw-r--r--test/Analysis/misc-ps-region-store.mm17
-rw-r--r--test/Analysis/misc-ps.c81
-rw-r--r--test/Analysis/misc-ps.m36
-rw-r--r--test/Analysis/new.cpp1
-rw-r--r--test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m28
-rw-r--r--test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m18
-rw-r--r--test/Analysis/null-deref-ps.c29
-rw-r--r--test/Analysis/nullptr.cpp38
-rw-r--r--test/Analysis/objc-arc.m67
-rw-r--r--test/Analysis/objc-bool.m22
-rw-r--r--test/Analysis/objc-method-coverage.m17
-rw-r--r--test/Analysis/out-of-bounds.c6
-rw-r--r--test/Analysis/plist-output-alternate.m289
-rw-r--r--test/Analysis/plist-output.m845
-rw-r--r--test/Analysis/pr_2542_rdar_6793404.m2
-rw-r--r--test/Analysis/properties.m25
-rw-r--r--test/Analysis/ptr-arith.c2
-rw-r--r--test/Analysis/rdar-6540084.m2
-rw-r--r--test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m6
-rw-r--r--test/Analysis/redefined_system.c17
-rw-r--r--test/Analysis/reference.cpp2
-rw-r--r--test/Analysis/retain-release-gc-only.m4
-rw-r--r--test/Analysis/retain-release-inline.m347
-rw-r--r--test/Analysis/retain-release-path-notes-gc.m8
-rw-r--r--test/Analysis/retain-release-path-notes.m16
-rw-r--r--test/Analysis/retain-release-region-store.m7
-rw-r--r--test/Analysis/retain-release.m159
-rw-r--r--test/Analysis/retain-release.mm51
-rw-r--r--test/Analysis/security-syntax-checks-no-emit.c2
-rw-r--r--test/Analysis/security-syntax-checks.m34
-rw-r--r--test/Analysis/self-init.m52
-rw-r--r--test/Analysis/stack-addr-ps.c18
-rw-r--r--test/Analysis/stats.c8
-rw-r--r--test/Analysis/string.c32
-rw-r--r--test/Analysis/system-header-simulator-objc.h114
-rw-r--r--test/Analysis/system-header-simulator.h38
-rw-r--r--test/Analysis/taint-generic.c185
-rw-r--r--test/Analysis/taint-tester.c204
-rw-r--r--test/Analysis/taint-tester.cpp26
-rw-r--r--test/Analysis/taint-tester.m20
-rw-r--r--test/Analysis/temp-obj-dtors-cfg-output.cpp1315
-rw-r--r--test/Analysis/uninit-vals-ps-region.m2
-rw-r--r--test/Analysis/unix-fns.c70
-rw-r--r--test/Analysis/unreachable-code-path.c17
-rw-r--r--test/Analysis/unused-ivars.m2
-rw-r--r--test/Analysis/variadic-method-types.m8
-rw-r--r--test/Analysis/virtualcall.cpp53
106 files changed, 10140 insertions, 2055 deletions
diff --git a/test/Analysis/CFContainers.mm b/test/Analysis/CFContainers.mm
new file mode 100644
index 000000000000..7d6c175d1fc2
--- /dev/null
+++ b/test/Analysis/CFContainers.mm
@@ -0,0 +1,204 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=osx.coreFoundation.containers.PointerSizedValues,osx.coreFoundation.containers.OutOfBounds -analyzer-store=region -triple x86_64-apple-darwin -verify %s
+
+typedef const struct __CFAllocator * CFAllocatorRef;
+typedef const struct __CFString * CFStringRef;
+typedef unsigned char Boolean;
+typedef signed long CFIndex;
+extern
+const CFAllocatorRef kCFAllocatorDefault;
+typedef const void * (*CFArrayRetainCallBack)(CFAllocatorRef allocator, const void *value);
+typedef void (*CFArrayReleaseCallBack)(CFAllocatorRef allocator, const void *value);
+typedef CFStringRef (*CFArrayCopyDescriptionCallBack)(const void *value);
+typedef Boolean (*CFArrayEqualCallBack)(const void *value1, const void *value2);
+typedef struct {
+ CFIndex version;
+ CFArrayRetainCallBack retain;
+ CFArrayReleaseCallBack release;
+ CFArrayCopyDescriptionCallBack copyDescription;
+ CFArrayEqualCallBack equal;
+} CFArrayCallBacks;
+typedef const struct __CFArray * CFArrayRef;
+CFArrayRef CFArrayCreate(CFAllocatorRef allocator, const void **values, CFIndex numValues, const CFArrayCallBacks *callBacks);
+typedef const struct __CFString * CFStringRef;
+enum {
+ kCFNumberSInt8Type = 1,
+ kCFNumberSInt16Type = 2,
+ kCFNumberSInt32Type = 3,
+ kCFNumberSInt64Type = 4,
+ kCFNumberFloat32Type = 5,
+ kCFNumberFloat64Type = 6,
+ kCFNumberCharType = 7,
+ kCFNumberShortType = 8,
+ kCFNumberIntType = 9,
+ kCFNumberLongType = 10,
+ kCFNumberLongLongType = 11,
+ kCFNumberFloatType = 12,
+ kCFNumberDoubleType = 13,
+ kCFNumberCFIndexType = 14,
+ kCFNumberNSIntegerType = 15,
+ kCFNumberCGFloatType = 16,
+ kCFNumberMaxType = 16
+};
+typedef CFIndex CFNumberType;
+typedef const struct __CFNumber * CFNumberRef;
+typedef CFIndex CFComparisonResult;
+typedef const struct __CFDictionary * CFDictionaryRef;
+typedef const void * (*CFDictionaryRetainCallBack)(CFAllocatorRef allocator, const void *value);
+typedef void (*CFDictionaryReleaseCallBack)(CFAllocatorRef allocator, const void *value);
+typedef CFStringRef (*CFDictionaryCopyDescriptionCallBack)(const void *value);
+typedef Boolean (*CFDictionaryEqualCallBack)(const void *value1, const void *value2);
+typedef Boolean (*CFArrayEqualCallBack)(const void *value1, const void *value2);
+typedef Boolean (*CFSetEqualCallBack)(const void *value1, const void *value2);
+typedef const void * (*CFSetRetainCallBack)(CFAllocatorRef allocator, const void *value);
+typedef void (*CFSetReleaseCallBack)(CFAllocatorRef allocator, const void *value);
+typedef CFStringRef (*CFSetCopyDescriptionCallBack)(const void *value);
+typedef struct {
+ CFIndex version;
+ CFSetRetainCallBack retain;
+ CFSetReleaseCallBack release;
+ CFSetCopyDescriptionCallBack copyDescription;
+ CFSetEqualCallBack equal;
+} CFSetCallBacks;
+typedef struct {
+ CFIndex version;
+ CFDictionaryRetainCallBack retain;
+ CFDictionaryReleaseCallBack release;
+ CFDictionaryCopyDescriptionCallBack copyDescription;
+ CFDictionaryEqualCallBack equal;
+} CFDictionaryKeyCallBacks;
+typedef struct {
+ CFIndex version;
+ CFDictionaryRetainCallBack retain;
+ CFDictionaryReleaseCallBack release;
+ CFDictionaryCopyDescriptionCallBack copyDescription;
+ CFDictionaryEqualCallBack equal;
+} CFDictionaryValueCallBacks;
+CFDictionaryRef CFDictionaryCreate(CFAllocatorRef allocator, const void **keys, const void **values, CFIndex numValues, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);
+extern
+const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks;
+typedef const struct __CFSet * CFSetRef;
+extern
+const CFSetCallBacks kCFTypeSetCallBacks;
+extern
+const CFDictionaryKeyCallBacks kCFCopyStringDictionaryKeyCallBacks;
+extern
+const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx);
+extern
+CFIndex CFArrayGetCount(CFArrayRef theArray);
+CFDictionaryRef CFDictionaryCreate(CFAllocatorRef allocator, const void **keys, const void **values, CFIndex numValues, const
+CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);
+CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr);
+extern
+CFSetRef CFSetCreate(CFAllocatorRef allocator, const void **values, CFIndex numValues, const CFSetCallBacks *callBacks);
+#define CFSTR(cStr) ((CFStringRef) __builtin___CFStringMakeConstantString ("" cStr ""))
+#define NULL __null
+
+// Done with the headers.
+// Test experimental.osx.cocoa.ContainerAPI checker.
+void testContainers(int **xNoWarn, CFIndex count) {
+ int x[] = { 1, 2, 3 };
+ CFArrayRef foo = CFArrayCreate(kCFAllocatorDefault, (const void **) x, sizeof(x) / sizeof(x[0]), 0);// expected-warning {{The first argument to 'CFArrayCreate' must be a C array of pointer-sized}}
+
+ CFArrayRef fooNoWarn = CFArrayCreate(kCFAllocatorDefault, (const void **) xNoWarn, sizeof(xNoWarn) / sizeof(xNoWarn[0]), 0); // no warning
+ CFArrayRef fooNoWarn2 = CFArrayCreate(kCFAllocatorDefault, 0, sizeof(xNoWarn) / sizeof(xNoWarn[0]), 0);// no warning, passing in 0
+ CFArrayRef fooNoWarn3 = CFArrayCreate(kCFAllocatorDefault, NULL, sizeof(xNoWarn) / sizeof(xNoWarn[0]), 0);// no warning, passing in NULL
+
+ CFSetRef set = CFSetCreate(NULL, (const void **)x, 3, &kCFTypeSetCallBacks); // expected-warning {{The first argument to 'CFSetCreate' must be a C array of pointer-sized values}}
+ CFArrayRef* pairs = new CFArrayRef[count];
+ CFSetRef fSet = CFSetCreate(kCFAllocatorDefault, (const void**) pairs, count - 1, &kCFTypeSetCallBacks);// no warning
+}
+
+void CreateDict(int *elems) {
+ const short days28 = 28;
+ const short days30 = 30;
+ const short days31 = 31;
+ CFIndex numValues = 6;
+ CFStringRef keys[6];
+ CFNumberRef values[6];
+ keys[0] = CFSTR("January"); values[0] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days31);
+ keys[1] = CFSTR("February"); values[1] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days28);
+ keys[2] = CFSTR("March"); values[2] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days31);
+ keys[3] = CFSTR("April"); values[3] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days30);
+ keys[4] = CFSTR("May"); values[4] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days31);
+ keys[5] = CFSTR("June"); values[5] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days30);
+
+ const CFDictionaryKeyCallBacks keyCB = kCFCopyStringDictionaryKeyCallBacks;
+ const CFDictionaryValueCallBacks valCB = kCFTypeDictionaryValueCallBacks;
+ CFDictionaryRef dict1 = CFDictionaryCreate(kCFAllocatorDefault, (const void**)keys, (const void**)values, numValues, &keyCB, &valCB); // no warning
+ CFDictionaryRef dict2 = CFDictionaryCreate(kCFAllocatorDefault, (const void**)elems[0], (const void**)values, numValues, &keyCB, &valCB); //expected-warning {{The first argument to 'CFDictionaryCreate' must be a C array of}}
+ CFDictionaryRef dict3 = CFDictionaryCreate(kCFAllocatorDefault, (const void**)keys, (const void**)elems, numValues, &keyCB, &valCB); // expected-warning {{The second argument to 'CFDictionaryCreate' must be a C array of pointer-sized values}}
+}
+
+void OutOfBoundsSymbolicOffByOne(const void ** input, CFIndex S) {
+ CFArrayRef array;
+ array = CFArrayCreate(kCFAllocatorDefault, input, S, 0);
+ const void *s1 = CFArrayGetValueAtIndex(array, 0); // no warning
+ const void *s2 = CFArrayGetValueAtIndex(array, S-1); // no warning
+ const void *s3 = CFArrayGetValueAtIndex(array, S); // expected-warning {{Index is out of bounds}}
+}
+
+void OutOfBoundsConst(const void ** input, CFIndex S) {
+ CFArrayRef array;
+ array = CFArrayCreate(kCFAllocatorDefault, input, 3, 0);
+ const void *s1 = CFArrayGetValueAtIndex(array, 0); // no warning
+ const void *s2 = CFArrayGetValueAtIndex(array, 2); // no warning
+ const void *s3 = CFArrayGetValueAtIndex(array, 5); // expected-warning {{Index is out of bounds}}
+
+ // TODO: The solver is probably not strong enough here.
+ CFIndex sIndex;
+ for (sIndex = 0 ; sIndex <= 5 ; sIndex += 3 ) {
+ const void *s = CFArrayGetValueAtIndex(array, sIndex);
+ }
+}
+
+void OutOfBoundsZiro(const void ** input, CFIndex S) {
+ CFArrayRef array;
+ // The API allows to set the size to 0. Check that we don't undeflow when the size is 0.
+ array = CFArrayCreate(kCFAllocatorDefault, 0, 0, 0);
+ const void *s1 = CFArrayGetValueAtIndex(array, 0); // expected-warning {{Index is out of bounds}}
+}
+
+void TestGetCount(CFArrayRef A, CFIndex sIndex) {
+ CFIndex sCount = CFArrayGetCount(A);
+ if (sCount > sIndex)
+ const void *s1 = CFArrayGetValueAtIndex(A, sIndex);
+ const void *s2 = CFArrayGetValueAtIndex(A, sCount);// expected-warning {{Index is out of bounds}}
+}
+
+typedef void* XX[3];
+void TestPointerToArray(int *elems, void *p1, void *p2, void *p3, unsigned count, void* fn[], char cp[]) {
+ void* x[] = { p1, p2, p3 };
+ CFArrayCreate(0, (const void **) &x, count, 0); // no warning
+
+ void* y[] = { p1, p2, p3 };
+ CFArrayCreate(0, (const void **) y, count, 0); // no warning
+ XX *z = &x;
+ CFArrayCreate(0, (const void **) z, count, 0); // no warning
+
+ CFArrayCreate(0, (const void **) &fn, count, 0); // false negative
+ CFArrayCreate(0, (const void **) fn, count, 0); // no warning
+ CFArrayCreate(0, (const void **) cp, count, 0); // expected-warning {{The first argument to 'CFArrayCreate' must be a C array of pointer-sized}}
+
+ char cc[] = { 0, 2, 3 };
+ CFArrayCreate(0, (const void **) &cc, count, 0); // expected-warning {{The first argument to 'CFArrayCreate' must be a C array of pointer-sized}}
+ CFArrayCreate(0, (const void **) cc, count, 0); // expected-warning {{The first argument to 'CFArrayCreate' must be a C array of pointer-sized}}
+}
+
+void TestUndef(CFArrayRef A, CFIndex sIndex, void* x[]) {
+ unsigned undefVal;
+ const void *s1 = CFArrayGetValueAtIndex(A, undefVal);
+
+ unsigned undefVal2;
+ CFArrayRef B = CFArrayCreate(0, (const void **) &x, undefVal2, 0);
+ const void *s2 = CFArrayGetValueAtIndex(B, 2);
+}
+
+void TestConst(CFArrayRef A, CFIndex sIndex, void* x[]) {
+ CFArrayRef B = CFArrayCreate(0, (const void **) &x, 4, 0);
+ const void *s1 = CFArrayGetValueAtIndex(B, 2);
+
+}
+
+void TestNullArray() {
+ CFArrayGetValueAtIndex(0, 0);
+}
diff --git a/test/Analysis/CFDateGC.m b/test/Analysis/CFDateGC.m
index 69b99f052b01..4884bb9ea888 100644
--- a/test/Analysis/CFDateGC.m
+++ b/test/Analysis/CFDateGC.m
@@ -42,7 +42,7 @@ CFAbsoluteTime f1_use_after_release() {
[NSMakeCollectable(date) release];
CFDateGetAbsoluteTime(date); // no-warning
CFRelease(date);
- t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released.}}
+ t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released}}
return t;
}
@@ -55,7 +55,7 @@ CFAbsoluteTime f2_use_after_release() {
[(id) CFMakeCollectable(date) release];
CFDateGetAbsoluteTime(date); // no-warning
CFRelease(date);
- t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released.}}
+ t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released}}
return t;
}
diff --git a/test/Analysis/CheckNSError.m b/test/Analysis/CheckNSError.m
index 5bf7e08a587a..d35b686ef1d9 100644
--- a/test/Analysis/CheckNSError.m
+++ b/test/Analysis/CheckNSError.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NSError,osx.coreFoundation.CFError -analyzer-store=region -analyzer-constraints=basic -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NSError,osx.coreFoundation.CFError -analyzer-store=region -analyzer-constraints=range -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NSError,osx.coreFoundation.CFError -analyzer-store=region -analyzer-constraints=basic -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NSError,osx.coreFoundation.CFError -analyzer-store=region -analyzer-constraints=range -verify -Wno-objc-root-class %s
typedef signed char BOOL;
diff --git a/test/Analysis/NSPanel.m b/test/Analysis/NSPanel.m
index ac725716457f..578658eab694 100644
--- a/test/Analysis/NSPanel.m
+++ b/test/Analysis/NSPanel.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -analyzer-constraints=range -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -Wno-objc-root-class %s
// BEGIN delta-debugging reduced header stuff
diff --git a/test/Analysis/NSString.m b/test/Analysis/NSString.m
index 48450daa013d..4035cc93130a 100644
--- a/test/Analysis/NSString.m
+++ b/test/Analysis/NSString.m
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify %s
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=range -verify %s
-// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify %s
-// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=range -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -Wno-objc-root-class %s
//===----------------------------------------------------------------------===//
@@ -97,31 +97,31 @@ extern void *_NSConstantStringClassReference;
NSComparisonResult f1(NSString* s) {
NSString *aString = 0;
- return [s compare:aString]; // expected-warning {{Argument to 'NSString' method 'compare:' cannot be nil.}}
+ return [s compare:aString]; // expected-warning {{Argument to 'NSString' method 'compare:' cannot be nil}}
}
NSComparisonResult f2(NSString* s) {
NSString *aString = 0;
- return [s caseInsensitiveCompare:aString]; // expected-warning {{Argument to 'NSString' method 'caseInsensitiveCompare:' cannot be nil.}}
+ return [s caseInsensitiveCompare:aString]; // expected-warning {{Argument to 'NSString' method 'caseInsensitiveCompare:' cannot be nil}}
}
NSComparisonResult f3(NSString* s, NSStringCompareOptions op) {
NSString *aString = 0;
- return [s compare:aString options:op]; // expected-warning {{Argument to 'NSString' method 'compare:options:' cannot be nil.}}
+ return [s compare:aString options:op]; // expected-warning {{Argument to 'NSString' method 'compare:options:' cannot be nil}}
}
NSComparisonResult f4(NSString* s, NSStringCompareOptions op, NSRange R) {
NSString *aString = 0;
- return [s compare:aString options:op range:R]; // expected-warning {{Argument to 'NSString' method 'compare:options:range:' cannot be nil.}}
+ return [s compare:aString options:op range:R]; // expected-warning {{Argument to 'NSString' method 'compare:options:range:' cannot be nil}}
}
NSComparisonResult f5(NSString* s, NSStringCompareOptions op, NSRange R) {
NSString *aString = 0;
- return [s compare:aString options:op range:R locale:0]; // expected-warning {{Argument to 'NSString' method 'compare:options:range:locale:' cannot be nil.}}
+ return [s compare:aString options:op range:R locale:0]; // expected-warning {{Argument to 'NSString' method 'compare:options:range:locale:' cannot be nil}}
}
NSArray *f6(NSString* s) {
- return [s componentsSeparatedByCharactersInSet:0]; // expected-warning {{Argument to 'NSString' method 'componentsSeparatedByCharactersInSet:' cannot be nil.}}
+ return [s componentsSeparatedByCharactersInSet:0]; // expected-warning {{Argument to 'NSString' method 'componentsSeparatedByCharactersInSet:' cannot be nil}}
}
NSString* f7(NSString* s1, NSString* s2, NSString* s3) {
@@ -189,7 +189,7 @@ void f13(void) {
@end
void f14(MyString *s) {
- [s compare:0]; // expected-warning {{Argument to 'MyString' method 'compare:' cannot be nil.}}
+ [s compare:0]; // expected-warning {{Argument to 'MyString' method 'compare:' cannot be nil}}
}
// Test regular use of -autorelease
diff --git a/test/Analysis/ObjCProperties.m b/test/Analysis/ObjCProperties.m
index d88e0571e4c1..b9ed9b9a7e5f 100644
--- a/test/Analysis/ObjCProperties.m
+++ b/test/Analysis/ObjCProperties.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=basic %s -verify
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range %s -verify
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=basic -Wno-objc-root-class %s -verify
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -Wno-objc-root-class %s -verify
// The point of this test cases is to exercise properties in the static
// analyzer
diff --git a/test/Analysis/ObjCRetSigs.m b/test/Analysis/ObjCRetSigs.m
index 02be25717a63..13078a32232b 100644
--- a/test/Analysis/ObjCRetSigs.m
+++ b/test/Analysis/ObjCRetSigs.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core -analyzer-checker=osx.cocoa.IncompatibleMethodTypes -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core -analyzer-checker=osx.cocoa.IncompatibleMethodTypes -verify -Wno-objc-root-class %s
int printf(const char *, ...);
diff --git a/test/Analysis/additive-folding.c b/test/Analysis/additive-folding.c
index 71d0151f22af..beb08aa59c2f 100644
--- a/test/Analysis/additive-folding.c
+++ b/test/Analysis/additive-folding.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.unix.Malloc -verify -analyzer-constraints=basic %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.unix.Malloc -verify -analyzer-constraints=range %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,unix.Malloc -verify -analyzer-constraints=basic %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,unix.Malloc -verify -analyzer-constraints=range %s
// These are used to trigger warnings.
typedef typeof(sizeof(int)) size_t;
diff --git a/test/Analysis/array-struct-region.c b/test/Analysis/array-struct-region.c
index 1284933db09d..4b085c8d7002 100644
--- a/test/Analysis/array-struct-region.c
+++ b/test/Analysis/array-struct-region.c
@@ -25,8 +25,8 @@ int string_literal_init() {
}
void nested_compound_literals(int rad) {
- int vec[6][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169},
- {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
+ int vec[6][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, // expected-warning 6 {{implicit conversion turns literal floating-point number into integer}}
+ {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}}; // expected-warning 6 {{implicit conversion turns literal floating-point number into integer}}
int a;
for (a = 0; a < 6; ++a) {
diff --git a/test/Analysis/auto-obj-dtors-cfg-output.cpp b/test/Analysis/auto-obj-dtors-cfg-output.cpp
index 17aa486de0ce..67a8f2e555bd 100644
--- a/test/Analysis/auto-obj-dtors-cfg-output.cpp
+++ b/test/Analysis/auto-obj-dtors-cfg-output.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG -cfg-add-implicit-dtors %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG -cfg-add-implicit-dtors %s > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
// XPASS: *
class A {
@@ -155,718 +156,709 @@ void test_catch_copy() {
}
}
-// CHECK: [ B2 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B1
-// CHECK: [ B1 ]
-// CHECK: 1:
-// CHECK: 2: A a;
-// CHECK: 3: a
-// CHECK: 4: [B1.3]
-// CHECK: 5: const A &b = a;
-// CHECK: 6: A()
-// CHECK: 7: [B1.6] (BindTemporary)
-// CHECK: 8: [B1.7]
-// CHECK: 9: [B1.8]
-// CHECK: 10: const A &c = A();
-// CHECK: 11: [B1.10].~A() (Implicit destructor)
-// CHECK: 12: [B1.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (1): B0
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B2 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B1
-// CHECK: [ B1 ]
-// CHECK: 1:
-// CHECK: 2: A a[2];
-// CHECK: 3:
-// CHECK: 4: A b[0];
-// CHECK: 5: [B1.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (1): B0
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B2 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B1
-// CHECK: [ B1 ]
-// CHECK: 1:
-// CHECK: 2: A a;
-// CHECK: 3:
-// CHECK: 4: A c;
-// CHECK: 5:
-// CHECK: 6: A d;
-// CHECK: 7: [B1.6].~A() (Implicit destructor)
-// CHECK: 8: [B1.4].~A() (Implicit destructor)
-// CHECK: 9:
-// CHECK: 10: A b;
-// CHECK: 11: [B1.10].~A() (Implicit destructor)
-// CHECK: 12: [B1.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (1): B0
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B4 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B3
-// CHECK: [ B1 ]
-// CHECK: 1:
-// CHECK: 2: A c;
-// CHECK: 3: [B1.2].~A() (Implicit destructor)
-// CHECK: 4: [B3.4].~A() (Implicit destructor)
-// CHECK: 5: [B3.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B3
-// CHECK: Successors (1): B0
-// CHECK: [ B2 ]
-// CHECK: 1: return;
-// CHECK: 2: [B3.4].~A() (Implicit destructor)
-// CHECK: 3: [B3.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B3
-// CHECK: Successors (1): B0
-// CHECK: [ B3 ]
-// CHECK: 1:
-// CHECK: 2: A a;
-// CHECK: 3:
-// CHECK: 4: A b;
-// CHECK: 5: UV
-// CHECK: 6: [B3.5]
-// CHECK: T: if [B3.6]
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (2): B2 B1
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (2): B1 B2
-// CHECK: Successors (0):
-// CHECK: [ B8 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B7
-// CHECK: [ B1 ]
-// CHECK: l1:
-// CHECK: 1:
-// CHECK: 2: A c;
-// CHECK: 3: [B1.2].~A() (Implicit destructor)
-// CHECK: 4: [B6.2].~A() (Implicit destructor)
-// CHECK: 5: [B7.2].~A() (Implicit destructor)
-// CHECK: Predecessors (2): B2 B3
-// CHECK: Successors (1): B0
-// CHECK: [ B2 ]
-// CHECK: 1:
-// CHECK: 2: A b;
-// CHECK: 3: [B2.2].~A() (Implicit destructor)
-// CHECK: 4: [B6.4].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B1
-// CHECK: [ B3 ]
-// CHECK: 1: [B6.4].~A() (Implicit destructor)
-// CHECK: T: goto l1;
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B1
-// CHECK: [ B4 ]
-// CHECK: 1: UV
-// CHECK: 2: [B4.1]
-// CHECK: T: if [B4.2]
-// CHECK: Predecessors (1): B6
-// CHECK: Successors (2): B3 B2
-// CHECK: [ B5 ]
-// CHECK: 1: [B6.4].~A() (Implicit destructor)
-// CHECK: 2: [B6.2].~A() (Implicit destructor)
-// CHECK: T: goto l0;
-// CHECK: Predecessors (1): B6
-// CHECK: Successors (1): B6
-// CHECK: [ B6 ]
-// CHECK: l0:
-// CHECK: 1:
-// CHECK: 2: A b;
-// CHECK: 3:
-// CHECK: 4: A a;
-// CHECK: 5: UV
-// CHECK: 6: [B6.5]
-// CHECK: T: if [B6.6]
-// CHECK: Predecessors (2): B7 B5
-// CHECK: Successors (2): B5 B4
-// CHECK: [ B7 ]
-// CHECK: 1:
-// CHECK: 2: A a;
-// CHECK: Predecessors (1): B8
-// CHECK: Successors (1): B6
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B5 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B4
-// CHECK: [ B1 ]
-// CHECK: 1: [B4.6].~A() (Implicit destructor)
-// CHECK: 2: [B4.2].~A() (Implicit destructor)
-// CHECK: Predecessors (2): B2 B3
-// CHECK: Successors (1): B0
-// CHECK: [ B2 ]
-// CHECK: 1:
-// CHECK: 2: A c;
-// CHECK: 3: [B2.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B1
-// CHECK: [ B3 ]
-// CHECK: 1:
-// CHECK: 2: A c;
-// CHECK: 3: [B3.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B1
-// CHECK: [ B4 ]
-// CHECK: 1:
-// CHECK: 2: A a;
-// CHECK: 3: a
-// CHECK: 4: [B4.3]
-// CHECK: 5: [B4.4]
-// CHECK: 6: A b = a;
-// CHECK: 7: b
-// CHECK: 8: [B4.7]
-// CHECK: 9: [B4.8].operator int
-// CHECK: 10: [B4.9]()
-// CHECK: 11: [B4.10]
-// CHECK: T: if [B4.11]
-// CHECK: Predecessors (1): B5
-// CHECK: Successors (2): B3 B2
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B9 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B8
-// CHECK: [ B1 ]
-// CHECK: 1: [B8.6].~A() (Implicit destructor)
-// CHECK: 2:
-// CHECK: 3: A e;
-// CHECK: 4: [B1.3].~A() (Implicit destructor)
-// CHECK: 5: [B8.2].~A() (Implicit destructor)
-// CHECK: Predecessors (2): B2 B5
-// CHECK: Successors (1): B0
-// CHECK: [ B2 ]
-// CHECK: 1:
-// CHECK: 2: A d;
-// CHECK: 3: [B2.2].~A() (Implicit destructor)
-// CHECK: 4: [B4.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B1
-// CHECK: [ B3 ]
-// CHECK: 1: return;
-// CHECK: 2: [B4.2].~A() (Implicit destructor)
-// CHECK: 3: [B8.6].~A() (Implicit destructor)
-// CHECK: 4: [B8.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B0
-// CHECK: [ B4 ]
-// CHECK: 1:
-// CHECK: 2: A c;
-// CHECK: 3: UV
-// CHECK: 4: [B4.3]
-// CHECK: T: if [B4.4]
-// CHECK: Predecessors (1): B8
-// CHECK: Successors (2): B3 B2
-// CHECK: [ B5 ]
-// CHECK: 1:
-// CHECK: 2: A d;
-// CHECK: 3: [B5.2].~A() (Implicit destructor)
-// CHECK: 4: [B7.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B7
-// CHECK: Successors (1): B1
-// CHECK: [ B6 ]
-// CHECK: 1: return;
-// CHECK: 2: [B7.2].~A() (Implicit destructor)
-// CHECK: 3: [B8.6].~A() (Implicit destructor)
-// CHECK: 4: [B8.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B7
-// CHECK: Successors (1): B0
-// CHECK: [ B7 ]
-// CHECK: 1:
-// CHECK: 2: A c;
-// CHECK: 3: UV
-// CHECK: 4: [B7.3]
-// CHECK: T: if [B7.4]
-// CHECK: Predecessors (1): B8
-// CHECK: Successors (2): B6 B5
-// CHECK: [ B8 ]
-// CHECK: 1:
-// CHECK: 2: A a;
-// CHECK: 3: a
-// CHECK: 4: [B8.3]
-// CHECK: 5: [B8.4]
-// CHECK: 6: A b = a;
-// CHECK: 7: b
-// CHECK: 8: [B8.7]
-// CHECK: 9: [B8.8].operator int
-// CHECK: 10: [B8.9]()
-// CHECK: 11: [B8.10]
-// CHECK: T: if [B8.11]
-// CHECK: Predecessors (1): B9
-// CHECK: Successors (2): B7 B4
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (3): B1 B3 B6
-// CHECK: Successors (0):
-// CHECK: [ B6 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B5
-// CHECK: [ B1 ]
-// CHECK: 1: [B2.4].~A() (Implicit destructor)
-// CHECK: 2: [B5.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (1): B0
-// CHECK: [ B2 ]
-// CHECK: 1: a
-// CHECK: 2: [B2.1]
-// CHECK: 3: [B2.2]
-// CHECK: 4: A b = a;
-// CHECK: 5: b
-// CHECK: 6: [B2.5]
-// CHECK: 7: [B2.6].operator int
-// CHECK: 8: [B2.7]()
-// CHECK: 9: [B2.8]
-// CHECK: T: while [B2.9]
-// CHECK: Predecessors (2): B3 B5
-// CHECK: Successors (2): B4 B1
-// CHECK: [ B3 ]
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B2
-// CHECK: [ B4 ]
-// CHECK: 1:
-// CHECK: 2: A c;
-// CHECK: 3: [B4.2].~A() (Implicit destructor)
-// CHECK: 4: [B2.4].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (1): B3
-// CHECK: [ B5 ]
-// CHECK: 1:
-// CHECK: 2: A a;
-// CHECK: Predecessors (1): B6
-// CHECK: Successors (1): B2
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B12 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B11
-// CHECK: [ B1 ]
-// CHECK: 1: [B2.4].~A() (Implicit destructor)
-// CHECK: 2:
-// CHECK: 3: A e;
-// CHECK: 4: [B1.3].~A() (Implicit destructor)
-// CHECK: 5: [B11.2].~A() (Implicit destructor)
-// CHECK: Predecessors (2): B9 B2
-// CHECK: Successors (1): B0
-// CHECK: [ B2 ]
-// CHECK: 1: a
-// CHECK: 2: [B2.1]
-// CHECK: 3: [B2.2]
-// CHECK: 4: A b = a;
-// CHECK: 5: b
-// CHECK: 6: [B2.5]
-// CHECK: 7: [B2.6].operator int
-// CHECK: 8: [B2.7]()
-// CHECK: 9: [B2.8]
-// CHECK: T: while [B2.9]
-// CHECK: Predecessors (2): B3 B11
-// CHECK: Successors (2): B10 B1
-// CHECK: [ B3 ]
-// CHECK: Predecessors (2): B4 B7
-// CHECK: Successors (1): B2
-// CHECK: [ B4 ]
-// CHECK: 1:
-// CHECK: 2: A d;
-// CHECK: 3: [B4.2].~A() (Implicit destructor)
-// CHECK: 4: [B10.2].~A() (Implicit destructor)
-// CHECK: 5: [B2.4].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B6
-// CHECK: Successors (1): B3
-// CHECK: [ B5 ]
-// CHECK: 1: return;
-// CHECK: 2: [B10.2].~A() (Implicit destructor)
-// CHECK: 3: [B2.4].~A() (Implicit destructor)
-// CHECK: 4: [B11.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B6
-// CHECK: Successors (1): B0
-// CHECK: [ B6 ]
-// CHECK: 1: UV
-// CHECK: 2: [B6.1]
-// CHECK: T: if [B6.2]
-// CHECK: Predecessors (1): B8
-// CHECK: Successors (2): B5 B4
-// CHECK: [ B7 ]
-// CHECK: 1: [B10.2].~A() (Implicit destructor)
-// CHECK: 2: [B2.4].~A() (Implicit destructor)
-// CHECK: T: continue;
-// CHECK: Predecessors (1): B8
-// CHECK: Successors (1): B3
-// CHECK: [ B8 ]
-// CHECK: 1: UV
-// CHECK: 2: [B8.1]
-// CHECK: T: if [B8.2]
-// CHECK: Predecessors (1): B10
-// CHECK: Successors (2): B7 B6
-// CHECK: [ B9 ]
-// CHECK: 1: [B10.2].~A() (Implicit destructor)
-// CHECK: T: break;
-// CHECK: Predecessors (1): B10
-// CHECK: Successors (1): B1
-// CHECK: [ B10 ]
-// CHECK: 1:
-// CHECK: 2: A c;
-// CHECK: 3: UV
-// CHECK: 4: [B10.3]
-// CHECK: T: if [B10.4]
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (2): B9 B8
-// CHECK: [ B11 ]
-// CHECK: 1:
-// CHECK: 2: A a;
-// CHECK: Predecessors (1): B12
-// CHECK: Successors (1): B2
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (2): B1 B5
-// CHECK: Successors (0):
-// CHECK: [ B4 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B2
-// CHECK: [ B1 ]
-// CHECK: 1: UV
-// CHECK: 2: [B1.1]
-// CHECK: T: do ... while [B1.2]
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (2): B3 B0
-// CHECK: [ B2 ]
-// CHECK: 1:
-// CHECK: 2: A a;
-// CHECK: 3: [B2.2].~A() (Implicit destructor)
-// CHECK: Predecessors (2): B3 B4
-// CHECK: Successors (1): B1
-// CHECK: [ B3 ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (1): B2
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B12 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B11
-// CHECK: [ B1 ]
-// CHECK: 1:
-// CHECK: 2: A d;
-// CHECK: 3: [B1.2].~A() (Implicit destructor)
-// CHECK: 4: [B11.2].~A() (Implicit destructor)
-// CHECK: Predecessors (2): B8 B2
-// CHECK: Successors (1): B0
-// CHECK: [ B2 ]
-// CHECK: 1: UV
-// CHECK: 2: [B2.1]
-// CHECK: T: do ... while [B2.2]
-// CHECK: Predecessors (2): B3 B6
-// CHECK: Successors (2): B10 B1
-// CHECK: [ B3 ]
-// CHECK: 1:
-// CHECK: 2: A c;
-// CHECK: 3: [B3.2].~A() (Implicit destructor)
-// CHECK: 4: [B9.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B5
-// CHECK: Successors (1): B2
-// CHECK: [ B4 ]
-// CHECK: 1: return;
-// CHECK: 2: [B9.2].~A() (Implicit destructor)
-// CHECK: 3: [B11.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B5
-// CHECK: Successors (1): B0
-// CHECK: [ B5 ]
-// CHECK: 1: UV
-// CHECK: 2: [B5.1]
-// CHECK: T: if [B5.2]
-// CHECK: Predecessors (1): B7
-// CHECK: Successors (2): B4 B3
-// CHECK: [ B6 ]
-// CHECK: 1: [B9.2].~A() (Implicit destructor)
-// CHECK: T: continue;
-// CHECK: Predecessors (1): B7
-// CHECK: Successors (1): B2
-// CHECK: [ B7 ]
-// CHECK: 1: UV
-// CHECK: 2: [B7.1]
-// CHECK: T: if [B7.2]
-// CHECK: Predecessors (1): B9
-// CHECK: Successors (2): B6 B5
-// CHECK: [ B8 ]
-// CHECK: 1: [B9.2].~A() (Implicit destructor)
-// CHECK: T: break;
-// CHECK: Predecessors (1): B9
-// CHECK: Successors (1): B1
-// CHECK: [ B9 ]
-// CHECK: 1:
-// CHECK: 2: A b;
-// CHECK: 3: UV
-// CHECK: 4: [B9.3]
-// CHECK: T: if [B9.4]
-// CHECK: Predecessors (2): B10 B11
-// CHECK: Successors (2): B8 B7
-// CHECK: [ B10 ]
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (1): B9
-// CHECK: [ B11 ]
-// CHECK: 1:
-// CHECK: 2: A a;
-// CHECK: Predecessors (1): B12
-// CHECK: Successors (1): B9
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (2): B1 B4
-// CHECK: Successors (0):
-// CHECK: [ B4 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B2
-// CHECK: [ B1 ]
-// CHECK: 1: [B2.6].~A() (Implicit destructor)
-// CHECK: 2: [B2.2].~A() (Implicit destructor)
-// CHECK: Predecessors (2): B3 B2
-// CHECK: Successors (1): B0
-// CHECK: [ B2 ]
-// CHECK: 1:
-// CHECK: 2: A a;
-// CHECK: 3: a
-// CHECK: 4: [B2.3]
-// CHECK: 5: [B2.4]
-// CHECK: 6: A b = a;
-// CHECK: 7: b
-// CHECK: 8: [B2.7]
-// CHECK: 9: [B2.8].operator int
-// CHECK: 10: [B2.9]()
-// CHECK: T: switch [B2.10]
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B1
-// CHECK: [ B3 ]
-// CHECK: 1:
-// CHECK: 2: A c;
-// CHECK: 3: [B3.2].~A() (Implicit destructor)
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B1
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B9 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B2
-// CHECK: [ B1 ]
-// CHECK: 1: [B2.6].~A() (Implicit destructor)
-// CHECK: 2:
-// CHECK: 3: A g;
-// CHECK: 4: [B1.3].~A() (Implicit destructor)
-// CHECK: 5: [B2.2].~A() (Implicit destructor)
-// CHECK: Predecessors (3): B3 B7 B2
-// CHECK: Successors (1): B0
-// CHECK: [ B2 ]
-// CHECK: 1:
-// CHECK: 2: A a;
-// CHECK: 3: a
-// CHECK: 4: [B2.3]
-// CHECK: 5: [B2.4]
-// CHECK: 6: A b = a;
-// CHECK: 7: b
-// CHECK: 8: [B2.7]
-// CHECK: 9: [B2.8].operator int
-// CHECK: 10: [B2.9]()
-// CHECK: T: switch [B2.10]
-// CHECK: Predecessors (1): B9
-// CHECK: Successors (3): B3 B8
+// CHECK: [B1 (ENTRY)]
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B1 (ENTRY)]
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: 1
+// CHECK: 2: return [B1.1];
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: a
+// CHECK: 4: [B1.3] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 5: const A &b = a;
+// CHECK: 6: A() (CXXConstructExpr, class A)
+// CHECK: 7: [B1.6] (BindTemporary)
+// CHECK: 8: [B1.7] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 9: [B1.8]
+// CHECK: 10: const A &c = A();
+// CHECK: 11: [B1.10].~A() (Implicit destructor)
+// CHECK: 12: [B1.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: (CXXConstructExpr, class A [2])
+// CHECK: 2: A a[2];
+// CHECK: 3: (CXXConstructExpr, class A [0])
+// CHECK: 4: A b[0];
+// CHECK: 5: [B1.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: (CXXConstructExpr, class A)
+// CHECK: 4: A c;
+// CHECK: 5: (CXXConstructExpr, class A)
+// CHECK: 6: A d;
+// CHECK: 7: [B1.6].~A() (Implicit destructor)
+// CHECK: 8: [B1.4].~A() (Implicit destructor)
+// CHECK: 9: (CXXConstructExpr, class A)
+// CHECK: 10: A b;
+// CHECK: 11: [B1.10].~A() (Implicit destructor)
+// CHECK: 12: [B1.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B4 (ENTRY)]
+// CHECK: Succs (1): B3
+// CHECK: [B1]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: [B1.2].~A() (Implicit destructor)
+// CHECK: 4: [B3.4].~A() (Implicit destructor)
+// CHECK: 5: [B3.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: return;
+// CHECK: 2: [B3.4].~A() (Implicit destructor)
+// CHECK: 3: [B3.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B3
+// CHECK: Succs (1): B0
+// CHECK: [B3]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: (CXXConstructExpr, class A)
+// CHECK: 4: A b;
+// CHECK: 5: UV
+// CHECK: 6: [B3.5] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B3.6]
+// CHECK: Preds (1): B4
+// CHECK: Succs (2): B2 B1
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (2): B1 B2
+// CHECK: [B8 (ENTRY)]
+// CHECK: Succs (1): B7
+// CHECK: [B1]
+// CHECK: l1:
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: [B1.2].~A() (Implicit destructor)
+// CHECK: 4: [B6.2].~A() (Implicit destructor)
+// CHECK: 5: [B7.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A b;
+// CHECK: 3: [B2.2].~A() (Implicit destructor)
+// CHECK: 4: [B6.4].~A() (Implicit destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: [B6.4].~A() (Implicit destructor)
+// CHECK: T: goto l1;
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: UV
+// CHECK: 2: [B4.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B4.2]
+// CHECK: Preds (1): B6
+// CHECK: Succs (2): B3 B2
+// CHECK: [B5]
+// CHECK: 1: [B6.4].~A() (Implicit destructor)
+// CHECK: 2: [B6.2].~A() (Implicit destructor)
+// CHECK: T: goto l0;
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B6
+// CHECK: [B6]
+// CHECK: l0:
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A b;
+// CHECK: 3: (CXXConstructExpr, class A)
+// CHECK: 4: A a;
+// CHECK: 5: UV
+// CHECK: 6: [B6.5] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B6.6]
+// CHECK: Preds (2): B7 B5
+// CHECK: Succs (2): B5 B4
+// CHECK: [B7]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: Preds (1): B8
+// CHECK: Succs (1): B6
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B5 (ENTRY)]
+// CHECK: Succs (1): B4
+// CHECK: [B1]
+// CHECK: 1: [B4.6].~A() (Implicit destructor)
+// CHECK: 2: [B4.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: [B2.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: [B3.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: a
+// CHECK: 4: [B4.3] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 5: [B4.4] (CXXConstructExpr, class A)
+// CHECK: 6: A b = a;
+// CHECK: 7: b
+// CHECK: 8: [B4.7] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 9: [B4.8].operator int
+// CHECK: 10: [B4.9]()
+// CHECK: 11: [B4.10] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 12: [B4.11] (ImplicitCastExpr, IntegralToBoolean, _Bool)
+// CHECK: T: if [B4.12]
+// CHECK: Preds (1): B5
+// CHECK: Succs (2): B3 B2
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B9 (ENTRY)]
+// CHECK: Succs (1): B8
+// CHECK: [B1]
+// CHECK: 1: [B8.6].~A() (Implicit destructor)
+// CHECK: 2: (CXXConstructExpr, class A)
+// CHECK: 3: A e;
+// CHECK: 4: [B1.3].~A() (Implicit destructor)
+// CHECK: 5: [B8.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B2 B5
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A d;
+// CHECK: 3: [B2.2].~A() (Implicit destructor)
+// CHECK: 4: [B4.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: return;
+// CHECK: 2: [B4.2].~A() (Implicit destructor)
+// CHECK: 3: [B8.6].~A() (Implicit destructor)
+// CHECK: 4: [B8.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B0
+// CHECK: [B4]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: UV
+// CHECK: 4: [B4.3] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B4.4]
+// CHECK: Preds (1): B8
+// CHECK: Succs (2): B3 B2
+// CHECK: [B5]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A d;
+// CHECK: 3: [B5.2].~A() (Implicit destructor)
+// CHECK: 4: [B7.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B1
+// CHECK: [B6]
+// CHECK: 1: return;
+// CHECK: 2: [B7.2].~A() (Implicit destructor)
+// CHECK: 3: [B8.6].~A() (Implicit destructor)
+// CHECK: 4: [B8.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B0
+// CHECK: [B7]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: UV
+// CHECK: 4: [B7.3] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B7.4]
+// CHECK: Preds (1): B8
+// CHECK: Succs (2): B6 B5
+// CHECK: [B8]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: a
+// CHECK: 4: [B8.3] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 5: [B8.4] (CXXConstructExpr, class A)
+// CHECK: 6: A b = a;
+// CHECK: 7: b
+// CHECK: 8: [B8.7] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 9: [B8.8].operator int
+// CHECK: 10: [B8.9]()
+// CHECK: 11: [B8.10] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 12: [B8.11] (ImplicitCastExpr, IntegralToBoolean, _Bool)
+// CHECK: T: if [B8.12]
+// CHECK: Preds (1): B9
+// CHECK: Succs (2): B7 B4
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (3): B1 B3 B6
+// CHECK: [B6 (ENTRY)]
+// CHECK: Succs (1): B5
+// CHECK: [B1]
+// CHECK: 1: [B2.4].~A() (Implicit destructor)
+// CHECK: 2: [B5.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: a
+// CHECK: 2: [B2.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B2.2] (CXXConstructExpr, class A)
+// CHECK: 4: A b = a;
+// CHECK: 5: b
+// CHECK: 6: [B2.5] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 7: [B2.6].operator int
+// CHECK: 8: [B2.7]()
+// CHECK: 9: [B2.8] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 10: [B2.9] (ImplicitCastExpr, IntegralToBoolean, _Bool)
+// CHECK: T: while [B2.10]
+// CHECK: Preds (2): B3 B5
+// CHECK: Succs (2): B4 B1
+// CHECK: [B3]
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B2
+// CHECK: [B4]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: [B4.2].~A() (Implicit destructor)
+// CHECK: 4: [B2.4].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B3
+// CHECK: [B5]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B2
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B12 (ENTRY)]
+// CHECK: Succs (1): B11
+// CHECK: [B1]
+// CHECK: 1: [B2.4].~A() (Implicit destructor)
+// CHECK: 2: (CXXConstructExpr, class A)
+// CHECK: 3: A e;
+// CHECK: 4: [B1.3].~A() (Implicit destructor)
+// CHECK: 5: [B11.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B9 B2
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: a
+// CHECK: 2: [B2.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B2.2] (CXXConstructExpr, class A)
+// CHECK: 4: A b = a;
+// CHECK: 5: b
+// CHECK: 6: [B2.5] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 7: [B2.6].operator int
+// CHECK: 8: [B2.7]()
+// CHECK: 9: [B2.8] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 10: [B2.9] (ImplicitCastExpr, IntegralToBoolean, _Bool)
+// CHECK: T: while [B2.10]
+// CHECK: Preds (2): B3 B11
+// CHECK: Succs (2): B10 B1
+// CHECK: [B3]
+// CHECK: Preds (2): B4 B7
+// CHECK: Succs (1): B2
+// CHECK: [B4]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A d;
+// CHECK: 3: [B4.2].~A() (Implicit destructor)
+// CHECK: 4: [B10.2].~A() (Implicit destructor)
+// CHECK: 5: [B2.4].~A() (Implicit destructor)
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B3
+// CHECK: [B5]
+// CHECK: 1: return;
+// CHECK: 2: [B10.2].~A() (Implicit destructor)
+// CHECK: 3: [B2.4].~A() (Implicit destructor)
+// CHECK: 4: [B11.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B0
+// CHECK: [B6]
+// CHECK: 1: UV
+// CHECK: 2: [B6.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B6.2]
+// CHECK: Preds (1): B8
+// CHECK: Succs (2): B5 B4
+// CHECK: [B7]
+// CHECK: 1: [B10.2].~A() (Implicit destructor)
+// CHECK: 2: [B2.4].~A() (Implicit destructor)
+// CHECK: T: continue;
+// CHECK: Preds (1): B8
+// CHECK: Succs (1): B3
+// CHECK: [B8]
+// CHECK: 1: UV
+// CHECK: 2: [B8.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B8.2]
+// CHECK: Preds (1): B10
+// CHECK: Succs (2): B7 B6
+// CHECK: [B9]
+// CHECK: 1: [B10.2].~A() (Implicit destructor)
+// CHECK: T: break;
+// CHECK: Preds (1): B10
+// CHECK: Succs (1): B1
+// CHECK: [B10]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: UV
+// CHECK: 4: [B10.3] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B10.4]
+// CHECK: Preds (1): B2
+// CHECK: Succs (2): B9 B8
+// CHECK: [B11]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: Preds (1): B12
+// CHECK: Succs (1): B2
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (2): B1 B5
+// CHECK: [B4 (ENTRY)]
+// CHECK: Succs (1): B2
+// CHECK: [B1]
+// CHECK: 1: UV
+// CHECK: 2: [B1.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: do ... while [B1.2]
+// CHECK: Preds (1): B2
+// CHECK: Succs (2): B3 B0
+// CHECK: [B2]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: [B2.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B3 B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: Preds (1): B1
+// CHECK: Succs (1): B2
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B12 (ENTRY)]
+// CHECK: Succs (1): B11
+// CHECK: [B1]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A d;
+// CHECK: 3: [B1.2].~A() (Implicit destructor)
+// CHECK: 4: [B11.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B8 B2
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: UV
+// CHECK: 2: [B2.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: do ... while [B2.2]
+// CHECK: Preds (2): B3 B6
+// CHECK: Succs (2): B10 B1
+// CHECK: [B3]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: [B3.2].~A() (Implicit destructor)
+// CHECK: 4: [B9.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B5
+// CHECK: Succs (1): B2
+// CHECK: [B4]
+// CHECK: 1: return;
+// CHECK: 2: [B9.2].~A() (Implicit destructor)
+// CHECK: 3: [B11.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B5
+// CHECK: Succs (1): B0
+// CHECK: [B5]
+// CHECK: 1: UV
+// CHECK: 2: [B5.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B5.2]
+// CHECK: Preds (1): B7
+// CHECK: Succs (2): B4 B3
+// CHECK: [B6]
+// CHECK: 1: [B9.2].~A() (Implicit destructor)
+// CHECK: T: continue;
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B2
+// CHECK: [B7]
+// CHECK: 1: UV
+// CHECK: 2: [B7.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B7.2]
+// CHECK: Preds (1): B9
+// CHECK: Succs (2): B6 B5
+// CHECK: [B8]
+// CHECK: 1: [B9.2].~A() (Implicit destructor)
+// CHECK: T: break;
+// CHECK: Preds (1): B9
+// CHECK: Succs (1): B1
+// CHECK: [B9]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A b;
+// CHECK: 3: UV
+// CHECK: 4: [B9.3] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B9.4]
+// CHECK: Preds (2): B10 B11
+// CHECK: Succs (2): B8 B7
+// CHECK: [B10]
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B9
+// CHECK: [B11]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: Preds (1): B12
+// CHECK: Succs (1): B9
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (2): B1 B4
+// CHECK: [B4 (ENTRY)]
+// CHECK: Succs (1): B2
+// CHECK: [B1]
+// CHECK: 1: [B2.6].~A() (Implicit destructor)
+// CHECK: 2: [B2.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B3 B2
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: a
+// CHECK: 4: [B2.3] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 5: [B2.4] (CXXConstructExpr, class A)
+// CHECK: 6: A b = a;
+// CHECK: 7: b
+// CHECK: 8: [B2.7] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 9: [B2.8].operator int
+// CHECK: 10: [B2.9]()
+// CHECK: 11: [B2.10] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: T: switch [B2.11]
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: [B3.2].~A() (Implicit destructor)
+// CHECK: Succs (1): B1
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B9 (ENTRY)]
+// CHECK: Succs (1): B2
+// CHECK: [B1]
+// CHECK: 1: [B2.6].~A() (Implicit destructor)
+// CHECK: 2: (CXXConstructExpr, class A)
+// CHECK: 3: A g;
+// CHECK: 4: [B1.3].~A() (Implicit destructor)
+// CHECK: 5: [B2.2].~A() (Implicit destructor)
+// CHECK: Preds (3): B3 B7 B2
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: a
+// CHECK: 4: [B2.3] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 5: [B2.4] (CXXConstructExpr, class A)
+// CHECK: 6: A b = a;
+// CHECK: 7: b
+// CHECK: 8: [B2.7] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 9: [B2.8].operator int
+// CHECK: 10: [B2.9]()
+// CHECK: 11: [B2.10] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: T: switch [B2.11]
+// CHECK: Preds (1): B9
+// CHECK: Succs (3): B3 B8
// CHECK: B1
-// CHECK: [ B3 ]
-// CHECK: case 1:
-// CHECK: T: break;
-// CHECK: Predecessors (2): B2 B4
-// CHECK: Successors (1): B1
-// CHECK: [ B4 ]
-// CHECK: 1:
-// CHECK: 2: A f;
-// CHECK: 3: [B4.2].~A() (Implicit destructor)
-// CHECK: 4: [B8.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B6
-// CHECK: Successors (1): B3
-// CHECK: [ B5 ]
-// CHECK: 1: return;
-// CHECK: 2: [B8.2].~A() (Implicit destructor)
-// CHECK: 3: [B2.6].~A() (Implicit destructor)
-// CHECK: 4: [B2.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B6
-// CHECK: Successors (1): B0
-// CHECK: [ B6 ]
-// CHECK: 1: UV
-// CHECK: 2: [B6.1]
-// CHECK: T: if [B6.2]
-// CHECK: Predecessors (1): B8
-// CHECK: Successors (2): B5 B4
-// CHECK: [ B7 ]
-// CHECK: 1: [B8.2].~A() (Implicit destructor)
-// CHECK: T: break;
-// CHECK: Predecessors (1): B8
-// CHECK: Successors (1): B1
-// CHECK: [ B8 ]
-// CHECK: case 0:
-// CHECK: 1:
-// CHECK: 2: A c;
-// CHECK: 3: UV
-// CHECK: 4: [B8.3]
-// CHECK: T: if [B8.4]
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (2): B7 B6
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (2): B1 B5
-// CHECK: Successors (0):
-// CHECK: [ B6 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B5
-// CHECK: [ B1 ]
-// CHECK: 1: [B2.4].~A() (Implicit destructor)
-// CHECK: 2: [B5.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (1): B0
-// CHECK: [ B2 ]
-// CHECK: 1: a
-// CHECK: 2: [B2.1]
-// CHECK: 3: [B2.2]
-// CHECK: 4: A b = a;
-// CHECK: 5: b
-// CHECK: 6: [B2.5]
-// CHECK: 7: [B2.6].operator int
-// CHECK: 8: [B2.7]()
-// CHECK: 9: [B2.8]
-// CHECK: T: for (...; [B2.9]; )
-// CHECK: Predecessors (2): B3 B5
-// CHECK: Successors (2): B4 B1
-// CHECK: [ B3 ]
-// CHECK: 1: [B2.4].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B2
-// CHECK: [ B4 ]
-// CHECK: 1:
-// CHECK: 2: A c;
-// CHECK: 3: [B4.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (1): B3
-// CHECK: [ B5 ]
-// CHECK: 1:
-// CHECK: 2: A a;
-// CHECK: Predecessors (1): B6
-// CHECK: Successors (1): B2
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B12 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B11
-// CHECK: [ B1 ]
-// CHECK: 1: [B2.4].~A() (Implicit destructor)
-// CHECK: 2: [B11.4].~A() (Implicit destructor)
-// CHECK: 3:
-// CHECK: 4: A f;
-// CHECK: 5: [B1.4].~A() (Implicit destructor)
-// CHECK: 6: [B11.2].~A() (Implicit destructor)
-// CHECK: Predecessors (2): B9 B2
-// CHECK: Successors (1): B0
-// CHECK: [ B2 ]
-// CHECK: 1: b
-// CHECK: 2: [B2.1]
-// CHECK: 3: [B2.2]
-// CHECK: 4: A c = b;
-// CHECK: 5: c
-// CHECK: 6: [B2.5]
-// CHECK: 7: [B2.6].operator int
-// CHECK: 8: [B2.7]()
-// CHECK: 9: [B2.8]
-// CHECK: T: for (...; [B2.9]; )
-// CHECK: Predecessors (2): B3 B11
-// CHECK: Successors (2): B10 B1
-// CHECK: [ B3 ]
-// CHECK: 1: [B2.4].~A() (Implicit destructor)
-// CHECK: Predecessors (2): B4 B7
-// CHECK: Successors (1): B2
-// CHECK: [ B4 ]
-// CHECK: 1:
-// CHECK: 2: A e;
-// CHECK: 3: [B4.2].~A() (Implicit destructor)
-// CHECK: 4: [B10.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B6
-// CHECK: Successors (1): B3
-// CHECK: [ B5 ]
-// CHECK: 1: return;
-// CHECK: 2: [B10.2].~A() (Implicit destructor)
-// CHECK: 3: [B2.4].~A() (Implicit destructor)
-// CHECK: 4: [B11.4].~A() (Implicit destructor)
-// CHECK: 5: [B11.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B6
-// CHECK: Successors (1): B0
-// CHECK: [ B6 ]
-// CHECK: 1: UV
-// CHECK: 2: [B6.1]
-// CHECK: T: if [B6.2]
-// CHECK: Predecessors (1): B8
-// CHECK: Successors (2): B5 B4
-// CHECK: [ B7 ]
-// CHECK: 1: [B10.2].~A() (Implicit destructor)
-// CHECK: T: continue;
-// CHECK: Predecessors (1): B8
-// CHECK: Successors (1): B3
-// CHECK: [ B8 ]
-// CHECK: 1: UV
-// CHECK: 2: [B8.1]
-// CHECK: T: if [B8.2]
-// CHECK: Predecessors (1): B10
-// CHECK: Successors (2): B7 B6
-// CHECK: [ B9 ]
-// CHECK: 1: [B10.2].~A() (Implicit destructor)
-// CHECK: T: break;
-// CHECK: Predecessors (1): B10
-// CHECK: Successors (1): B1
-// CHECK: [ B10 ]
-// CHECK: 1:
-// CHECK: 2: A d;
-// CHECK: 3: UV
-// CHECK: 4: [B10.3]
-// CHECK: T: if [B10.4]
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (2): B9 B8
-// CHECK: [ B11 ]
-// CHECK: 1:
-// CHECK: 2: A a;
-// CHECK: 3:
-// CHECK: 4: A b;
-// CHECK: Predecessors (1): B12
-// CHECK: Successors (1): B2
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (2): B1 B5
-// CHECK: Successors (0):
-// CHECK: [ B3 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B0
-// CHECK: [ B1 ]
-// CHECK: T: try ...
-// CHECK: Predecessors (0):
-// CHECK: Successors (2): B2 B0
-// CHECK: [ B2 ]
-// CHECK: catch (const A &e):
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (1): B0
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (3): B2 B1 B3
-// CHECK: Successors (0):
-// CHECK: [ B3 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B0
-// CHECK: [ B1 ]
-// CHECK: T: try ...
-// CHECK: Predecessors (0):
-// CHECK: Successors (2): B2 B0
-// CHECK: [ B2 ]
-// CHECK: catch (A e):
-// CHECK: 1: .~A() (Implicit destructor)
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (1): B0
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (3): B2 B1 B3
-// CHECK: Successors (0):
-
+// CHECK: [B3]
+// CHECK: case 1:
+// CHECK: T: break;
+// CHECK: Preds (2): B2 B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A f;
+// CHECK: 3: [B4.2].~A() (Implicit destructor)
+// CHECK: 4: [B8.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B3
+// CHECK: [B5]
+// CHECK: 1: return;
+// CHECK: 2: [B8.2].~A() (Implicit destructor)
+// CHECK: 3: [B2.6].~A() (Implicit destructor)
+// CHECK: 4: [B2.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B0
+// CHECK: [B6]
+// CHECK: 1: UV
+// CHECK: 2: [B6.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B6.2]
+// CHECK: Preds (1): B8
+// CHECK: Succs (2): B5 B4
+// CHECK: [B7]
+// CHECK: 1: [B8.2].~A() (Implicit destructor)
+// CHECK: T: break;
+// CHECK: Preds (1): B8
+// CHECK: Succs (1): B1
+// CHECK: [B8]
+// CHECK: case 0:
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: UV
+// CHECK: 4: [B8.3] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B8.4]
+// CHECK: Preds (1): B2
+// CHECK: Succs (2): B7 B6
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (2): B1 B5
+// CHECK: [B6 (ENTRY)]
+// CHECK: Succs (1): B5
+// CHECK: [B1]
+// CHECK: 1: [B2.4].~A() (Implicit destructor)
+// CHECK: 2: [B5.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: a
+// CHECK: 2: [B2.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B2.2] (CXXConstructExpr, class A)
+// CHECK: 4: A b = a;
+// CHECK: 5: b
+// CHECK: 6: [B2.5] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 7: [B2.6].operator int
+// CHECK: 8: [B2.7]()
+// CHECK: 9: [B2.8] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 10: [B2.9] (ImplicitCastExpr, IntegralToBoolean, _Bool)
+// CHECK: T: for (...; [B2.10]; )
+// CHECK: Preds (2): B3 B5
+// CHECK: Succs (2): B4 B1
+// CHECK: [B3]
+// CHECK: 1: [B2.4].~A() (Implicit destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B2
+// CHECK: [B4]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: [B4.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B3
+// CHECK: [B5]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B2
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B12 (ENTRY)]
+// CHECK: Succs (1): B11
+// CHECK: [B1]
+// CHECK: 1: [B2.4].~A() (Implicit destructor)
+// CHECK: 2: [B11.4].~A() (Implicit destructor)
+// CHECK: 3: (CXXConstructExpr, class A)
+// CHECK: 4: A f;
+// CHECK: 5: [B1.4].~A() (Implicit destructor)
+// CHECK: 6: [B11.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B9 B2
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: b
+// CHECK: 2: [B2.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B2.2] (CXXConstructExpr, class A)
+// CHECK: 4: A c = b;
+// CHECK: 5: c
+// CHECK: 6: [B2.5] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 7: [B2.6].operator int
+// CHECK: 8: [B2.7]()
+// CHECK: 9: [B2.8] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 10: [B2.9] (ImplicitCastExpr, IntegralToBoolean, _Bool)
+// CHECK: T: for (...; [B2.10]; )
+// CHECK: Preds (2): B3 B11
+// CHECK: Succs (2): B10 B1
+// CHECK: [B3]
+// CHECK: 1: [B2.4].~A() (Implicit destructor)
+// CHECK: Preds (2): B4 B7
+// CHECK: Succs (1): B2
+// CHECK: [B4]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A e;
+// CHECK: 3: [B4.2].~A() (Implicit destructor)
+// CHECK: 4: [B10.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B3
+// CHECK: [B5]
+// CHECK: 1: return;
+// CHECK: 2: [B10.2].~A() (Implicit destructor)
+// CHECK: 3: [B2.4].~A() (Implicit destructor)
+// CHECK: 4: [B11.4].~A() (Implicit destructor)
+// CHECK: 5: [B11.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B0
+// CHECK: [B6]
+// CHECK: 1: UV
+// CHECK: 2: [B6.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B6.2]
+// CHECK: Preds (1): B8
+// CHECK: Succs (2): B5 B4
+// CHECK: [B7]
+// CHECK: 1: [B10.2].~A() (Implicit destructor)
+// CHECK: T: continue;
+// CHECK: Preds (1): B8
+// CHECK: Succs (1): B3
+// CHECK: [B8]
+// CHECK: 1: UV
+// CHECK: 2: [B8.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B8.2]
+// CHECK: Preds (1): B10
+// CHECK: Succs (2): B7 B6
+// CHECK: [B9]
+// CHECK: 1: [B10.2].~A() (Implicit destructor)
+// CHECK: T: break;
+// CHECK: Preds (1): B10
+// CHECK: Succs (1): B1
+// CHECK: [B10]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A d;
+// CHECK: 3: UV
+// CHECK: 4: [B10.3] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B10.4]
+// CHECK: Preds (1): B2
+// CHECK: Succs (2): B9 B8
+// CHECK: [B11]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: (CXXConstructExpr, class A)
+// CHECK: 4: A b;
+// CHECK: Preds (1): B12
+// CHECK: Succs (1): B2
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (2): B1 B5
+// CHECK: [B3 (ENTRY)]
+// CHECK: Succs (1): B0
+// CHECK: [B1]
+// CHECK: T: try ...
+// CHECK: Succs (2): B2 B0
+// CHECK: [B2]
+// CHECK: catch (const A &e):
+// CHECK: 1: catch (const A &e) {
+// CHECK: }
+// CHECK: Preds (1): B1
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (3): B2 B1 B3
+// CHECK: [B3 (ENTRY)]
+// CHECK: Succs (1): B0
+// CHECK: [B1]
+// CHECK: T: try ...
+// CHECK: Succs (2): B2 B0
+// CHECK: [B2]
+// CHECK: catch (A e):
+// CHECK: 1: catch (A e) {
+// CHECK: }
+// CHECK: 2: [B2.1].~A() (Implicit destructor)
+// CHECK: Preds (1): B1
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (3): B2 B1 B3
diff --git a/test/Analysis/bool-assignment.cpp b/test/Analysis/bool-assignment.cpp
new file mode 100644
index 000000000000..e57312999449
--- /dev/null
+++ b/test/Analysis/bool-assignment.cpp
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core.BoolAssignment -analyzer-store=region -verify %s
+
+// Test C++'s bool
+
+void test_cppbool_initialization(int y) {
+ if (y < 0) {
+ bool x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ bool x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ bool x = y; // no-warning
+}
+
+void test_cppbool_assignment(int y) {
+ bool x = 0; // no-warning
+ if (y < 0) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ x = y; // no-warning
+}
+
+// Test Objective-C's BOOL
+
+typedef signed char BOOL;
+
+void test_BOOL_initialization(int y) {
+ if (y < 0) {
+ BOOL x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ BOOL x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ BOOL x = y; // no-warning
+}
+
+void test_BOOL_assignment(int y) {
+ BOOL x = 0; // no-warning
+ if (y < 0) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ x = y; // no-warning
+}
+
+
+// Test MacTypes.h's Boolean
+
+typedef unsigned char Boolean;
+
+void test_Boolean_initialization(int y) {
+ if (y < 0) {
+ Boolean x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ Boolean x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ Boolean x = y; // no-warning
+}
+
+void test_Boolean_assignment(int y) {
+ Boolean x = 0; // no-warning
+ if (y < 0) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ x = y; // no-warning
+}
diff --git a/test/Analysis/bool-assignment2.c b/test/Analysis/bool-assignment2.c
new file mode 100644
index 000000000000..9de26cf34958
--- /dev/null
+++ b/test/Analysis/bool-assignment2.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -std=c99 -analyze -analyzer-checker=core,experimental.core.BoolAssignment -analyzer-store=region -verify %s
+
+// Test stdbool.h's _Bool
+
+// Prior to C99, stdbool.h uses this typedef, but even in ANSI C mode, _Bool
+// appears to be defined.
+
+// #if __STDC_VERSION__ < 199901L
+// typedef int _Bool;
+// #endif
+
+void test_stdbool_initialization(int y) {
+ if (y < 0) {
+ _Bool x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ _Bool x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ _Bool x = y; // no-warning
+}
+
+void test_stdbool_assignment(int y) {
+ _Bool x = 0; // no-warning
+ if (y < 0) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ x = y; // no-warning
+}
diff --git a/test/Analysis/bstring.c b/test/Analysis/bstring.c
index e23059fcec48..833c917613ed 100644
--- a/test/Analysis/bstring.c
+++ b/test/Analysis/bstring.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.unix.CString -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,experimental.unix.CString -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,experimental.unix.CString -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=core,experimental.unix.CString -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,experimental.unix.cstring -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,experimental.unix.cstring -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,unix.cstring,experimental.unix.cstring -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=core,unix.cstring.NullArg,experimental.unix.cstring.OutOfBounds,experimental.unix.cstring.BufferOverlap,experimental.unix.cstring.NotNullTerminated -analyzer-store=region -Wno-null-dereference -verify %s
//===----------------------------------------------------------------------===
// Declarations
diff --git a/test/Analysis/casts.m b/test/Analysis/casts.m
index d9700fe5c754..6f19211976b7 100644
--- a/test/Analysis/casts.m
+++ b/test/Analysis/casts.m
@@ -33,9 +33,10 @@ typedef enum {
RDR10087620Enum elem;
}
@property (readwrite, nonatomic) RDR10087620Enum elem;
+@end
+
static void
adium_media_ready_cb(RDR10087620 *InObj)
{
InObj.elem |= EEOne;
}
-@end \ No newline at end of file
diff --git a/test/Analysis/check-deserialization.cpp b/test/Analysis/check-deserialization.cpp
new file mode 100644
index 000000000000..2b0bce2b9ad5
--- /dev/null
+++ b/test/Analysis/check-deserialization.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -error-on-deserialized-decl S1_method -include-pch %t -analyze -analyzer-checker=core %s
+// RUN: %clang_cc1 -include-pch %t -analyze -analyzer-checker=core -verify %s
+
+#ifndef HEADER
+#define HEADER
+// Header.
+
+void S1_method(); // This should not be deserialized.
+
+
+#else
+// Using the header.
+
+int test() {
+ int x = 0;
+ return 5/x; //expected-warning {{Division by zero}}
+}
+
+#endif
diff --git a/test/Analysis/coverage.c b/test/Analysis/coverage.c
new file mode 100644
index 000000000000..73d78da18644
--- /dev/null
+++ b/test/Analysis/coverage.c
@@ -0,0 +1,94 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -analyzer-max-loop 4 -verify %s
+#include "system-header-simulator.h"
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+
+static int another_function(int *y) {
+ if (*y > 0)
+ return *y;
+ return 0;
+}
+
+static void function_which_doesnt_give_up(int **x) {
+ *x = 0;
+}
+
+static void function_which_gives_up(int *x) {
+ for (int i = 0; i < 5; ++i)
+ (*x)++;
+}
+
+static void function_which_gives_up_nested(int *x) {
+ function_which_gives_up(x);
+ for (int i = 0; i < 5; ++i)
+ (*x)++;
+}
+
+static void function_which_doesnt_give_up_nested(int *x, int *y) {
+ *y = another_function(x);
+ function_which_gives_up(x);
+}
+
+void coverage1(int *x) {
+ function_which_gives_up(x);
+ char *m = (char*)malloc(12); // expected-warning {{potential leak}}
+}
+
+void coverage2(int *x) {
+ if (x) {
+ function_which_gives_up(x);
+ char *m = (char*)malloc(12);// expected-warning {{potential leak}}
+ }
+}
+
+void coverage3(int *x) {
+ x++;
+ function_which_gives_up(x);
+ char *m = (char*)malloc(12);// expected-warning {{potential leak}}
+}
+
+void coverage4(int *x) {
+ *x += another_function(x);
+ function_which_gives_up(x);
+ char *m = (char*)malloc(12);// expected-warning {{potential leak}}
+}
+
+void coverage5(int *x) {
+ for (int i = 0; i<7; ++i)
+ function_which_gives_up(x);
+ // The root function gives up here.
+ char *m = (char*)malloc(12); // no-warning
+}
+
+void coverage6(int *x) {
+ for (int i = 0; i<3; ++i) {
+ function_which_gives_up(x);
+ }
+ char *m = (char*)malloc(12); // expected-warning {{potential leak}}
+}
+
+int coverage7_inline(int *i) {
+ function_which_doesnt_give_up(&i);
+ return *i; // expected-warning {{Dereference}}
+}
+
+void coverage8(int *x) {
+ int y;
+ function_which_doesnt_give_up_nested(x, &y);
+ y = (*x)/y; // expected-warning {{Division by zero}}
+ char *m = (char*)malloc(12); // expected-warning {{potential leak}}
+}
+
+void function_which_gives_up_settonull(int **x) {
+ *x = 0;
+ int y = 0;
+ for (int i = 0; i < 5; ++i)
+ y++;
+}
+
+void coverage9(int *x) {
+ int y = 5;
+ function_which_gives_up_settonull(&x);
+ y = (*x); // no warning
+}
diff --git a/test/Analysis/cstring-syntax-cxx.cpp b/test/Analysis/cstring-syntax-cxx.cpp
new file mode 100644
index 000000000000..f8975abc185b
--- /dev/null
+++ b/test/Analysis/cstring-syntax-cxx.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix.cstring.BadSizeArg -analyzer-store=region -verify %s
+
+// Ensure we don't crash on C++ declarations with special names.
+struct X {
+ X(int i): i(i) {}
+ int i;
+};
+
+X operator+(X a, X b) {
+ return X(a.i + b.i);
+}
+
+void test(X a, X b) {
+ X c = a + b;
+}
+
diff --git a/test/Analysis/cstring-syntax.c b/test/Analysis/cstring-syntax.c
new file mode 100644
index 000000000000..64ecb67008f8
--- /dev/null
+++ b/test/Analysis/cstring-syntax.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix.cstring.BadSizeArg -analyzer-store=region -Wno-strlcpy-strlcat-size -Wno-sizeof-array-argument -Wno-sizeof-pointer-memaccess -verify %s
+
+typedef __SIZE_TYPE__ size_t;
+char *strncat(char *, const char *, size_t);
+size_t strlen (const char *s);
+
+void testStrncat(const char *src) {
+ char dest[10];
+ strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest) - 1); // expected-warning {{Potential buffer overflow. Replace with 'sizeof(dest) - strlen(dest) - 1' or use a safer 'strlcat' API}}
+ strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest)); // expected-warning {{Potential buffer overflow. Replace with}}
+ strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest) - strlen(dest)); // expected-warning {{Potential buffer overflow. Replace with}}
+ strncat(dest, src, sizeof(src)); // expected-warning {{Potential buffer overflow. Replace with}}
+}
diff --git a/test/Analysis/dead-stores.c b/test/Analysis/dead-stores.c
index 5ddb4528c1b2..b8d195d05a76 100644
--- a/test/Analysis/dead-stores.c
+++ b/test/Analysis/dead-stores.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core,deadcode.DeadStores,deadcode.IdempotentOperations -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s
-// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core,deadcode.DeadStores,deadcode.IdempotentOperations -analyzer-store=region -analyzer-constraints=basic -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s
-// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core,deadcode.DeadStores,deadcode.IdempotentOperations -analyzer-store=region -analyzer-constraints=range -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s
+// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core,deadcode.DeadStores,experimental.deadcode.IdempotentOperations -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s
+// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core,deadcode.DeadStores,experimental.deadcode.IdempotentOperations -analyzer-store=region -analyzer-constraints=basic -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s
+// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core,deadcode.DeadStores,experimental.deadcode.IdempotentOperations -analyzer-store=region -analyzer-constraints=range -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s
void f1() {
int k, y; // expected-warning{{unused variable 'k'}} expected-warning{{unused variable 'y'}}
@@ -11,7 +11,7 @@ void f1() {
void f2(void *b) {
char *c = (char*)b; // no-warning
char *d = b+1; // expected-warning {{never read}} expected-warning{{unused variable 'd'}}
- printf("%s", c); // expected-warning{{implicitly declaring C library function 'printf' with type 'int (const char *, ...)'}} \
+ printf("%s", c); // expected-warning{{implicitly declaring library function 'printf' with type 'int (const char *, ...)'}} \
// expected-note{{please include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
}
@@ -526,3 +526,25 @@ void rdar8405222() {
rdar8405222_aux(i);
}
+// Look through chains of assignements, e.g.: int x = y = 0, when employing
+// silencing heuristics.
+int radar11185138_foo() {
+ int x, y;
+ x = y = 0; // expected-warning {{never read}}
+ return y;
+}
+
+int rdar11185138_bar() {
+ int y;
+ int x = y = 0; // no-warning
+ x = 2;
+ y = 2;
+ return x + y;
+}
+
+int *radar11185138_baz() {
+ int *x, *y;
+ x = y = 0; // no-warning
+ return y;
+}
+
diff --git a/test/Analysis/dead-stores.m b/test/Analysis/dead-stores.m
index 4ed71c4e8bfa..083427478d7e 100644
--- a/test/Analysis/dead-stores.m
+++ b/test/Analysis/dead-stores.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core -analyzer-checker=deadcode.DeadStores,osx.cocoa.RetainCount -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core -analyzer-checker=deadcode.DeadStores,osx.cocoa.RetainCount -fblocks -verify -Wno-objc-root-class %s
typedef signed char BOOL;
typedef unsigned int NSUInteger;
@@ -76,3 +76,15 @@ void foo_rdar8527823();
}
@end
+// Don't flag dead stores when a variable is captured in a block used
+// by a property access.
+@interface RDar10591355
+@property (assign) int x;
+@end
+
+RDar10591355 *rdar10591355_aux();
+
+void rdar10591355() {
+ RDar10591355 *p = rdar10591355_aux();
+ ^{ (void) p.x; }();
+}
diff --git a/test/Analysis/debug-CallGraph.c b/test/Analysis/debug-CallGraph.c
new file mode 100644
index 000000000000..b7c7c8a8447d
--- /dev/null
+++ b/test/Analysis/debug-CallGraph.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCallGraph %s 2>&1 | FileCheck %s
+
+static void mmm(int y) {
+ if (y != 0)
+ y++;
+ y = y/0;
+}
+
+static int foo(int x, int y) {
+ mmm(y);
+ if (x != 0)
+ x++;
+ return 5/x;
+}
+
+void aaa() {
+ foo(1,2);
+}
+
+// CHECK:--- Call graph Dump ---
+// CHECK: Function: < root > calls: aaa
diff --git a/test/Analysis/default-analyze.m b/test/Analysis/default-analyze.m
new file mode 100644
index 000000000000..82656b24a6e9
--- /dev/null
+++ b/test/Analysis/default-analyze.m
@@ -0,0 +1,63 @@
+// RUN: %clang --analyze %s -o %t
+
+// Tests that some specific checkers are enabled by default.
+
+id foo(int x) {
+ id title;
+ switch (x) {
+ case 1:
+ title = @"foo"; // expected-warning {{never read}}
+ case 2:
+ title = @"bar";
+ break;
+ default:
+ title = "@baz";
+ break;
+ }
+ return title;
+}
+
+// <rdar://problem/8808566> Static analyzer is wrong: NSWidth(imgRect) not understood as unconditional assignment
+//
+// Note: this requires inlining support. This previously issued a false positive use of
+// uninitialized value when calling NSWidth.
+typedef double CGFloat;
+
+struct CGPoint {
+ CGFloat x;
+ CGFloat y;
+};
+typedef struct CGPoint CGPoint;
+
+struct CGSize {
+ CGFloat width;
+ CGFloat height;
+};
+typedef struct CGSize CGSize;
+
+struct CGRect {
+ CGPoint origin;
+ CGSize size;
+};
+typedef struct CGRect CGRect;
+
+typedef CGRect NSRect;
+typedef CGSize NSSize;
+
+static __inline__ __attribute__((always_inline)) CGFloat NSWidth(NSRect aRect) {
+ return (aRect.size.width);
+}
+
+static __inline__ __attribute__((always_inline)) CGFloat NSHeight(NSRect aRect) {
+ return (aRect.size.height);
+}
+
+NSSize rdar880566_size();
+
+double rdar8808566() {
+ NSRect myRect;
+ myRect.size = rdar880566_size();
+ double x = NSWidth(myRect) + NSHeight(myRect); // no-warning
+ return x;
+}
+
diff --git a/test/Analysis/domtest.c b/test/Analysis/domtest.c
new file mode 100644
index 000000000000..245186a1c239
--- /dev/null
+++ b/test/Analysis/domtest.c
@@ -0,0 +1,165 @@
+// RUN: %clang -cc1 -analyze -analyzer-checker=debug.DumpDominators %s 2>&1 | FileCheck %s
+
+// Test the DominatorsTree implementation with various control flows
+int test1()
+{
+ int x = 6;
+ int y = x/2;
+ int z;
+
+ while(y > 0) {
+ if(y < x) {
+ x = x/y;
+ y = y-1;
+ }else{
+ z = x - y;
+ }
+ x = x - 1;
+ x = x - 1;
+ }
+ z = x+y;
+ z = 3;
+ return 0;
+}
+
+// CHECK: Immediate dominance tree (Node#,IDom#):
+// CHECK: (0,1)
+// CHECK: (1,2)
+// CHECK: (2,8)
+// CHECK: (3,4)
+// CHECK: (4,7)
+// CHECK: (5,7)
+// CHECK: (6,7)
+// CHECK: (7,2)
+// CHECK: (8,9)
+// CHECK: (9,9)
+
+int test2()
+{
+ int x,y,z;
+
+ x = 10; y = 100;
+ if(x > 0){
+ y = 1;
+ }else{
+ while(x<=0){
+ x++;
+ y++;
+ }
+ }
+ z = y;
+
+ return 0;
+}
+
+// CHECK: Immediate dominance tree (Node#,IDom#):
+// CHECK: (0,1)
+// CHECK: (1,6)
+// CHECK: (2,6)
+// CHECK: (3,4)
+// CHECK: (4,2)
+// CHECK: (5,6)
+// CHECK: (6,7)
+// CHECK: (7,7)
+
+int test3()
+{
+ int x,y,z;
+
+ x = y = z = 1;
+ if(x>0) {
+ while(x>=0){
+ while(y>=x) {
+ x = x-1;
+ y = y/2;
+ }
+ }
+ }
+ z = y;
+
+ return 0;
+}
+
+// CHECK: Immediate dominance tree (Node#,IDom#):
+// CHECK: (0,1)
+// CHECK: (1,7)
+// CHECK: (2,7)
+// CHECK: (3,4)
+// CHECK: (4,2)
+// CHECK: (5,6)
+// CHECK: (6,4)
+// CHECK: (7,8)
+// CHECK: (8,8)
+
+int test4()
+{
+ int y = 3;
+ while(y > 0) {
+ if(y < 3) {
+ while(y>0)
+ y ++;
+ }else{
+ while(y<10)
+ y ++;
+ }
+ }
+ return 0;
+}
+
+// CHECK: Immediate dominance tree (Node#,IDom#):
+// CHECK: (0,1)
+// CHECK: (1,2)
+// CHECK: (2,11)
+// CHECK: (3,10)
+// CHECK: (4,10)
+// CHECK: (5,6)
+// CHECK: (6,4)
+// CHECK: (7,10)
+// CHECK: (8,9)
+// CHECK: (9,7)
+// CHECK: (10,2)
+// CHECK: (11,12)
+// CHECK: (12,12)
+
+int test5()
+{
+ int x,y,z,a,b,c;
+ x = 1;
+ y = 2;
+ z = 3;
+ a = 4;
+ b = 5;
+ c = 6;
+ if ( x < 10 ) {
+ if ( y < 10 ) {
+ if ( z < 10 ) {
+ x = 4;
+ } else {
+ x = 5;
+ }
+ a = 10;
+ } else {
+ x = 6;
+ }
+ b = 10;
+ } else {
+ x = 7;
+ }
+ c = 11;
+ return 0;
+}
+
+// CHECK: Immediate dominance tree (Node#,IDom#):
+// CHECK: (0,1)
+// CHECK: (1,10)
+// CHECK: (2,10)
+// CHECK: (3,9)
+// CHECK: (4,9)
+// CHECK: (5,8)
+// CHECK: (6,8)
+// CHECK: (7,8)
+// CHECK: (8,9)
+// CHECK: (9,10)
+// CHECK: (10,11)
+// CHECK: (11,11)
+
diff --git a/test/Analysis/dtor.cpp b/test/Analysis/dtor.cpp
index dfd438ed405d..8d63cc47bed4 100644
--- a/test/Analysis/dtor.cpp
+++ b/test/Analysis/dtor.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -analyzer-inline-call -cfg-add-implicit-dtors -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -analyzer-ipa=inlining -cfg-add-implicit-dtors -verify %s
class A {
public:
diff --git a/test/Analysis/dtors-in-dtor-cfg-output.cpp b/test/Analysis/dtors-in-dtor-cfg-output.cpp
index 776548318003..68ba37ebf399 100644
--- a/test/Analysis/dtors-in-dtor-cfg-output.cpp
+++ b/test/Analysis/dtors-in-dtor-cfg-output.cpp
@@ -35,26 +35,22 @@ public:
TestArray::~TestArray() {}
-// CHECK: [ B2 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B1
-// CHECK: [ B1 ]
-// CHECK: 1: this->a.~A() (Member object destructor)
-// CHECK: 2: ~B() (Base object destructor)
-// CHECK: 3: ~C() (Base object destructor)
-// CHECK: 4: ~A() (Base object destructor)
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (1): B0
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B2 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B1
-// CHECK: [ B1 ]
-// CHECK: 1: this->a.~A() (Member object destructor)
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (1): B0
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: this->a.~A() (Member object destructor)
+// CHECK: 2: ~B() (Base object destructor)
+// CHECK: 3: ~C() (Base object destructor)
+// CHECK: 4: ~A() (Base object destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: this->a.~A() (Member object destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
diff --git a/test/Analysis/dynamic-cast.cpp b/test/Analysis/dynamic-cast.cpp
new file mode 100644
index 000000000000..8e63b2bcb363
--- /dev/null
+++ b/test/Analysis/dynamic-cast.cpp
@@ -0,0 +1,230 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core -verify %s
+
+class A {
+public:
+ virtual void f(){};
+
+};
+class B : public A{
+public:
+ int m;
+};
+class C : public A{};
+
+class BB: public B{};
+
+// A lot of the tests below have the if statement in them, which forces the
+// analyzer to explore both path - when the result is 0 and not. This makes
+// sure that we definitely know that the result is non-0 (as the result of
+// the cast).
+int testDynCastFromRadar() {
+ B aa;
+ A *a = &aa;
+ const int* res = 0;
+ B *b = dynamic_cast<B*>(a);
+ static const int i = 5;
+ if(b) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // no warning
+}
+
+int testBaseToBase1() {
+ B b;
+ B *pb = &b;
+ B *pbb = dynamic_cast<B*>(pb);
+ const int* res = 0;
+ static const int i = 5;
+ if (pbb) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // no warning
+}
+
+int testMultipleLevelsOfSubclassing1() {
+ BB bb;
+ B *pb = &bb;
+ A *pa = pb;
+ B *b = dynamic_cast<B*>(pa);
+ const int* res = 0;
+ static const int i = 5;
+ if (b) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // no warning
+}
+
+int testMultipleLevelsOfSubclassing2() {
+ BB bb;
+ A *pbb = &bb;
+ B *b = dynamic_cast<B*>(pbb);
+ BB *s = dynamic_cast<BB*>(b);
+ const int* res = 0;
+ static const int i = 5;
+ if (s) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // no warning
+}
+
+int testMultipleLevelsOfSubclassing3() {
+ BB bb;
+ A *pbb = &bb;
+ B *b = dynamic_cast<B*>(pbb);
+ return b->m; // no warning
+}
+
+int testLHS() {
+ B aa;
+ A *a = &aa;
+ return (dynamic_cast<B*>(a))->m;
+}
+
+int testLHS2() {
+ B aa;
+ A *a = &aa;
+ return (*dynamic_cast<B*>(a)).m;
+}
+
+int testDynCastUnknown2(class A *a) {
+ B *b = dynamic_cast<B*>(a);
+ return b->m; // no warning
+}
+
+int testDynCastUnknown(class A *a) {
+ B *b = dynamic_cast<B*>(a);
+ const int* res = 0;
+ static const int i = 5;
+ if (b) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // expected-warning {{Dereference of null pointer}}
+}
+
+int testDynCastFail2() {
+ C c;
+ A *pa = &c;
+ B *b = dynamic_cast<B*>(pa);
+ return b->m; // expected-warning {{dereference of a null pointer}}
+}
+
+int testLHSFail() {
+ C c;
+ A *a = &c;
+ return (*dynamic_cast<B*>(a)).m; // expected-warning {{Dereference of null pointer}}
+}
+
+int testBaseToDerivedFail() {
+ A a;
+ B *b = dynamic_cast<B*>(&a);
+ return b->m; // expected-warning {{dereference of a null pointer}}
+}
+
+int testConstZeroFail() {
+ B *b = dynamic_cast<B*>((A *)0);
+ return b->m; // expected-warning {{dereference of a null pointer}}
+}
+
+int testConstZeroFail2() {
+ A *a = 0;
+ B *b = dynamic_cast<B*>(a);
+ return b->m; // expected-warning {{dereference of a null pointer}}
+}
+
+int testUpcast() {
+ B b;
+ A *a = dynamic_cast<A*>(&b);
+ const int* res = 0;
+ static const int i = 5;
+ if (a) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // no warning
+}
+
+int testCastToVoidStar() {
+ A a;
+ void *b = dynamic_cast<void*>(&a);
+ const int* res = 0;
+ static const int i = 5;
+ if (b) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // no warning
+}
+
+int testReferenceSuccesfulCast() {
+ B rb;
+ B &b = dynamic_cast<B&>(rb);
+ int *x = 0;
+ return *x; // expected-warning {{Dereference of null pointer}}
+}
+
+int testReferenceFailedCast() {
+ A a;
+ B &b = dynamic_cast<B&>(a);
+ int *x = 0;
+ return *x; // no warning (An exception is thrown by the cast.)
+}
+
+// Here we allow any outcome of the cast and this is good because there is a
+// situation where this will fail. So if the user has written the code in this
+// way, we assume they expect the cast to succeed.
+// Note, this might need special handling if we track types of symbolic casts
+// and use them for dynamic_cast handling.
+int testDynCastMostLikelyWillFail(C *c) {
+ B *b = 0;
+ b = dynamic_cast<B*>(c);
+ const int* res = 0;
+ static const int i = 5;
+ if (b) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // expected-warning{{Dereference of null pointer}}
+}
+
+class M : public B, public C {};
+void callTestDynCastMostLikelyWillFail() {
+ M m;
+ testDynCastMostLikelyWillFail(&m);
+}
+
+// False positives/negatives.
+
+// Due to symbolic regions not being typed.
+int testDynCastFalsePositive(BB *c) {
+ B *b = 0;
+ b = dynamic_cast<B*>(c);
+ const int* res = 0;
+ static const int i = 5;
+ if (b) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // expected-warning{{Dereference of null pointer}}
+}
+
+// Does not work when we new an object.
+int testDynCastFail3() {
+ A *a = new A();
+ B *b = dynamic_cast<B*>(a);
+ return b->m;
+}
+
diff --git a/test/Analysis/exercise-ps.c b/test/Analysis/exercise-ps.c
index 5dd1f3f12bd2..b592c330e601 100644
--- a/test/Analysis/exercise-ps.c
+++ b/test/Analysis/exercise-ps.c
@@ -18,6 +18,6 @@ void_typedef f2_helper();
static void f2(void *buf) {
F12_typedef* x;
x = f2_helper();
- memcpy((&x[1]), (buf), 1); // expected-warning{{implicitly declaring C library function 'memcpy' with type 'void *(void *, const void *}} \
+ memcpy((&x[1]), (buf), 1); // expected-warning{{implicitly declaring library function 'memcpy' with type 'void *(void *, const void *}} \
// expected-note{{please include the header <string.h> or explicitly provide a declaration for 'memcpy'}}
}
diff --git a/test/Analysis/free.c b/test/Analysis/free.c
index 44c4f19f1b3c..f688db7fb8dd 100644
--- a/test/Analysis/free.c
+++ b/test/Analysis/free.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-checker=core,experimental.unix.Malloc -fblocks -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-checker=core,unix.Malloc -fblocks -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-checker=core,experimental.unix.MallocWithAnnotations -fblocks -verify %s
void free(void *);
void t1 () {
diff --git a/test/Analysis/global-region-invalidation.c b/test/Analysis/global-region-invalidation.c
new file mode 100644
index 000000000000..184ffb870fb8
--- /dev/null
+++ b/test/Analysis/global-region-invalidation.c
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -disable-free -analyzer-eagerly-assume -analyzer-checker=core,deadcode,experimental.security.taint,debug.TaintTest -verify %s
+
+// Note, we do need to include headers here, since the analyzer checks if the function declaration is located in a system header.
+#include "system-header-simulator.h"
+
+// Test that system header does not invalidate the internal global.
+int size_rdar9373039 = 1;
+int rdar9373039() {
+ int x;
+ int j = 0;
+
+ for (int i = 0 ; i < size_rdar9373039 ; ++i)
+ x = 1;
+
+ // strlen doesn't invalidate the value of 'size_rdar9373039'.
+ int extra = (2 + strlen ("Clang") + ((4 - ((unsigned int) (2 + strlen ("Clang")) % 4)) % 4)) + (2 + strlen ("1.0") + ((4 - ((unsigned int) (2 + strlen ("1.0")) % 4)) % 4));
+
+ for (int i = 0 ; i < size_rdar9373039 ; ++i)
+ j += x; // no-warning
+
+ return j;
+}
+
+// Test stdin does not get invalidated by a system call nor by an internal call.
+void foo();
+int stdinTest() {
+ int i = 0;
+ fscanf(stdin, "%d", &i);
+ foo();
+ int m = i; // expected-warning + {{tainted}}
+ fscanf(stdin, "%d", &i);
+ int j = i; // expected-warning + {{tainted}}
+ return m + j; // expected-warning + {{tainted}}
+}
+
+// Test errno gets invalidated by a system call.
+int testErrnoSystem() {
+ int i;
+ int *p = 0;
+ fscanf(stdin, "%d", &i);
+ if (errno == 0) {
+ fscanf(stdin, "%d", &i); // errno gets invalidated here.
+ return 5 / errno; // no-warning
+ }
+ return 0;
+}
+
+// Test that errno gets invalidated by internal calls.
+int testErrnoInternal() {
+ int i;
+ int *p = 0;
+ fscanf(stdin, "%d", &i);
+ if (errno == 0) {
+ foo(); // errno gets invalidated here.
+ return 5 / errno; // no-warning
+ }
+ return 0;
+}
+
+// Test that const integer does not get invalidated.
+const int x = 0;
+int constIntGlob() {
+ const int *m = &x;
+ foo();
+ return 3 / *m; // expected-warning {{Division by zero}}
+}
+
+extern const int x;
+int constIntGlobExtern() {
+ if (x == 0) {
+ foo();
+ return 5 / x; // expected-warning {{Division by zero}}
+ }
+ return 0;
+}
diff --git a/test/Analysis/html-diags-multifile.c b/test/Analysis/html-diags-multifile.c
new file mode 100644
index 000000000000..611dd072635b
--- /dev/null
+++ b/test/Analysis/html-diags-multifile.c
@@ -0,0 +1,17 @@
+// RUN: mkdir -p %t.dir
+// RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %t.dir
+// RUN: ls %t.dir | grep report | count 0
+// RUN: rm -fR %t.dir
+// REQUIRES: shell
+
+// This tests that we do not currently emit HTML diagnostics for reports that
+// cross file boundaries.
+
+#include "html-diags-multifile.h"
+
+#define CALL_HAS_BUG(q) has_bug(q)
+
+void test_call_macro() {
+ CALL_HAS_BUG(0);
+}
+
diff --git a/test/Analysis/html-diags-multifile.h b/test/Analysis/html-diags-multifile.h
new file mode 100644
index 000000000000..71d39ba79e1c
--- /dev/null
+++ b/test/Analysis/html-diags-multifile.h
@@ -0,0 +1,4 @@
+#define DEREF(p) *p = 0xDEADBEEF
+void has_bug(int *p) {
+ DEREF(p);
+}
diff --git a/test/Analysis/html-diags.c b/test/Analysis/html-diags.c
new file mode 100644
index 000000000000..59d81a56a4e9
--- /dev/null
+++ b/test/Analysis/html-diags.c
@@ -0,0 +1,20 @@
+// RUN: mkdir %t.dir
+// RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %T.dir %s
+// RUN: rm -fR %t.dir
+
+// Currently this test mainly checks that the HTML diagnostics doesn't crash
+// when handling macros will calls with macros. We should actually validate
+// the output, but that requires being able to match against a specifically
+// generate HTML file.
+
+#define DEREF(p) *p = 0xDEADBEEF
+
+void has_bug(int *p) {
+ DEREF(p);
+}
+
+#define CALL_HAS_BUG(q) has_bug(q)
+
+void test_call_macro() {
+ CALL_HAS_BUG(0);
+}
diff --git a/test/Analysis/idempotent-operations-limited-loops.c b/test/Analysis/idempotent-operations-limited-loops.c
index 47a1f2854c74..71e7c27b6ce3 100644
--- a/test/Analysis/idempotent-operations-limited-loops.c
+++ b/test/Analysis/idempotent-operations-limited-loops.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=core,deadcode.IdempotentOperations -analyzer-max-loop 3 -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=core,deadcode.IdempotentOperations -analyzer-max-loop 4 -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=core,deadcode.IdempotentOperations %s -verify
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=core,experimental.deadcode.IdempotentOperations -analyzer-max-loop 3 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=core,experimental.deadcode.IdempotentOperations -analyzer-max-loop 4 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=core,experimental.deadcode.IdempotentOperations %s -verify
void always_warning() { int *p = 0; *p = 0xDEADBEEF; } // expected-warning{{Dereference of null pointer (loaded from variable 'p')}}
diff --git a/test/Analysis/idempotent-operations.c b/test/Analysis/idempotent-operations.c
index 10bd9ff3198c..6cc9a01b77ae 100644
--- a/test/Analysis/idempotent-operations.c
+++ b/test/Analysis/idempotent-operations.c
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=deadcode.IdempotentOperations -verify %s
-// RUN: %clang --analyze -Xclang -analyzer-disable-checker=deadcode.DeadStores -fblocks -Xclang -verify %s -o %t
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=experimental.deadcode.IdempotentOperations -verify %s
// Basic tests
diff --git a/test/Analysis/idempotent-operations.cpp b/test/Analysis/idempotent-operations.cpp
index 9d22909ed37e..51b590566adf 100644
--- a/test/Analysis/idempotent-operations.cpp
+++ b/test/Analysis/idempotent-operations.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=deadcode.IdempotentOperations -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=experimental.deadcode.IdempotentOperations -verify %s
// C++ specific false positives
diff --git a/test/Analysis/idempotent-operations.m b/test/Analysis/idempotent-operations.m
index b4765082d84a..9a9820c3b2a4 100644
--- a/test/Analysis/idempotent-operations.m
+++ b/test/Analysis/idempotent-operations.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=deadcode.IdempotentOperations,osx.cocoa.RetainCount -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=experimental.deadcode.IdempotentOperations,osx.cocoa.RetainCount -verify %s
typedef signed char BOOL;
typedef unsigned long NSUInteger;
diff --git a/test/Analysis/initializers-cfg-output.cpp b/test/Analysis/initializers-cfg-output.cpp
index b73809f2b83a..8a7a3f5d013d 100644
--- a/test/Analysis/initializers-cfg-output.cpp
+++ b/test/Analysis/initializers-cfg-output.cpp
@@ -44,60 +44,55 @@ TestControlFlow::TestControlFlow(bool b)
int v;
}
-// CHECK: [ B2 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B1
-// CHECK: [ B1 ]
-// CHECK: 1:
-// CHECK: 2: A([B1.1]) (Base initializer)
-// CHECK: 3:
-// CHECK: 4: C([B1.3]) (Base initializer)
-// CHECK: 5:
-// CHECK: 6: B([B1.5]) (Base initializer)
-// CHECK: 7:
-// CHECK: 8: A([B1.7]) (Base initializer)
-// CHECK: 9: /*implicit*/int()
-// CHECK: 10: i([B1.9]) (Member initializer)
-// CHECK: 11: this
-// CHECK: 12: [B1.11]->i
-// CHECK: 13: r([B1.12]) (Member initializer)
-// CHECK: 14:
-// CHECK: 15: A a;
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (1): B0
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B5 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B4
-// CHECK: [ B1 ]
-// CHECK: 1: [B4.4] ? [B2.1] : [B3.1]
-// CHECK: 2: y([B1.1]) (Member initializer)
-// CHECK: 3: this
-// CHECK: 4: [B1.3]->y
-// CHECK: 5: [B1.4]
-// CHECK: 6: z([B1.5]) (Member initializer)
-// CHECK: 7: int v;
-// CHECK: Predecessors (2): B2 B3
-// CHECK: Successors (1): B0
-// CHECK: [ B2 ]
-// CHECK: 1: 0
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B1
-// CHECK: [ B3 ]
-// CHECK: 1: 1
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B1
-// CHECK: [ B4 ]
-// CHECK: 1: 0
-// CHECK: 2: x([B4.1]) (Member initializer)
-// CHECK: 3: b
-// CHECK: 4: [B4.3]
-// CHECK: T: [B4.4] ? ... : ...
-// CHECK: Predecessors (1): B5
-// CHECK: Successors (2): B2 B3
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A([B1.1]) (Base initializer)
+// CHECK: 3: (CXXConstructExpr, class C)
+// CHECK: 4: C([B1.3]) (Base initializer)
+// CHECK: 5: (CXXConstructExpr, class B)
+// CHECK: 6: B([B1.5]) (Base initializer)
+// CHECK: 7: (CXXConstructExpr, class A)
+// CHECK: 8: A([B1.7]) (Base initializer)
+// CHECK: 9: /*implicit*/int()
+// CHECK: 10: i([B1.9]) (Member initializer)
+// CHECK: 11: this
+// CHECK: 12: [B1.11]->i
+// CHECK: 13: r([B1.12]) (Member initializer)
+// CHECK: 14: (CXXConstructExpr, class A)
+// CHECK: 15: A a;
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B5 (ENTRY)]
+// CHECK: Succs (1): B4
+// CHECK: [B1]
+// CHECK: 1: [B4.4] ? [B2.1] : [B3.1]
+// CHECK: 2: y([B1.1]) (Member initializer)
+// CHECK: 3: this
+// CHECK: 4: [B1.3]->y
+// CHECK: 5: [B1.4] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK: 6: z([B1.5]) (Member initializer)
+// CHECK: 7: int v;
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: 0
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: 1
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: 0
+// CHECK: 2: x([B4.1]) (Member initializer)
+// CHECK: 3: b
+// CHECK: 4: [B4.3] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: [B4.4] ? ... : ...
+// CHECK: Preds (1): B5
+// CHECK: Succs (2): B2 B3
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
diff --git a/test/Analysis/inline-not-supported.c b/test/Analysis/inline-not-supported.c
new file mode 100644
index 000000000000..bff0e4d0b22c
--- /dev/null
+++ b/test/Analysis/inline-not-supported.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fblocks -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-store region -verify %s
+
+// For now, don't inline varargs.
+void foo(int *x, ...) {
+ *x = 1;
+}
+
+void bar() {
+ foo(0, 2); // no-warning
+}
+
+// For now, don't inline vararg blocks.
+void (^baz)(int *x, ...) = ^(int *x, ...) { *x = 1; };
+
+void taz() {
+ baz(0, 2); // no-warning
+}
+
+// For now, don't inline blocks.
+void (^qux)(int *p) = ^(int *p) { *p = 1; };
+void test_qux() {
+ qux(0); // no-warning
+}
+
+
+void test_analyzer_is_running() {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+}
diff --git a/test/Analysis/inline-plist.c b/test/Analysis/inline-plist.c
new file mode 100644
index 000000000000..549082dc9ca2
--- /dev/null
+++ b/test/Analysis/inline-plist.c
@@ -0,0 +1,369 @@
+// RUN: %clang --analyze %s -Xclang -analyzer-ipa=inlining -o %t
+// RUN: FileCheck -input-file %t %s
+
+// <rdar://problem/10967815>
+void mmm(int y) {
+ if (y != 0)
+ y++;
+}
+
+int foo(int x, int y) {
+ mmm(y);
+ if (x != 0)
+ x++;
+ return 5/x;
+}
+
+// Test a bug triggering only when inlined.
+void has_bug(int *p) {
+ *p = 0xDEADBEEF;
+}
+
+void test_has_bug() {
+ has_bug(0);
+}
+
+
+// CHECK: <?xml version="1.0" encoding="UTF-8"?>
+// CHECK: <plist version="1.0">
+// CHECK: <dict>
+// CHECK: <key>files</key>
+// CHECK: <array>
+// CHECK: </array>
+// CHECK: <key>diagnostics</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>14</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Assuming &apos;x&apos; is equal to 0</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Assuming &apos;x&apos; is equal to 0</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>14</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Division by zero</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Division by zero</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Division by zero</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Division by zero</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>foo</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Calling &apos;has_bug&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Calling &apos;has_bug&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Entered call from &apos;test_has_bug&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Entered call from &apos;test_has_bug&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>has_bug</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </plist>
diff --git a/test/Analysis/inline-unique-reports.c b/test/Analysis/inline-unique-reports.c
new file mode 100644
index 000000000000..ae94267d2c25
--- /dev/null
+++ b/test/Analysis/inline-unique-reports.c
@@ -0,0 +1,184 @@
+// RUN: %clang --analyze %s -Xclang -analyzer-ipa=inlining -o %t > /dev/null 2>&1
+// RUN: FileCheck -input-file %t %s
+
+static inline bug(int *p) {
+ *p = 0xDEADBEEF;
+}
+
+void test_bug_1() {
+ int *p = 0;
+ bug(p);
+}
+
+void test_bug_2() {
+ int *p = 0;
+ bug(p);
+}
+
+// CHECK: <?xml version="1.0" encoding="UTF-8"?>
+// CHECK: <plist version="1.0">
+// CHECK: <dict>
+// CHECK: <key>files</key>
+// CHECK: <array>
+// CHECK: </array>
+// CHECK: <key>diagnostics</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>9</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>9</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Calling &apos;bug&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Calling &apos;bug&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>4</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Entered call from &apos;test_bug_1&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Entered call from &apos;test_bug_1&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>4</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>4</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>bug</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </plist>
diff --git a/test/Analysis/inline.c b/test/Analysis/inline.c
index 2aac15661b14..0827d934614a 100644
--- a/test/Analysis/inline.c
+++ b/test/Analysis/inline.c
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-inline-call -analyzer-store region -verify %s
-// XFAIL: *
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-store region -verify %s
int test1_f1() {
int y = 1;
@@ -29,3 +28,65 @@ void test2_f3() {
test2_f1(test2_f2()); // expected-warning{{too many arguments in call to 'test2_f1'}}
}
+// Test that inlining works with recursive functions.
+
+unsigned factorial(unsigned x) {
+ if (x <= 1)
+ return 1;
+ return x * factorial(x - 1);
+}
+
+void test_factorial() {
+ if (factorial(3) == 6) {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+ }
+ else {
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ }
+}
+
+void test_factorial_2() {
+ unsigned x = factorial(3);
+ if (x == factorial(3)) {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+ }
+ else {
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ }
+}
+
+// Test that returning stack memory from a parent stack frame does
+// not trigger a warning.
+static char *return_buf(char *buf) {
+ return buf + 10;
+}
+
+void test_return_stack_memory_ok() {
+ char stack_buf[100];
+ char *pos = return_buf(stack_buf);
+ (void) pos;
+}
+
+char *test_return_stack_memory_bad() {
+ char stack_buf[100];
+ char *x = stack_buf;
+ return x; // expected-warning {{stack memory associated}}
+}
+
+// Test that passing a struct value with an uninitialized field does
+// not trigger a warning if we are inlining and the body is available.
+struct rdar10977037 { int x, y; };
+int test_rdar10977037_aux(struct rdar10977037 v) { return v.y; }
+int test_rdar10977037_aux_2(struct rdar10977037 v);
+int test_rdar10977037() {
+ struct rdar10977037 v;
+ v.y = 1;
+ v. y += test_rdar10977037_aux(v); // no-warning
+ return test_rdar10977037_aux_2(v); // expected-warning {{Passed-by-value struct argument contains uninitialized data}}
+}
+
+
diff --git a/test/Analysis/inline2.c b/test/Analysis/inline2.c
index 97e479d4b292..473146c0be4b 100644
--- a/test/Analysis/inline2.c
+++ b/test/Analysis/inline2.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-inline-call -analyzer-store region -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-store region -verify %s
// Test parameter 'a' is registered to LiveVariables analysis data although it
// is not referenced in the function body.
diff --git a/test/Analysis/inline3.c b/test/Analysis/inline3.c
index 9c8e26ece51b..968d82acd6e1 100644
--- a/test/Analysis/inline3.c
+++ b/test/Analysis/inline3.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-inline-call -analyzer-store region -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-store region -verify %s
-// Test when entering f1(), we set the right AnalysisContext to Environment.
+// Test when entering f1(), we set the right AnalysisDeclContext to Environment.
// Otherwise, block-level expr '1 && a' would not be block-level.
int a;
diff --git a/test/Analysis/inline4.c b/test/Analysis/inline4.c
index c428aad5ec4b..e7715e01dda1 100644
--- a/test/Analysis/inline4.c
+++ b/test/Analysis/inline4.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-inline-call -analyzer-store region -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-store region -verify %s
int g(int a) {
return a;
diff --git a/test/Analysis/keychainAPI.m b/test/Analysis/keychainAPI.m
index d10600dea590..cb4f72c9c454 100644
--- a/test/Analysis/keychainAPI.m
+++ b/test/Analysis/keychainAPI.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=osx.SecKeychainAPI %s -verify
+// RUN: %clang_cc1 -analyze -analyzer-checker=osx.SecKeychainAPI %s -analyzer-ipa=inlining -verify
// Fake typedefs.
typedef unsigned int OSStatus;
@@ -77,7 +77,7 @@ void errRetVal() {
void *outData;
st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &outData);
if (st == GenericError) // expected-warning{{Allocated data is not released: missing a call to 'SecKeychainItemFreeContent'.}}
- SecKeychainItemFreeContent(ptr, outData); // expected-warning{{Call to free data when error was returned during allocation.}}
+ SecKeychainItemFreeContent(ptr, outData); // expected-warning{{Only call free if a valid (non-NULL) buffer was returned}}
}
// If null is passed in, the data is not allocated, so no need for the matching free.
@@ -133,7 +133,7 @@ void* returnContent() {
return outData;
} // no-warning
-// Password was passed in as an argument and does nt have to be deleted.
+// Password was passed in as an argument and does not have to be deleted.
OSStatus getPasswordAndItem(void** password, UInt32* passwordLength) {
OSStatus err;
SecKeychainItemRef item;
@@ -275,7 +275,7 @@ void DellocWithCFStringCreate2(CFAllocatorRef alloc) {
st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &bytes);
if (st == noErr) {
CFStringRef userStr = CFStringCreateWithBytesNoCopy(alloc, bytes, length, 5, 0, kCFAllocatorNull); // expected-warning{{Allocated data is not released}}
- CFRelease(userStr);
+ CFRelease(userStr);
}
}
@@ -305,6 +305,22 @@ void DellocWithCFStringCreate4(CFAllocatorRef alloc) {
}
}
+void radar10508828() {
+ UInt32 pwdLen = 0;
+ void* pwdBytes = 0;
+ OSStatus rc = SecKeychainFindGenericPassword(0, 3, "foo", 3, "bar", &pwdLen, &pwdBytes, 0);
+#pragma unused(rc)
+ if (pwdBytes)
+ SecKeychainItemFreeContent(0, pwdBytes);
+}
+
+void radar10508828_2() {
+ UInt32 pwdLen = 0;
+ void* pwdBytes = 0;
+ OSStatus rc = SecKeychainFindGenericPassword(0, 3, "foo", 3, "bar", &pwdLen, &pwdBytes, 0);
+ SecKeychainItemFreeContent(0, pwdBytes); // expected-warning {{Only call free if a valid (non-NULL) buffer was returned.}}
+}
+
//Example from bug 10797.
__inline__ static
const char *__WBASLLevelString(int level) {
@@ -321,3 +337,73 @@ static int *bug10798(int *p, int columns, int prevRow) {
} while(10 >= row[1]);
return row;
}
+
+// Test inter-procedural behaviour.
+
+void my_FreeParam(void *attrList, void* X) {
+ SecKeychainItemFreeContent(attrList, X);
+}
+
+void *my_AllocateReturn(OSStatus *st) {
+ unsigned int *ptr = 0;
+ UInt32 length;
+ void *outData;
+ *st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &outData);
+ return outData;
+}
+
+OSStatus my_Allocate_Param(void** password, UInt32* passwordLength) {
+ OSStatus err;
+ SecKeychainItemRef item;
+ err = SecKeychainFindGenericPassword(0, 3, "xx", 3, "xx",
+ passwordLength, password, &item);
+ return err;
+}
+
+void allocAndFree1() {
+ unsigned int *ptr = 0;
+ OSStatus st = 0;
+ UInt32 length;
+ void *outData;
+ st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &outData);
+ if (st == noErr)
+ my_FreeParam(ptr, outData);
+}
+
+void consumeChar(char);
+
+void allocNoFree2(int x) {
+ OSStatus st = 0;
+ void *outData = my_AllocateReturn(&st);
+ if (x) {
+ consumeChar(*(char*)outData); // expected-warning{{Allocated data is not released:}}
+ return;
+ } else {
+ consumeChar(*(char*)outData);
+ }
+ return;
+}
+
+void allocAndFree2(void *attrList) {
+ OSStatus st = 0;
+ void *outData = my_AllocateReturn(&st);
+ if (st == noErr)
+ my_FreeParam(attrList, outData);
+}
+
+void allocNoFree3() {
+ UInt32 length = 32;
+ void *outData;
+ void *outData2;
+ OSStatus st = my_Allocate_Param(&outData, &length); // expected-warning{{Allocated data is not released}}
+ st = my_Allocate_Param(&outData2, &length); // expected-warning{{Allocated data is not released}}
+}
+
+void allocAndFree3(void *attrList) {
+ UInt32 length = 32;
+ void *outData;
+ OSStatus st = my_Allocate_Param(&outData, &length);
+ if (st == noErr)
+ SecKeychainItemFreeContent(attrList, outData);
+}
+
diff --git a/test/Analysis/lambdas.cpp b/test/Analysis/lambdas.cpp
new file mode 100644
index 000000000000..77b36c42cfa8
--- /dev/null
+++ b/test/Analysis/lambdas.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -analyze -analyzer-checker=debug.DumpCFG %s > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
+
+struct X { X(const X&); };
+void f(X x) { (void) [x]{}; }
+
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: x
+// CHECK: 2: [B1.1] (ImplicitCastExpr, NoOp, const struct X)
+// CHECK: 3: [B1.2] (CXXConstructExpr, struct X)
+// CHECK: 4: [=x] {
+// CHECK: }
+// CHECK: 5: (void)[B1.4] (CStyleCastExpr, ToVoid, void)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+
diff --git a/test/Analysis/malloc-annotations.c b/test/Analysis/malloc-annotations.c
new file mode 100644
index 000000000000..a0c145279d92
--- /dev/null
+++ b/test/Analysis/malloc-annotations.c
@@ -0,0 +1,271 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.core.CastSize,experimental.unix.MallocWithAnnotations -analyzer-store=region -verify %s
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+void *realloc(void *ptr, size_t size);
+void *calloc(size_t nmemb, size_t size);
+void __attribute((ownership_returns(malloc))) *my_malloc(size_t);
+void __attribute((ownership_takes(malloc, 1))) my_free(void *);
+void my_freeBoth(void *, void *)
+ __attribute((ownership_holds(malloc, 1, 2)));
+void __attribute((ownership_returns(malloc, 1))) *my_malloc2(size_t);
+void __attribute((ownership_holds(malloc, 1))) my_hold(void *);
+
+// Duplicate attributes are silly, but not an error.
+// Duplicate attribute has no extra effect.
+// If two are of different kinds, that is an error and reported as such.
+void __attribute((ownership_holds(malloc, 1)))
+__attribute((ownership_holds(malloc, 1)))
+__attribute((ownership_holds(malloc, 3))) my_hold2(void *, void *, void *);
+void *my_malloc3(size_t);
+void *myglobalpointer;
+struct stuff {
+ void *somefield;
+};
+struct stuff myglobalstuff;
+
+void f1() {
+ int *p = malloc(12);
+ return; // expected-warning{{Memory is never released; potential leak}}
+}
+
+void f2() {
+ int *p = malloc(12);
+ free(p);
+ free(p); // expected-warning{{Attempt to free released memory}}
+}
+
+void f2_realloc_0() {
+ int *p = malloc(12);
+ realloc(p,0);
+ realloc(p,0); // expected-warning{{Attempt to free released memory}}
+}
+
+void f2_realloc_1() {
+ int *p = malloc(12);
+ int *q = realloc(p,0); // no-warning
+}
+
+// ownership attributes tests
+void naf1() {
+ int *p = my_malloc3(12);
+ return; // no-warning
+}
+
+void n2af1() {
+ int *p = my_malloc2(12);
+ return; // expected-warning{{Memory is never released; potential leak}}
+}
+
+void af1() {
+ int *p = my_malloc(12);
+ return; // expected-warning{{Memory is never released; potential leak}}
+}
+
+void af1_b() {
+ int *p = my_malloc(12); // expected-warning{{Memory is never released; potential leak}}
+}
+
+void af1_c() {
+ myglobalpointer = my_malloc(12); // no-warning
+}
+
+// TODO: We will be able to handle this after we add support for tracking allocations stored in struct fields.
+void af1_d() {
+ struct stuff mystuff;
+ mystuff.somefield = my_malloc(12); // false negative
+}
+
+// Test that we can pass out allocated memory via pointer-to-pointer.
+void af1_e(void **pp) {
+ *pp = my_malloc(42); // no-warning
+}
+
+void af1_f(struct stuff *somestuff) {
+ somestuff->somefield = my_malloc(12); // no-warning
+}
+
+// Allocating memory for a field via multiple indirections to our arguments is OK.
+void af1_g(struct stuff **pps) {
+ *pps = my_malloc(sizeof(struct stuff)); // no-warning
+ (*pps)->somefield = my_malloc(42); // no-warning
+}
+
+void af2() {
+ int *p = my_malloc(12);
+ my_free(p);
+ free(p); // expected-warning{{Attempt to free released memory}}
+}
+
+void af2b() {
+ int *p = my_malloc(12);
+ free(p);
+ my_free(p); // expected-warning{{Attempt to free released memory}}
+}
+
+void af2c() {
+ int *p = my_malloc(12);
+ free(p);
+ my_hold(p); // expected-warning{{Attempt to free released memory}}
+}
+
+void af2d() {
+ int *p = my_malloc(12);
+ free(p);
+ my_hold2(0, 0, p); // expected-warning{{Attempt to free released memory}}
+}
+
+// No leak if malloc returns null.
+void af2e() {
+ int *p = my_malloc(12);
+ if (!p)
+ return; // no-warning
+ free(p); // no-warning
+}
+
+// This case would inflict a double-free elsewhere.
+// However, this case is considered an analyzer bug since it causes false-positives.
+void af3() {
+ int *p = my_malloc(12);
+ my_hold(p);
+ free(p); // no-warning
+}
+
+int * af4() {
+ int *p = my_malloc(12);
+ my_free(p);
+ return p; // expected-warning{{Use of memory after it is freed}}
+}
+
+// This case is (possibly) ok, be conservative
+int * af5() {
+ int *p = my_malloc(12);
+ my_hold(p);
+ return p; // no-warning
+}
+
+
+
+// This case tests that storing malloc'ed memory to a static variable which is
+// then returned is not leaked. In the absence of known contracts for functions
+// or inter-procedural analysis, this is a conservative answer.
+int *f3() {
+ static int *p = 0;
+ p = malloc(12);
+ return p; // no-warning
+}
+
+// This case tests that storing malloc'ed memory to a static global variable
+// which is then returned is not leaked. In the absence of known contracts for
+// functions or inter-procedural analysis, this is a conservative answer.
+static int *p_f4 = 0;
+int *f4() {
+ p_f4 = malloc(12);
+ return p_f4; // no-warning
+}
+
+int *f5() {
+ int *q = malloc(12);
+ q = realloc(q, 20);
+ return q; // no-warning
+}
+
+void f6() {
+ int *p = malloc(12);
+ if (!p)
+ return; // no-warning
+ else
+ free(p);
+}
+
+void f6_realloc() {
+ int *p = malloc(12);
+ if (!p)
+ return; // no-warning
+ else
+ realloc(p,0);
+}
+
+
+char *doit2();
+void pr6069() {
+ char *buf = doit2();
+ free(buf);
+}
+
+void pr6293() {
+ free(0);
+}
+
+void f7() {
+ char *x = (char*) malloc(4);
+ free(x);
+ x[0] = 'a'; // expected-warning{{Use of memory after it is freed}}
+}
+
+void f7_realloc() {
+ char *x = (char*) malloc(4);
+ realloc(x,0);
+ x[0] = 'a'; // expected-warning{{Use of memory after it is freed}}
+}
+
+void PR6123() {
+ int *x = malloc(11); // expected-warning{{Cast a region whose size is not a multiple of the destination type size.}}
+}
+
+void PR7217() {
+ int *buf = malloc(2); // expected-warning{{Cast a region whose size is not a multiple of the destination type size.}}
+ buf[1] = 'c'; // not crash
+}
+
+void mallocCastToVoid() {
+ void *p = malloc(2);
+ const void *cp = p; // not crash
+ free(p);
+}
+
+void mallocCastToFP() {
+ void *p = malloc(2);
+ void (*fp)() = p; // not crash
+ free(p);
+}
+
+// This tests that malloc() buffers are undefined by default
+char mallocGarbage () {
+ char *buf = malloc(2);
+ char result = buf[1]; // expected-warning{{undefined}}
+ free(buf);
+ return result;
+}
+
+// This tests that calloc() buffers need to be freed
+void callocNoFree () {
+ char *buf = calloc(2,2);
+ return; // expected-warning{{never released}}
+}
+
+// These test that calloc() buffers are zeroed by default
+char callocZeroesGood () {
+ char *buf = calloc(2,2);
+ char result = buf[3]; // no-warning
+ if (buf[1] == 0) {
+ free(buf);
+ }
+ return result; // no-warning
+}
+
+char callocZeroesBad () {
+ char *buf = calloc(2,2);
+ char result = buf[3]; // no-warning
+ if (buf[1] != 0) {
+ free(buf); // expected-warning{{never executed}}
+ }
+ return result; // expected-warning{{never released}}
+}
+
+void testMultipleFreeAnnotations() {
+ int *p = malloc(12);
+ int *q = malloc(12);
+ my_freeBoth(p, q);
+}
+
diff --git a/test/Analysis/malloc-interprocedural.c b/test/Analysis/malloc-interprocedural.c
new file mode 100644
index 000000000000..589bc4fdef59
--- /dev/null
+++ b/test/Analysis/malloc-interprocedural.c
@@ -0,0 +1,98 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix.Malloc -analyzer-ipa=inlining -analyzer-inline-max-stack-depth=5 -analyzer-inline-max-function-size=6 -analyzer-store=region -verify %s
+
+#include "system-header-simulator.h"
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void *valloc(size_t);
+void free(void *);
+void *realloc(void *ptr, size_t size);
+void *reallocf(void *ptr, size_t size);
+void *calloc(size_t nmemb, size_t size);
+extern void exit(int) __attribute__ ((__noreturn__));
+
+static void my_malloc1(void **d, size_t size) {
+ *d = malloc(size);
+}
+
+static void *my_malloc2(int elevel, size_t size) {
+ void *data;
+ data = malloc(size);
+ if (data == 0)
+ exit(0);
+ return data;
+}
+
+static void my_free1(void *p) {
+ free(p);
+}
+
+static void test1() {
+ void *data = 0;
+ my_malloc1(&data, 4); // expected-warning {{Memory is never released; potential leak of memory pointed to by 'data'}}
+}
+
+static void test11() {
+ void *data = 0;
+ my_malloc1(&data, 4);
+ my_free1(data);
+}
+
+static void testUniqueingByallocationSiteInTopLevelFunction() {
+ void *data = my_malloc2(1, 4);
+ data = 0;
+ int x = 5;// expected-warning {{Memory is never released; potential leak of memory pointed to by 'data'}}
+ data = my_malloc2(1, 4);// expected-warning {{Memory is never released; potential leak of memory pointed to by 'data'}}
+}
+
+static void test3() {
+ void *data = my_malloc2(1, 4);
+ free(data);
+ data = my_malloc2(1, 4);
+ free(data);
+}
+
+int test4() {
+ int *data = (int*)my_malloc2(1, 4);
+ my_free1(data);
+ data = (int *)my_malloc2(1, 4);
+ my_free1(data);
+ return *data; // expected-warning {{Use of memory after it is freed}}
+}
+
+void test6() {
+ int *data = (int *)my_malloc2(1, 4);
+ my_free1((int*)data);
+ my_free1((int*)data); // expected-warning{{Use of memory after it is freed}}
+}
+
+// TODO: We should warn here.
+void test5() {
+ int *data;
+ my_free1((int*)data);
+}
+
+static char *reshape(char *in) {
+ return 0;
+}
+
+void testThatRemoveDeadBindingsRunBeforeEachCall() {
+ char *v = malloc(12);
+ v = reshape(v);
+ v = reshape(v);// expected-warning {{Memory is never released; potential leak of memory pointed to by 'v'}}
+}
+
+// Test that we keep processing after 'return;'
+void fooWithEmptyReturn(int x) {
+ if (x)
+ return;
+ x++;
+ return;
+}
+
+int uafAndCallsFooWithEmptyReturn() {
+ int *x = (int*)malloc(12);
+ free(x);
+ fooWithEmptyReturn(12);
+ return *x; // expected-warning {{Use of memory after it is freed}}
+}
diff --git a/test/Analysis/malloc-plist.c b/test/Analysis/malloc-plist.c
new file mode 100644
index 000000000000..db2e0f01e73b
--- /dev/null
+++ b/test/Analysis/malloc-plist.c
@@ -0,0 +1,2814 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix.Malloc -analyzer-output=plist -o %t %s
+// RUN: FileCheck --input-file %t %s
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+void *realloc(void *ptr, size_t size);
+
+void diagnosticTest(int in) {
+ if (in > 5) {
+ int *p = malloc(12);
+ (*p)++;
+ }
+ in++; // expected-warning {{leak}}
+}
+
+void myArrayAllocation() {
+ int **A;
+ A = malloc(2*sizeof(int*));
+ A[0] = 0;// expected-warning {{leak}}
+}
+
+void reallocDiagnostics() {
+ char * buf = malloc(100);
+ char * tmp;
+ tmp = (char*)realloc(buf, 0x1000000);
+ if (!tmp) {
+ return;// expected-warning {{leak}}
+ }
+ buf = tmp;
+ free(buf);
+}
+
+void *wrapper() {
+ void *x = malloc(100);
+ // This is intentionally done to test diagnostic emission.
+ if (x)
+ return x;
+ return 0;
+}
+
+void test_wrapper() {
+ void *buf = wrapper();
+ (void) buf;
+}
+
+// Test what happens when the same call frees and allocated memory.
+// Also tests the stack hint for parameters, when they are passed directly or via pointer.
+void my_free(void *x) {
+ free(x);
+}
+void my_malloc_and_free(void **x) {
+ *x = malloc(100);
+ if (*x)
+ my_free(*x);
+ return;
+}
+void *test_double_action_call() {
+ void *buf;
+ my_malloc_and_free(&buf);
+ return buf;
+}
+
+// Test stack hint for 'reallocation failed'.
+char *my_realloc(char *buf) {
+ char *tmp;
+ tmp = (char*)realloc(buf, 0x1000000);
+ if (!tmp) {
+ return tmp;
+ }
+ return tmp;
+}
+void reallocIntra() {
+ char *buf = (char *)malloc(100);
+ buf = my_realloc(buf);
+ free(buf);
+}
+
+// Test stack hint when returning a result.
+static char *malloc_wrapper_ret() {
+ return (char*)malloc(12);
+}
+void use_ret() {
+ char *v;
+ v = malloc_wrapper_ret();
+}
+
+// Test that we refer to the last symbol used in the leak diagnostic.
+void LeakedSymbol(int in) {
+ int *m = 0;
+ int *p;
+ p = (int*)malloc(12);
+ (*p)++;
+ m = p;
+ p = 0;
+ (*m)++;
+ in++;
+}
+
+// CHECK: <?xml version="1.0" encoding="UTF-8"?>
+// CHECK: <plist version="1.0">
+// CHECK: <dict>
+// CHECK: <key>files</key>
+// CHECK: <array>
+// CHECK: </array>
+// CHECK: <key>diagnostics</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>27</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>27</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>27</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;p&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;p&apos;</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by &apos;p&apos;</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Memory leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>diagnosticTest</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>30</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>30</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>30</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>21</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>21</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>21</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;A&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;A&apos;</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by &apos;A&apos;</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Memory leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>myArrayAllocation</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>21</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>40</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>40</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Attempt to reallocate memory</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Attempt to reallocate memory</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>40</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Assuming &apos;tmp&apos; is null</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Assuming &apos;tmp&apos; is null</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Reallocation failed</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Reallocation failed</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>col</key><integer>14</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>col</key><integer>14</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Memory leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>reallocDiagnostics</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>23</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Calling &apos;wrapper&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Calling &apos;wrapper&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>34</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Entered call from &apos;test_wrapper&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Entered call from &apos;test_wrapper&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>34</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>34</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>13</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>23</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>13</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>13</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>23</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>13</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>23</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Assuming &apos;x&apos; is non-null</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Assuming &apos;x&apos; is non-null</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>38</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>38</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>23</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Returned allocated memory</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Returned allocated memory</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>23</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>45</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>45</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>45</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Memory leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_wrapper</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>45</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Calling &apos;my_malloc_and_free&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Calling &apos;my_malloc_and_free&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>52</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Entered call from &apos;test_double_action_call&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Entered call from &apos;test_double_action_call&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>52</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>52</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>20</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>20</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>20</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>17</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Calling &apos;my_free&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Calling &apos;my_free&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>49</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>2</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Entered call from &apos;my_malloc_and_free&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Entered call from &apos;my_malloc_and_free&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>49</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>49</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>2</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is released</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is released</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>17</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>2</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Returned released memory via 1st parameter</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Returned released memory via 1st parameter</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>17</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>56</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>56</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Returned released memory via 1st parameter</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Returned released memory via 1st parameter</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>61</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>61</integer>
+// CHECK: <key>col</key><integer>14</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>61</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>61</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>61</integer>
+// CHECK: <key>col</key><integer>14</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Use of memory after it is freed</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Use of memory after it is freed</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Use of memory after it is freed</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Use-after-free</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_double_action_call</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>61</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>25</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>35</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>25</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>25</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>35</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>25</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>35</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>25</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Calling &apos;my_realloc&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Calling &apos;my_realloc&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>65</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Entered call from &apos;reallocIntra&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Entered call from &apos;reallocIntra&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>65</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>65</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>66</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>66</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>66</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>66</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>40</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>40</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Attempt to reallocate memory</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Attempt to reallocate memory</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>40</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Assuming &apos;tmp&apos; is null</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Assuming &apos;tmp&apos; is null</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Reallocation failed</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Reallocation failed</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>69</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>69</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>25</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Reallocation of 1st parameter failed</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Reallocation of 1st parameter failed</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>25</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>13</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>13</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Memory leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>reallocIntra</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>84</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>84</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Calling &apos;malloc_wrapper_ret&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Calling &apos;malloc_wrapper_ret&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>80</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Entered call from &apos;use_ret&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Entered call from &apos;use_ret&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>80</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>80</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>19</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>19</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>19</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Returned allocated memory</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Returned allocated memory</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>86</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>86</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>86</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;v&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;v&apos;</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by &apos;v&apos;</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Memory leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>use_ret</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>86</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>90</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>90</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>24</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>24</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>24</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>97</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>97</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>97</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>97</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>97</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;m&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;m&apos;</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by &apos;m&apos;</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Memory leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>LeakedSymbol</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>97</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </plist>
+
diff --git a/test/Analysis/malloc-sizeof.c b/test/Analysis/malloc-sizeof.c
new file mode 100644
index 000000000000..d2b3bcf3c84d
--- /dev/null
+++ b/test/Analysis/malloc-sizeof.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.unix.MallocSizeof -verify %s
+
+#include <stddef.h>
+
+void *malloc(size_t size);
+void *calloc(size_t nmemb, size_t size);
+void *realloc(void *ptr, size_t size);
+
+struct A {};
+struct B {};
+
+void foo() {
+ int *ip1 = malloc(sizeof(1));
+ int *ip2 = malloc(4 * sizeof(int));
+
+ long *lp1 = malloc(sizeof(short)); // expected-warning {{Result of 'malloc' is converted to type 'long *', whose pointee type 'long' is incompatible with sizeof operand type 'short'}}
+ long *lp2 = malloc(5 * sizeof(double)); // expected-warning {{Result of 'malloc' is converted to type 'long *', whose pointee type 'long' is incompatible with sizeof operand type 'double'}}
+ long *lp3 = malloc(5 * sizeof(char) + 2); // expected-warning {{Result of 'malloc' is converted to type 'long *', whose pointee type 'long' is incompatible with sizeof operand type 'char'}}
+
+ struct A *ap1 = calloc(1, sizeof(struct A));
+ struct A *ap2 = calloc(2, sizeof(*ap1));
+ struct A *ap3 = calloc(2, sizeof(ap1)); // expected-warning {{Result of 'calloc' is converted to type 'struct A *', whose pointee type 'struct A' is incompatible with sizeof operand type 'struct A *'}}
+ struct A *ap4 = calloc(3, sizeof(struct A*)); // expected-warning {{Result of 'calloc' is converted to type 'struct A *', whose pointee type 'struct A' is incompatible with sizeof operand type 'struct A *'}}
+ struct A *ap5 = calloc(4, sizeof(struct B)); // expected-warning {{Result of 'calloc' is converted to type 'struct A *', whose pointee type 'struct A' is incompatible with sizeof operand type 'struct B'}}
+ struct A *ap6 = realloc(ap5, sizeof(struct A));
+ struct A *ap7 = realloc(ap5, sizeof(struct B)); // expected-warning {{Result of 'realloc' is converted to type 'struct A *', whose pointee type 'struct A' is incompatible with sizeof operand type 'struct B'}}
+}
diff --git a/test/Analysis/malloc.c b/test/Analysis/malloc.c
index d9087ab83093..3b4712320b72 100644
--- a/test/Analysis/malloc.c
+++ b/test/Analysis/malloc.c
@@ -1,42 +1,33 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.core.CastSize,experimental.unix.Malloc -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.core.CastSize,unix.Malloc -analyzer-store=region -verify %s
+#include "system-header-simulator.h"
+
typedef __typeof(sizeof(int)) size_t;
void *malloc(size_t);
+void *valloc(size_t);
void free(void *);
void *realloc(void *ptr, size_t size);
+void *reallocf(void *ptr, size_t size);
void *calloc(size_t nmemb, size_t size);
-void __attribute((ownership_returns(malloc))) *my_malloc(size_t);
-void __attribute((ownership_takes(malloc, 1))) my_free(void *);
-void __attribute((ownership_returns(malloc, 1))) *my_malloc2(size_t);
-void __attribute((ownership_holds(malloc, 1))) my_hold(void *);
-
-// Duplicate attributes are silly, but not an error.
-// Duplicate attribute has no extra effect.
-// If two are of different kinds, that is an error and reported as such.
-void __attribute((ownership_holds(malloc, 1)))
-__attribute((ownership_holds(malloc, 1)))
-__attribute((ownership_holds(malloc, 3))) my_hold2(void *, void *, void *);
-void *my_malloc3(size_t);
-void *myglobalpointer;
-struct stuff {
- void *somefield;
-};
-struct stuff myglobalstuff;
+
+void myfoo(int *p);
+void myfooint(int p);
+char *fooRetPtr();
void f1() {
int *p = malloc(12);
- return; // expected-warning{{Allocated memory never released. Potential memory leak.}}
+ return; // expected-warning{{Memory is never released; potential leak}}
}
void f2() {
int *p = malloc(12);
free(p);
- free(p); // expected-warning{{Try to free a memory block that has been released}}
+ free(p); // expected-warning{{Attempt to free released memory}}
}
void f2_realloc_0() {
int *p = malloc(12);
realloc(p,0);
- realloc(p,0); // expected-warning{{Try to free a memory block that has been released}}
+ realloc(p,0); // expected-warning{{Attempt to free released memory}}
}
void f2_realloc_1() {
@@ -44,105 +35,155 @@ void f2_realloc_1() {
int *q = realloc(p,0); // no-warning
}
-// ownership attributes tests
-void naf1() {
- int *p = my_malloc3(12);
- return; // no-warning
+void reallocNotNullPtr(unsigned sizeIn) {
+ unsigned size = 12;
+ char *p = (char*)malloc(size);
+ if (p) {
+ char *q = (char*)realloc(p, sizeIn);
+ char x = *q; // expected-warning {{Memory is never released; potential leak}}
+ }
}
-void n2af1() {
- int *p = my_malloc2(12);
- return; // expected-warning{{Allocated memory never released. Potential memory leak.}}
+int *realloctest1() {
+ int *q = malloc(12);
+ q = realloc(q, 20);
+ return q; // no warning - returning the allocated value
}
-void af1() {
- int *p = my_malloc(12);
- return; // expected-warning{{Allocated memory never released. Potential memory leak.}}
+// p should be freed if realloc fails.
+void reallocFails() {
+ char *p = malloc(12);
+ char *r = realloc(p, 12+1);
+ if (!r) {
+ free(p);
+ } else {
+ free(r);
+ }
}
-void af1_b() {
- int *p = my_malloc(12); // expected-warning{{Allocated memory never released. Potential memory leak.}}
+void reallocSizeZero1() {
+ char *p = malloc(12);
+ char *r = realloc(p, 0);
+ if (!r) {
+ free(p);
+ } else {
+ free(r);
+ }
}
-void af1_c() {
- myglobalpointer = my_malloc(12); // no-warning
+void reallocSizeZero2() {
+ char *p = malloc(12);
+ char *r = realloc(p, 0);
+ if (!r) {
+ free(p);
+ } else {
+ free(r);
+ }
+ free(p); // expected-warning {{Attempt to free released memory}}
}
-void af1_d() {
- struct stuff mystuff;
- mystuff.somefield = my_malloc(12); // expected-warning{{Allocated memory never released. Potential memory leak.}}
+void reallocSizeZero3() {
+ char *p = malloc(12);
+ char *r = realloc(p, 0);
+ free(r);
}
-// Test that we can pass out allocated memory via pointer-to-pointer.
-void af1_e(void **pp) {
- *pp = my_malloc(42); // no-warning
+void reallocSizeZero4() {
+ char *r = realloc(0, 0);
+ free(r);
}
-void af1_f(struct stuff *somestuff) {
- somestuff->somefield = my_malloc(12); // no-warning
+void reallocSizeZero5() {
+ char *r = realloc(0, 0);
}
-// Allocating memory for a field via multiple indirections to our arguments is OK.
-void af1_g(struct stuff **pps) {
- *pps = my_malloc(sizeof(struct stuff)); // no-warning
- (*pps)->somefield = my_malloc(42); // no-warning
+void reallocPtrZero1() {
+ char *r = realloc(0, 12); // expected-warning {{Memory is never released; potential leak}}
}
-void af2() {
- int *p = my_malloc(12);
- my_free(p);
- free(p); // expected-warning{{Try to free a memory block that has been released}}
+void reallocPtrZero2() {
+ char *r = realloc(0, 12);
+ if (r)
+ free(r);
}
-void af2b() {
- int *p = my_malloc(12);
- free(p);
- my_free(p); // expected-warning{{Try to free a memory block that has been released}}
+void reallocPtrZero3() {
+ char *r = realloc(0, 12);
+ free(r);
}
-void af2c() {
- int *p = my_malloc(12);
- free(p);
- my_hold(p); // expected-warning{{Try to free a memory block that has been released}}
+void reallocRadar6337483_1() {
+ char *buf = malloc(100);
+ buf = (char*)realloc(buf, 0x1000000);
+ if (!buf) {
+ return;// expected-warning {{Memory is never released; potential leak}}
+ }
+ free(buf);
}
-void af2d() {
- int *p = my_malloc(12);
- free(p);
- my_hold2(0, 0, p); // expected-warning{{Try to free a memory block that has been released}}
+void reallocRadar6337483_2() {
+ char *buf = malloc(100);
+ char *buf2 = (char*)realloc(buf, 0x1000000);
+ if (!buf2) { // expected-warning {{Memory is never released; potential leak}}
+ ;
+ } else {
+ free(buf2);
+ }
}
-// No leak if malloc returns null.
-void af2e() {
- int *p = my_malloc(12);
- if (!p)
- return; // no-warning
- free(p); // no-warning
+void reallocRadar6337483_3() {
+ char * buf = malloc(100);
+ char * tmp;
+ tmp = (char*)realloc(buf, 0x1000000);
+ if (!tmp) {
+ free(buf);
+ return;
+ }
+ buf = tmp;
+ free(buf);
}
-// This case would inflict a double-free elsewhere.
-// However, this case is considered an analyzer bug since it causes false-positives.
-void af3() {
- int *p = my_malloc(12);
- my_hold(p);
- free(p); // no-warning
+void reallocRadar6337483_4() {
+ char *buf = malloc(100);
+ char *buf2 = (char*)realloc(buf, 0x1000000);
+ if (!buf2) {
+ return; // expected-warning {{Memory is never released; potential leak}}
+ } else {
+ free(buf2);
+ }
}
-// This case would inflict a double-free elsewhere.
-// However, this case is considered an analyzer bug since it causes false-positives.
-int * af4() {
- int *p = my_malloc(12);
- my_free(p);
- return p; // no-warning
+int *reallocfTest1() {
+ int *q = malloc(12);
+ q = reallocf(q, 20);
+ return q; // no warning - returning the allocated value
}
-// This case is (possibly) ok, be conservative
-int * af5() {
- int *p = my_malloc(12);
- my_hold(p);
- return p; // no-warning
+void reallocfRadar6337483_4() {
+ char *buf = malloc(100);
+ char *buf2 = (char*)reallocf(buf, 0x1000000);
+ if (!buf2) {
+ return; // no warning - reallocf frees even on failure
+ } else {
+ free(buf2);
+ }
}
+void reallocfRadar6337483_3() {
+ char * buf = malloc(100);
+ char * tmp;
+ tmp = (char*)reallocf(buf, 0x1000000);
+ if (!tmp) {
+ free(buf); // expected-warning {{Attempt to free released memory}}
+ return;
+ }
+ buf = tmp;
+ free(buf);
+}
+
+void reallocfPtrZero1() {
+ char *r = reallocf(0, 12); // expected-warning {{Memory is never released; potential leak}}
+}
// This case tests that storing malloc'ed memory to a static variable which is
@@ -199,13 +240,13 @@ void pr6293() {
void f7() {
char *x = (char*) malloc(4);
free(x);
- x[0] = 'a'; // expected-warning{{Use dynamically allocated memory after it is freed.}}
+ x[0] = 'a'; // expected-warning{{Use of memory after it is freed}}
}
void f7_realloc() {
char *x = (char*) malloc(4);
realloc(x,0);
- x[0] = 'a'; // expected-warning{{Use dynamically allocated memory after it is freed.}}
+ x[0] = 'a'; // expected-warning{{Use of memory after it is freed}}
}
void PR6123() {
@@ -261,3 +302,508 @@ char callocZeroesBad () {
}
return result; // expected-warning{{never released}}
}
+
+void nullFree() {
+ int *p = 0;
+ free(p); // no warning - a nop
+}
+
+void paramFree(int *p) {
+ myfoo(p);
+ free(p); // no warning
+ myfoo(p); // TODO: This should be a warning.
+}
+
+int* mallocEscapeRet() {
+ int *p = malloc(12);
+ return p; // no warning
+}
+
+void mallocEscapeFoo() {
+ int *p = malloc(12);
+ myfoo(p);
+ return; // no warning
+}
+
+void mallocEscapeFree() {
+ int *p = malloc(12);
+ myfoo(p);
+ free(p);
+}
+
+void mallocEscapeFreeFree() {
+ int *p = malloc(12);
+ myfoo(p);
+ free(p);
+ free(p); // expected-warning{{Attempt to free released memory}}
+}
+
+void mallocEscapeFreeUse() {
+ int *p = malloc(12);
+ myfoo(p);
+ free(p);
+ myfoo(p); // expected-warning{{Use of memory after it is freed}}
+}
+
+int *myalloc();
+void myalloc2(int **p);
+
+void mallocEscapeFreeCustomAlloc() {
+ int *p = malloc(12);
+ myfoo(p);
+ free(p);
+ p = myalloc();
+ free(p); // no warning
+}
+
+void mallocEscapeFreeCustomAlloc2() {
+ int *p = malloc(12);
+ myfoo(p);
+ free(p);
+ myalloc2(&p);
+ free(p); // no warning
+}
+
+void mallocBindFreeUse() {
+ int *x = malloc(12);
+ int *y = x;
+ free(y);
+ myfoo(x); // expected-warning{{Use of memory after it is freed}}
+}
+
+void mallocEscapeMalloc() {
+ int *p = malloc(12);
+ myfoo(p);
+ p = malloc(12); // expected-warning{{Memory is never released; potential leak}}
+}
+
+void mallocMalloc() {
+ int *p = malloc(12);
+ p = malloc(12); // expected-warning 2 {{Memory is never released; potential leak}}
+}
+
+void mallocFreeMalloc() {
+ int *p = malloc(12);
+ free(p);
+ p = malloc(12);
+ free(p);
+}
+
+void mallocFreeUse_params() {
+ int *p = malloc(12);
+ free(p);
+ myfoo(p); //expected-warning{{Use of memory after it is freed}}
+}
+
+void mallocFreeUse_params2() {
+ int *p = malloc(12);
+ free(p);
+ myfooint(*p); //expected-warning{{Use of memory after it is freed}}
+}
+
+void mallocFailedOrNot() {
+ int *p = malloc(12);
+ if (!p)
+ free(p);
+ else
+ free(p);
+}
+
+struct StructWithInt {
+ int g;
+};
+
+int *mallocReturnFreed() {
+ int *p = malloc(12);
+ free(p);
+ return p; // expected-warning {{Use of memory after it is freed}}
+}
+
+int useAfterFreeStruct() {
+ struct StructWithInt *px= malloc(sizeof(struct StructWithInt));
+ px->g = 5;
+ free(px);
+ return px->g; // expected-warning {{Use of memory after it is freed}}
+}
+
+void nonSymbolAsFirstArg(int *pp, struct StructWithInt *p);
+
+void mallocEscapeFooNonSymbolArg() {
+ struct StructWithInt *p = malloc(sizeof(struct StructWithInt));
+ nonSymbolAsFirstArg(&p->g, p);
+ return; // no warning
+}
+
+void mallocFailedOrNotLeak() {
+ int *p = malloc(12);
+ if (p == 0)
+ return; // no warning
+ else
+ return; // expected-warning {{Memory is never released; potential leak}}
+}
+
+void mallocAssignment() {
+ char *p = malloc(12);
+ p = fooRetPtr(); // expected-warning {{leak}}
+}
+
+int vallocTest() {
+ char *mem = valloc(12);
+ return 0; // expected-warning {{Memory is never released; potential leak}}
+}
+
+void vallocEscapeFreeUse() {
+ int *p = valloc(12);
+ myfoo(p);
+ free(p);
+ myfoo(p); // expected-warning{{Use of memory after it is freed}}
+}
+
+int *Gl;
+struct GlStTy {
+ int *x;
+};
+
+struct GlStTy GlS = {0};
+
+void GlobalFree() {
+ free(Gl);
+}
+
+void GlobalMalloc() {
+ Gl = malloc(12);
+}
+
+void GlobalStructMalloc() {
+ int *a = malloc(12);
+ GlS.x = a;
+}
+
+void GlobalStructMallocFree() {
+ int *a = malloc(12);
+ GlS.x = a;
+ free(GlS.x);
+}
+
+char *ArrayG[12];
+
+void globalArrayTest() {
+ char *p = (char*)malloc(12);
+ ArrayG[0] = p;
+}
+
+// Make sure that we properly handle a pointer stored into a local struct/array.
+typedef struct _StructWithPtr {
+ int *memP;
+} StructWithPtr;
+
+static StructWithPtr arrOfStructs[10];
+
+void testMalloc() {
+ int *x = malloc(12);
+ StructWithPtr St;
+ St.memP = x;
+ arrOfStructs[0] = St;
+}
+
+StructWithPtr testMalloc2() {
+ int *x = malloc(12);
+ StructWithPtr St;
+ St.memP = x;
+ return St;
+}
+
+int *testMalloc3() {
+ int *x = malloc(12);
+ int *y = x;
+ return y;
+}
+
+void testElemRegion1() {
+ char *x = (void*)malloc(2);
+ int *ix = (int*)x;
+ free(&(x[0]));
+}
+
+void testElemRegion2(int **pp) {
+ int *p = malloc(12);
+ *pp = p;
+ free(pp[0]);
+}
+
+void testElemRegion3(int **pp) {
+ int *p = malloc(12);
+ *pp = p;
+ free(*pp);
+}
+// Region escape testing.
+
+unsigned takePtrToPtr(int **p);
+void PassTheAddrOfAllocatedData(int f) {
+ int *p = malloc(12);
+ // We don't know what happens after the call. Should stop tracking here.
+ if (takePtrToPtr(&p))
+ f++;
+ free(p); // no warning
+}
+
+struct X {
+ int *p;
+};
+unsigned takePtrToStruct(struct X *s);
+int ** foo2(int *g, int f) {
+ int *p = malloc(12);
+ struct X *px= malloc(sizeof(struct X));
+ px->p = p;
+ // We don't know what happens after this call. Should not track px nor p.
+ if (takePtrToStruct(px))
+ f++;
+ free(p);
+ return 0;
+}
+
+struct X* RegInvalidationDetect1(struct X *s2) {
+ struct X *px= malloc(sizeof(struct X));
+ px->p = 0;
+ px = s2;
+ return px; // expected-warning {{Memory is never released; potential leak}}
+}
+
+struct X* RegInvalidationGiveUp1() {
+ int *p = malloc(12);
+ struct X *px= malloc(sizeof(struct X));
+ px->p = p;
+ return px;
+}
+
+int **RegInvalidationDetect2(int **pp) {
+ int *p = malloc(12);
+ pp = &p;
+ pp++;
+ return 0;// expected-warning {{Memory is never released; potential leak}}
+}
+
+extern void exit(int) __attribute__ ((__noreturn__));
+void mallocExit(int *g) {
+ struct xx *p = malloc(12);
+ if (g != 0)
+ exit(1);
+ free(p);
+ return;
+}
+
+extern void __assert_fail (__const char *__assertion, __const char *__file,
+ unsigned int __line, __const char *__function)
+ __attribute__ ((__noreturn__));
+#define assert(expr) \
+ ((expr) ? (void)(0) : __assert_fail (#expr, __FILE__, __LINE__, __func__))
+void mallocAssert(int *g) {
+ struct xx *p = malloc(12);
+
+ assert(g != 0);
+ free(p);
+ return;
+}
+
+void doNotInvalidateWhenPassedToSystemCalls(char *s) {
+ char *p = malloc(12);
+ strlen(p);
+ strcpy(p, s); // expected-warning {{leak}}
+}
+
+// Rely on the CString checker evaluation of the strcpy API to convey that the result of strcpy is equal to p.
+void symbolLostWithStrcpy(char *s) {
+ char *p = malloc(12);
+ p = strcpy(p, s);
+ free(p);
+}
+
+
+// The same test as the one above, but with what is actually generated on a mac.
+static __inline char *
+__inline_strcpy_chk (char *restrict __dest, const char *restrict __src)
+{
+ return __builtin___strcpy_chk (__dest, __src, __builtin_object_size (__dest, 2 > 1));
+}
+
+void symbolLostWithStrcpy_InlineStrcpyVersion(char *s) {
+ char *p = malloc(12);
+ p = ((__builtin_object_size (p, 0) != (size_t) -1) ? __builtin___strcpy_chk (p, s, __builtin_object_size (p, 2 > 1)) : __inline_strcpy_chk (p, s));
+ free(p);
+}
+
+// Here we are returning a pointer one past the allocated value. An idiom which
+// can be used for implementing special malloc. The correct uses of this might
+// be rare enough so that we could keep this as a warning.
+static void *specialMalloc(int n){
+ int *p;
+ p = malloc( n+8 );
+ if( p ){
+ p[0] = n;
+ p++;
+ }
+ return p;
+}
+
+// Potentially, the user could free the struct by performing pointer arithmetic on the return value.
+// This is a variation of the specialMalloc issue, though probably would be more rare in correct code.
+int *specialMallocWithStruct() {
+ struct StructWithInt *px= malloc(sizeof(struct StructWithInt));
+ return &(px->g);
+}
+
+// Test various allocation/deallocation functions.
+
+char *strdup(const char *s);
+char *strndup(const char *s, size_t n);
+
+void testStrdup(const char *s, unsigned validIndex) {
+ char *s2 = strdup(s);
+ s2[validIndex + 1] = 'b';// expected-warning {{Memory is never released; potential leak}}
+}
+
+int testStrndup(const char *s, unsigned validIndex, unsigned size) {
+ char *s2 = strndup(s, size);
+ s2 [validIndex + 1] = 'b';
+ if (s2[validIndex] != 'a')
+ return 0;
+ else
+ return 1;// expected-warning {{Memory is never released; potential leak}}
+}
+
+void testStrdupContentIsDefined(const char *s, unsigned validIndex) {
+ char *s2 = strdup(s);
+ char result = s2[1];// no warning
+ free(s2);
+}
+
+// ----------------------------------------------------------------------------
+// Test the system library functions to which the pointer can escape.
+// This tests false positive suppression.
+
+// For now, we assume memory passed to pthread_specific escapes.
+// TODO: We could check that if a new pthread binding is set, the existing
+// binding must be freed; otherwise, a memory leak can occur.
+void testPthereadSpecificEscape(pthread_key_t key) {
+ void *buf = malloc(12);
+ pthread_setspecific(key, buf); // no warning
+}
+
+// PR12101: Test funopen().
+static int releasePtr(void *_ctx) {
+ free(_ctx);
+ return 0;
+}
+FILE *useFunOpen() {
+ void *ctx = malloc(sizeof(int));
+ FILE *f = funopen(ctx, 0, 0, 0, releasePtr); // no warning
+ if (f == 0) {
+ free(ctx);
+ }
+ return f;
+}
+FILE *useFunOpenNoReleaseFunction() {
+ void *ctx = malloc(sizeof(int));
+ FILE *f = funopen(ctx, 0, 0, 0, 0);
+ if (f == 0) {
+ free(ctx);
+ }
+ return f; // expected-warning{{leak}}
+}
+
+// Test setbuf, setvbuf.
+int my_main_no_warning() {
+ char *p = malloc(100);
+ setvbuf(stdout, p, 0, 100);
+ return 0;
+}
+int my_main_no_warning2() {
+ char *p = malloc(100);
+ setbuf(__stdoutp, p);
+ return 0;
+}
+int my_main_warn(FILE *f) {
+ char *p = malloc(100);
+ setvbuf(f, p, 0, 100);
+ return 0;// expected-warning {{leak}}
+}
+
+// <rdar://problem/10978247>.
+// some people use stack allocated memory as an optimization to avoid
+// a heap allocation for small work sizes. This tests the analyzer's
+// understanding that the malloc'ed memory is not the same as stackBuffer.
+void radar10978247(int myValueSize) {
+ char stackBuffer[128];
+ char *buffer;
+
+ if (myValueSize <= sizeof(stackBuffer))
+ buffer = stackBuffer;
+ else
+ buffer = malloc(myValueSize);
+
+ // do stuff with the buffer
+ if (buffer != stackBuffer)
+ free(buffer);
+}
+
+void radar10978247_positive(int myValueSize) {
+ char stackBuffer[128];
+ char *buffer;
+
+ if (myValueSize <= sizeof(stackBuffer))
+ buffer = stackBuffer;
+ else
+ buffer = malloc(myValueSize);
+
+ // do stuff with the buffer
+ if (buffer == stackBuffer) // expected-warning {{leak}}
+ return;
+}
+
+// ----------------------------------------------------------------------------
+// Below are the known false positives.
+
+// TODO: There should be no warning here. This one might be difficult to get rid of.
+void dependsOnValueOfPtr(int *g, unsigned f) {
+ int *p;
+
+ if (f) {
+ p = g;
+ } else {
+ p = malloc(12);
+ }
+
+ if (p != g)
+ free(p);
+ else
+ return; // expected-warning{{Memory is never released; potential leak}}
+ return;
+}
+
+// ----------------------------------------------------------------------------
+// False negatives.
+
+// TODO: This requires tracking symbols stored inside the structs/arrays.
+void testMalloc5() {
+ StructWithPtr St;
+ StructWithPtr *pSt = &St;
+ pSt->memP = malloc(12);
+}
+
+// TODO: This is another false negative.
+void testMallocWithParam(int **p) {
+ *p = (int*) malloc(sizeof(int));
+ *p = 0;
+}
+
+void testMallocWithParam_2(int **p) {
+ *p = (int*) malloc(sizeof(int));
+}
+
+// TODO: This should produce a warning, similar to the previous issue.
+void localArrayTest() {
+ char *p = (char*)malloc(12);
+ char *ArrayL[12];
+ ArrayL[0] = p;
+}
+
diff --git a/test/Analysis/malloc.cpp b/test/Analysis/malloc.cpp
new file mode 100644
index 000000000000..8f80b2b76f29
--- /dev/null
+++ b/test/Analysis/malloc.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.core.CastSize,unix.Malloc -analyzer-store=region -verify %s
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+void *realloc(void *ptr, size_t size);
+void *calloc(size_t nmemb, size_t size);
+
+// Test for radar://11110132.
+struct Foo {
+ mutable void* m_data;
+ Foo(void* data) : m_data(data) {}
+};
+Foo aFunction() {
+ return malloc(10);
+}
diff --git a/test/Analysis/malloc.m b/test/Analysis/malloc.m
new file mode 100644
index 000000000000..6c94118286ab
--- /dev/null
+++ b/test/Analysis/malloc.m
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify -Wno-objc-root-class %s
+#include "system-header-simulator-objc.h"
+
+@class NSString;
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+
+// RDar10579586 - Test use of malloc() with Objective-C string literal as a
+// test condition. Not really a malloc() issue, but this also exercises
+// the check that malloc() returns uninitialized memory.
+@interface RDar10579586
+struct rdar0579586_str {
+ char str_c;
+};
+@end
+
+void rdar10579586(char x);
+
+@implementation RDar10579586
++ (NSString *)foobar
+{
+ struct rdar0579586_str *buffer = ((void*)0);
+ NSString *error = ((void*)0);
+
+ if ((buffer = malloc(sizeof(struct rdar0579586_str))) == ((void*)0))
+ error = @"buffer allocation failure";
+
+ if (error != ((void*)0))
+ return error;
+
+ rdar10579586(buffer->str_c); // expected-warning {{Function call argument is an uninitialized value}}
+ free(buffer);
+ return ((void*)0);
+}
+@end
+
diff --git a/test/Analysis/malloc.mm b/test/Analysis/malloc.mm
new file mode 100644
index 000000000000..3515a4f99af0
--- /dev/null
+++ b/test/Analysis/malloc.mm
@@ -0,0 +1,156 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify -fblocks %s
+#include "system-header-simulator-objc.h"
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+
+// Done with headers. Start testing.
+void testNSDatafFreeWhenDoneNoError(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSData *nsdata = [NSData dataWithBytesNoCopy:data length:dataLength];
+ free(data); // no warning
+}
+
+void testNSDataFreeWhenDoneYES(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSData *nsdata = [NSData dataWithBytesNoCopy:data length:dataLength freeWhenDone:1]; // no-warning
+}
+
+void testNSDataFreeWhenDoneYES2(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSData *nsdata = [[NSData alloc] initWithBytesNoCopy:data length:dataLength freeWhenDone:1]; // no-warning
+}
+
+
+void testNSStringFreeWhenDoneYES(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSString *nsstr = [[NSString alloc] initWithBytesNoCopy:data length:dataLength encoding:NSUTF8StringEncoding freeWhenDone:1]; // no-warning
+}
+
+void testNSStringFreeWhenDoneYES2(NSUInteger dataLength) {
+ unichar *data = (unichar*)malloc(42);
+ NSString *nsstr = [[NSString alloc] initWithCharactersNoCopy:data length:dataLength freeWhenDone:1]; // no-warning
+}
+
+
+void testNSDataFreeWhenDoneNO(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSData *nsdata = [NSData dataWithBytesNoCopy:data length:dataLength freeWhenDone:0]; // expected-warning{{leak}}
+}
+
+void testNSDataFreeWhenDoneNO2(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSData *nsdata = [[NSData alloc] initWithBytesNoCopy:data length:dataLength freeWhenDone:0]; // expected-warning{{leak}}
+}
+
+
+void testNSStringFreeWhenDoneNO(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSString *nsstr = [[NSString alloc] initWithBytesNoCopy:data length:dataLength encoding:NSUTF8StringEncoding freeWhenDone:0]; // expected-warning{{leak}}
+}
+
+void testNSStringFreeWhenDoneNO2(NSUInteger dataLength) {
+ unichar *data = (unichar*)malloc(42);
+ NSString *nsstr = [[NSString alloc] initWithCharactersNoCopy:data length:dataLength freeWhenDone:0]; // expected-warning{{leak}}
+}
+
+// TODO: False Negative.
+void testNSDatafFreeWhenDoneFN(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSData *nsdata = [NSData dataWithBytesNoCopy:data length:dataLength freeWhenDone:1];
+ free(data); // false negative
+}
+
+// Test CF/NS...NoCopy. PR12100: Pointers can escape when custom deallocators are provided.
+void testNSDatafFreeWhenDone(NSUInteger dataLength) {
+ CFStringRef str;
+ char *bytes = (char*)malloc(12);
+ str = CFStringCreateWithCStringNoCopy(0, bytes, NSNEXTSTEPStringEncoding, 0); // no warning
+ CFRelease(str); // default allocator also frees bytes
+}
+
+void stringWithExternalContentsExample(void) {
+#define BufferSize 1000
+ CFMutableStringRef mutStr;
+ UniChar *myBuffer;
+
+ myBuffer = (UniChar *)malloc(BufferSize * sizeof(UniChar));
+
+ mutStr = CFStringCreateMutableWithExternalCharactersNoCopy(0, myBuffer, 0, BufferSize, kCFAllocatorNull); // expected-warning{{leak}}
+
+ CFRelease(mutStr);
+ //free(myBuffer);
+}
+
+// PR12101 : pointers can escape through custom deallocators set on creation of a container.
+void TestCallbackReleasesMemory(CFDictionaryKeyCallBacks keyCallbacks) {
+ void *key = malloc(12);
+ void *val = malloc(12);
+ CFMutableDictionaryRef x = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &keyCallbacks, &kCFTypeDictionaryValueCallBacks);
+ CFDictionarySetValue(x, key, val);
+ return;// no-warning
+}
+
+NSData *radar10976702() {
+ void *bytes = malloc(10);
+ return [NSData dataWithBytesNoCopy:bytes length:10]; // no-warning
+}
+
+void testBlocks() {
+ int *x= (int*)malloc(sizeof(int));
+ int (^myBlock)(int) = ^(int num) {
+ free(x);
+ return num;
+ };
+ myBlock(3);
+}
+
+// Test NSMapInsert.
+@interface NSMapTable : NSObject <NSCopying, NSCoding, NSFastEnumeration>
+@end
+extern void *NSMapGet(NSMapTable *table, const void *key);
+extern void NSMapInsert(NSMapTable *table, const void *key, const void *value);
+extern void NSMapInsertKnownAbsent(NSMapTable *table, const void *key, const void *value);
+char *strdup(const char *s);
+
+NSString * radar11152419(NSString *string1, NSMapTable *map) {
+ const char *strkey = "key";
+ NSString *string = ( NSString *)NSMapGet(map, strkey);
+ if (!string) {
+ string = [string1 copy];
+ NSMapInsert(map, strdup(strkey), (void*)string); // no warning
+ NSMapInsertKnownAbsent(map, strdup(strkey), (void*)string); // no warning
+ }
+ return string;
+}
+
+// Test that we handle pointer escaping through OSAtomicEnqueue.
+typedef volatile struct {
+ void *opaque1;
+ long opaque2;
+} OSQueueHead;
+void OSAtomicEnqueue( OSQueueHead *__list, void *__new, size_t __offset) __attribute__((weak_import));
+static inline void radar11111210(OSQueueHead *pool) {
+ void *newItem = malloc(4);
+ OSAtomicEnqueue(pool, newItem, 4);
+}
+
+// Pointer might escape through CGDataProviderCreateWithData (radar://11187558).
+typedef struct CGDataProvider *CGDataProviderRef;
+typedef void (*CGDataProviderReleaseDataCallback)(void *info, const void *data,
+ size_t size);
+extern CGDataProviderRef CGDataProviderCreateWithData(void *info,
+ const void *data, size_t size,
+ CGDataProviderReleaseDataCallback releaseData)
+ __attribute__((visibility("default")));
+void *calloc(size_t, size_t);
+
+static void releaseDataCallback (void *info, const void *data, size_t size) {
+#pragma unused (info, size)
+ free((void*)data);
+}
+void testCGDataProviderCreateWithData() {
+ void* b = calloc(8, 8);
+ CGDataProviderRef p = CGDataProviderCreateWithData(0, b, 8*8, releaseDataCallback);
+} \ No newline at end of file
diff --git a/test/Analysis/method-arg-decay.m b/test/Analysis/method-arg-decay.m
index 9ce88b242327..a36d81e82b52 100644
--- a/test/Analysis/method-arg-decay.m
+++ b/test/Analysis/method-arg-decay.m
@@ -56,7 +56,7 @@ PBXFindMatchContains, PBXFindMatchStartsWith, PBXFindMatchWholeWords,
@interface PBXProjectModule : PBXModule <PBXFindableText> {
}
@end @class PBXBookmark;
-@protocol PBXSelectionTarget - (NSObject <PBXSelectionTarget> *) performAction:(id)action withSelection:(NSArray *)selection; // expected-note {{method declared here}}
+@protocol PBXSelectionTarget - (NSObject <PBXSelectionTarget> *) performAction:(id)action withSelection:(NSArray *)selection; // expected-note {{method 'performAction:withSelection:' declared here}}
@end @class XCPropertyDictionary, XCPropertyCondition, XCPropertyConditionSet, XCMutablePropertyConditionSet;
extern NSMutableArray *XCFindPossibleKeyModules(PBXModule *module, BOOL useExposedModulesOnly);
@interface NSString (StringUtilities) - (NSString *) trimToLength:(NSInteger)length preserveRange:(NSRange)range;
@@ -72,8 +72,7 @@ extern NSMutableArray *XCFindPossibleKeyModules(PBXModule *module, BOOL useExpos
}
- (PBXModule *) moduleForTab:(NSTabViewItem *)item; // expected-note {{method definition for 'moduleForTab:' not found}}
@end
-@implementation XCPerspectiveModule // expected-warning {{incomplete implementation}} \
- // expected-warning {{method in protocol not implemented [-Wprotocol]}}
+@implementation XCPerspectiveModule // expected-warning {{incomplete implementation}} expected-warning {{method 'performAction:withSelection:' in protocol not implemented}}}
+ (void) openForProjectDocument:(PBXProjectDocument *)projectDocument {
}
- (PBXModule *) type:(Class)type inPerspective:(id)perspectiveIdentifer matchingFunction:(BOOL (void *, void *))comparator usingData:(void *)data {
diff --git a/test/Analysis/method-call-intra-p.cpp b/test/Analysis/method-call-intra-p.cpp
new file mode 100644
index 000000000000..701479faa820
--- /dev/null
+++ b/test/Analysis/method-call-intra-p.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -verify %s
+
+// Intra-procedural C++ tests.
+
+// Test relaxing function call arguments invalidation to be aware of const
+// arguments. radar://10595327
+struct InvalidateArgs {
+ void ttt(const int &nptr);
+ virtual void vttt(const int *nptr);
+};
+struct ChildOfInvalidateArgs: public InvalidateArgs {
+ virtual void vttt(const int *nptr);
+};
+void declarationFun(int x) {
+ InvalidateArgs t;
+ x = 3;
+ int y = x + 1;
+ int *p = 0;
+ t.ttt(y);
+ if (x == y)
+ y = *p; // no-warning
+}
+void virtualFun(int x) {
+ ChildOfInvalidateArgs t;
+ InvalidateArgs *pt = &t;
+ x = 3;
+ int y = x + 1;
+ int *p = 0;
+ pt->vttt(&y);
+ if (x == y)
+ y = *p; // no-warning
+}
diff --git a/test/Analysis/misc-ps-cxx0x.cpp b/test/Analysis/misc-ps-cxx0x.cpp
index 53b6fa29ad6e..b4dee3122e2c 100644
--- a/test/Analysis/misc-ps-cxx0x.cpp
+++ b/test/Analysis/misc-ps-cxx0x.cpp
@@ -68,3 +68,8 @@ void test2() {
*p = 0xDEADBEEF; // no-warning
}
+// Do not crash on the following when constructing the
+// callgraph.
+struct RDar11178609 {
+ ~RDar11178609() = delete;
+};
diff --git a/test/Analysis/misc-ps-region-store.cpp b/test/Analysis/misc-ps-region-store.cpp
index 37153f765062..8d75fb8ef350 100644
--- a/test/Analysis/misc-ps-region-store.cpp
+++ b/test/Analysis/misc-ps-region-store.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s -fexceptions -fcxx-exceptions
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s -fexceptions -fcxx-exceptions
// Test basic handling of references.
char &test1_aux();
@@ -466,4 +466,115 @@ void rdar10202899_test3() {
*p = 0xDEADBEEF;
}
+// This used to crash the analyzer because of the unnamed bitfield.
+void PR11249()
+{
+ struct {
+ char f1:4;
+ char :4;
+ char f2[1];
+ char f3;
+ } V = { 1, {2}, 3 };
+ int *p = 0;
+ if (V.f1 != 1)
+ *p = 0xDEADBEEF; // no-warning
+ if (V.f2[0] != 2)
+ *p = 0xDEADBEEF; // no-warning
+ if (V.f3 != 3)
+ *p = 0xDEADBEEF; // no-warning
+}
+
+// Handle doing a load from the memory associated with the code for
+// a function.
+extern double nan( const char * );
+double PR11450() {
+ double NaN = *(double*) nan;
+ return NaN;
+}
+
+// Test that 'this' is assumed non-null upon analyzing the entry to a "top-level"
+// function (i.e., when not analyzing from a specific caller).
+struct TestNullThis {
+ int field;
+ void test();
+};
+
+void TestNullThis::test() {
+ int *p = &field;
+ if (p)
+ return;
+ field = 2; // no-warning
+}
+
+// Test handling of 'catch' exception variables, and not warning
+// about uninitialized values.
+enum MyEnum { MyEnumValue };
+MyEnum rdar10892489() {
+ try {
+ throw MyEnumValue;
+ } catch (MyEnum e) {
+ return e; // no-warning
+ }
+ return MyEnumValue;
+}
+MyEnum rdar10892489_positive() {
+ try {
+ throw MyEnumValue;
+ } catch (MyEnum e) {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+ return e;
+ }
+ return MyEnumValue;
+}
+
+// Test handling of catch with no condition variable.
+void PR11545() {
+ try
+ {
+ throw;
+ }
+ catch (...)
+ {
+ }
+}
+
+void PR11545_positive() {
+ try
+ {
+ throw;
+ }
+ catch (...)
+ {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+ }
+}
+
+// Test handling taking the address of a field. While the analyzer
+// currently doesn't do anything intelligent here, this previously
+// resulted in a crash.
+class PR11146 {
+public:
+ struct Entry;
+ void baz();
+};
+
+struct PR11146::Entry {
+ int x;
+};
+
+void PR11146::baz() {
+ (void) &Entry::x;
+}
+
+// Test symbolicating a reference. In this example, the
+// analyzer (originally) didn't know how to handle x[index - index2],
+// returning an UnknownVal. The conjured symbol wasn't a location,
+// and would result in a crash.
+void rdar10924675(unsigned short x[], int index, int index2) {
+ unsigned short &y = x[index - index2];
+ if (y == 0)
+ return;
+}
diff --git a/test/Analysis/misc-ps-region-store.m b/test/Analysis/misc-ps-region-store.m
index 0fdab83d7f8a..d263d4da30cc 100644
--- a/test/Analysis/misc-ps-region-store.m
+++ b/test/Analysis/misc-ps-region-store.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,deadcode.IdempotentOperations,experimental.core.CastToStruct,experimental.security.ReturnPtrRange,experimental.security.ArrayBound -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -DTEST_64 -analyze -analyzer-checker=core,deadcode.IdempotentOperations,experimental.core.CastToStruct,experimental.security.ReturnPtrRange,experimental.security.ArrayBound -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core.CastToStruct,experimental.security.ReturnPtrRange,experimental.security.ArrayBound -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -DTEST_64 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core.CastToStruct,experimental.security.ReturnPtrRange,experimental.security.ArrayBound -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class %s
typedef long unsigned int size_t;
void *memcpy(void *, const void *, size_t);
@@ -294,9 +294,11 @@ int test_invalidate_field_test_positive() {
struct ArrayWrapper { unsigned char y[16]; };
struct WrappedStruct { unsigned z; };
+void test_handle_array_wrapper_helper();
+
int test_handle_array_wrapper() {
struct ArrayWrapper x;
- test_handle_array_wrapper(&x);
+ test_handle_array_wrapper_helper(&x);
struct WrappedStruct *p = (struct WrappedStruct*) x.y; // expected-warning{{Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption.}}
return p->z; // no-warning
}
@@ -918,7 +920,7 @@ int rdar_7770737_pos(void)
void pr6302(id x, Class y) {
// This previously crashed the analyzer (reported in PR 6302)
- x->isa = y;
+ x->isa = y; // expected-warning {{direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()}}
}
//===----------------------------------------------------------------------===//
@@ -1323,3 +1325,19 @@ void rdar9444714() {
*dst = '\0';
}
+// Test handling symbolic elements with field accesses.
+// <rdar://problem/11127008>
+typedef struct {
+ unsigned value;
+} RDar11127008;
+
+signed rdar_11127008_index();
+
+static unsigned rdar_11127008(void) {
+ RDar11127008 values[] = {{.value = 0}, {.value = 1}};
+ signed index = rdar_11127008_index();
+ if (index < 0) return 0;
+ if (index >= 2) return 0;
+ return values[index].value;
+}
+
diff --git a/test/Analysis/misc-ps-region-store.mm b/test/Analysis/misc-ps-region-store.mm
index fee9433dac3b..8615c6a9c7fd 100644
--- a/test/Analysis/misc-ps-region-store.mm
+++ b/test/Analysis/misc-ps-region-store.mm
@@ -29,3 +29,20 @@ char Test1_harness_b(Test1 *p) {
return [p foo];
}
+// Basic test of C++ references with Objective-C pointers.
+@interface RDar10569024
+@property(readonly) int x;
+@end
+
+typedef RDar10569024* RDar10569024Ref;
+
+void rdar10569024_aux(RDar10569024Ref o);
+
+int rdar10569024(id p, id collection) {
+ for (id elem in collection) {
+ const RDar10569024Ref &o = (RDar10569024Ref) elem;
+ rdar10569024_aux(o); // no-warning
+ return o.x; // no-warning
+ }
+ return 0;
+}
diff --git a/test/Analysis/misc-ps.c b/test/Analysis/misc-ps.c
index bef5b0618183..f81b0ddc68d2 100644
--- a/test/Analysis/misc-ps.c
+++ b/test/Analysis/misc-ps.c
@@ -1,24 +1,6 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -disable-free -analyzer-eagerly-assume -analyzer-checker=core -analyzer-checker=deadcode -verify %s
-unsigned long strlen(const char *);
-
int size_rdar9373039 = 1;
-int rdar9373039() {
- int x;
- int j = 0;
-
- for (int i = 0 ; i < size_rdar9373039 ; ++i)
- x = 1;
-
- // strlen doesn't invalidate the value of 'size_rdar9373039'.
- int extra = (2 + strlen ("Clang") + ((4 - ((unsigned int) (2 + strlen ("Clang")) % 4)) % 4)) + (2 + strlen ("1.0") + ((4 - ((unsigned int) (2 + strlen ("1.0")) % 4)) % 4));
-
- for (int i = 0 ; i < size_rdar9373039 ; ++i)
- j += x; // no-warning
-
- return j;
-}
-
int foo_rdar9373039(const char *);
int rdar93730392() {
@@ -81,3 +63,66 @@ int PR8962_f (int *t) {
}) ) return 0;
return *t; // no-warning
}
+
+// This previously crashed logic in the analyzer engine when evaluating locations.
+void rdar10308201_aux(unsigned val);
+void rdar10308201 (int valA, void *valB, unsigned valC) {
+ unsigned actual_base, lines;
+ if (valC == 0) {
+ actual_base = (unsigned)valB;
+ for (;;) {
+ if (valA & (1<<0))
+ rdar10308201_aux(actual_base);
+ }
+ }
+}
+
+typedef struct Struct103 {
+ unsigned i;
+} Struct103;
+typedef unsigned int size_t;
+void __my_memset_chk(char*, int, size_t);
+static int radar10367606(int t) {
+ Struct103 overall;
+ ((__builtin_object_size ((char *) &overall, 0) != (size_t) -1) ? __builtin___memset_chk ((char *) &overall, 0, sizeof(Struct103), __builtin_object_size ((char *) &overall, 0)) : __my_memset_chk ((char *) &overall, 0, sizeof(Struct103)));
+ return 0;
+}
+
+/* Caching out on a sink node. */
+extern int fooR10376675();
+extern int* bazR10376675();
+extern int nR10376675;
+void barR10376675(int *x) {
+ int *pm;
+ if (nR10376675 * 2) {
+ int *pk = bazR10376675();
+ pm = pk; //expected-warning {{never read}}
+ }
+ do {
+ *x = fooR10376675();
+ } while (0);
+}
+
+// Test accesses to wide character strings doesn't break the analyzer.
+typedef int wchar_t;
+struct rdar10385775 {
+ wchar_t *name;
+};
+void RDar10385775(struct rdar10385775* p) {
+ p->name = L"a";
+}
+
+// Test double loop of array and array literals. Previously this
+// resulted in a false positive uninitailized value warning.
+void rdar10686586() {
+ int array1[] = { 1, 2, 3, 0 };
+ int array2[] = { 1, 2, 3, 0 };
+ int *array[] = { array1, array2 };
+ int sum = 0;
+ for (int i = 0; i < 2; i++) {
+ for (int j = 0; j < 4; j++) {
+ sum += array[i][j]; // no-warning
+ }
+ }
+}
+
diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m
index 007c558299f5..9d2ff5b6ea37 100644
--- a/test/Analysis/misc-ps.m
+++ b/test/Analysis/misc-ps.m
@@ -1,11 +1,11 @@
// NOTE: Use '-fobjc-gc' to test the analysis being run twice, and multiple reports are not issued.
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code -Wno-null-dereference %s
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code -Wno-null-dereference %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code -Wno-null-dereference %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code -Wno-null-dereference %s
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
#ifndef __clang_analyzer__
-#error __clang__analyzer__ not defined
+#error __clang_analyzer__ not defined
#endif
typedef struct objc_ivar *Ivar;
@@ -274,6 +274,17 @@ void rdar_6777003(int x) {
*p = 1; // expected-warning{{Dereference of null pointer}}
}
+// Check that the pointer-to-conts arguments do not get invalidated by Obj C
+// interfaces. radar://10595327
+int rdar_10595327(char *str) {
+ char fl = str[0];
+ int *p = 0;
+ NSString *s = [NSString stringWithUTF8String:str];
+ if (str[0] != fl)
+ return *p; // no-warning
+ return 0;
+}
+
// For pointer arithmetic, --/++ should be treated as preserving non-nullness,
// regardless of how well the underlying StoreManager reasons about pointer
// arithmetic.
@@ -1237,7 +1248,7 @@ void pr9269() {
struct s { char *bar[10]; } baz[2] = { 0 };
unsigned i = 0;
for (i = 0;
- (* ({ while(0); ({ &baz[0]; }); })).bar[0] != 0;
+ (* ({ while(0); ({ &baz[0]; }); })).bar[0] != 0; // expected-warning {{while loop has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
++i) {}
}
@@ -1321,3 +1332,16 @@ void radar9414427() {
@implementation RDar9465344
@end
+// Don't crash when analyzing access to 'self' within a block.
+@interface Rdar10380300Base
+- (void) foo;
+@end
+@interface Rdar10380300 : Rdar10380300Base @end
+@implementation Rdar10380300
+- (void)foo {
+ ^{
+ [super foo];
+ }();
+}
+@end
+
diff --git a/test/Analysis/new.cpp b/test/Analysis/new.cpp
index 29ac5eebd242..5ca8c462bdf5 100644
--- a/test/Analysis/new.cpp
+++ b/test/Analysis/new.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -verify %s
+// XFAIL: *
void f1() {
int *n = new int;
diff --git a/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m b/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m
index e2ad1176e33f..c1cc076a9362 100644
--- a/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m
+++ b/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m
@@ -1,38 +1,32 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=range -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=range -analyzer-store=region -verify -Wno-objc-root-class %s
// <rdar://problem/6888289> - This test case shows that a nil instance
// variable can possibly be initialized by a method.
-typedef struct RDar6888289_data {
- long data[100];
-} RDar6888289_data;
-
@interface RDar6888289
{
- RDar6888289 *x;
+ id *x;
}
-- (RDar6888289_data) test;
-- (RDar6888289_data) test2;
+- (void) test:(id) y;
+- (void) test2:(id) y;
- (void) invalidate;
-- (RDar6888289_data) getData;
@end
+id *getVal(void);
+
@implementation RDar6888289
-- (RDar6888289_data) test {
+- (void) test:(id)y {
if (!x)
[self invalidate];
- return [x getData];
+ *x = y;
}
-- (RDar6888289_data) test2 {
+- (void) test2:(id)y {
if (!x) {}
- return [x getData]; // expected-warning{{The receiver of message 'getData' is nil and returns a value of type 'RDar6888289_data' that will be garbage}}
+ *x = y; // expected-warning {{null}}
}
- (void) invalidate {
- x = self;
+ x = getVal();
}
-- (RDar6888289_data) getData {
- return (RDar6888289_data) { 0 };
-}
@end
diff --git a/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m b/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
index eb15435600b9..e4d5aaf82b2d 100644
--- a/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
+++ b/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region %s 2>&1 | FileCheck -check-prefix=darwin8 %s
-// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region %s 2>&1 | FileCheck -check-prefix=darwin9 %s
-// RUN: %clang_cc1 -triple thumbv6-apple-darwin4.0.0-iphoneos -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region %s 2>&1 | FileCheck -check-prefix=darwin9 %s
+// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region -Wno-objc-root-class %s 2>&1 | FileCheck -check-prefix=darwin8 %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region -Wno-objc-root-class %s 2>&1 | FileCheck -check-prefix=darwin9 %s
+// RUN: %clang_cc1 -triple thumbv6-apple-ios4.0 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region -Wno-objc-root-class %s 2>&1 | FileCheck -check-prefix=darwin9 %s
@interface MyClass {}
- (void *)voidPtrM;
@@ -48,7 +48,7 @@ void createFoo4() {
}
void createFoo5() {
- MyClass *obj = @"";
+ MyClass *obj = (id)@"";
double d = [obj doubleM]; // no-warning
}
@@ -80,16 +80,16 @@ int handleVoidInComma() {
int marker(void) { // control reaches end of non-void function
}
-
-// CHECK-darwin8: warning: The receiver of message 'longDoubleM' is nil and returns a value of type 'long double' that will be garbage
// CHECK-darwin8: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
-// CHECK-darwin8: warning: The receiver of message 'doubleM' is nil and returns a value of type 'double' that will be garbage
// CHECK-darwin8: warning: The receiver of message 'unsignedLongLongM' is nil and returns a value of type 'unsigned long long' that will be garbage
+// CHECK-darwin8: warning: The receiver of message 'doubleM' is nil and returns a value of type 'double' that will be garbage
// CHECK-darwin8: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
-// CHECK-darwin9-NOT: warning: The receiver of message 'longDoubleM' is nil and returns a value of type 'long double' that will be garbage
+// CHECK-darwin8: warning: The receiver of message 'longDoubleM' is nil and returns a value of type 'long double' that will be garbage
+
// CHECK-darwin9-NOT: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
-// CHECK-darwin9-NOT: warning: The receiver of message 'doubleM' is nil and returns a value of type 'double' that will be garbage
// CHECK-darwin9-NOT: warning: The receiver of message 'unsignedLongLongM' is nil and returns a value of type 'unsigned long long' that will be garbage
+// CHECK-darwin9-NOT: warning: The receiver of message 'doubleM' is nil and returns a value of type 'double' that will be garbage
// CHECK-darwin9-NOT: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
+// CHECK-darwin9-NOT: warning: The receiver of message 'longDoubleM' is nil and returns a value of type 'long double' that will be garbage
// CHECK-darwin9: 1 warning generated
diff --git a/test/Analysis/null-deref-ps.c b/test/Analysis/null-deref-ps.c
index 641dde207558..a707970a3467 100644
--- a/test/Analysis/null-deref-ps.c
+++ b/test/Analysis/null-deref-ps.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode,experimental.core -std=gnu99 -analyzer-store=region -analyzer-constraints=range -analyzer-purge=none -verify %s -Wreturn-type
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode,experimental.core -std=gnu99 -analyzer-store=region -analyzer-constraints=range -verify %s -Wreturn-type
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode,experimental.deadcode.IdempotentOperations,experimental.core -std=gnu99 -analyzer-store=region -analyzer-constraints=range -analyzer-purge=none -verify %s -Wno-error=return-type
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode,experimental.deadcode.IdempotentOperations,experimental.core -std=gnu99 -analyzer-store=region -analyzer-constraints=range -verify %s -Wno-error=return-type
typedef unsigned uintptr_t;
@@ -221,7 +221,7 @@ int* f10(int* p, signed char x, int y) {
// This tests that our symbolication worked, and that we correctly test
// x against 0 (with the same bitwidth).
if (!x) {
- if (!p) return; // expected-warning {{non-void function 'f10' should return a value}}
+ if (!p) return 0;
*p = 10;
}
else p = 0;
@@ -289,4 +289,25 @@ void pr4759() {
pr4759_aux(p); // expected-warning{{Function call argument is an uninitialized value}}
}
-
+// Relax function call arguments invalidation to be aware of const
+// arguments. Test with function pointers. radar://10595327
+void ttt(const int *nptr);
+void ttt2(const int *nptr);
+typedef void (*NoConstType)(int*);
+int foo10595327(int b) {
+ void (*fp)(int *);
+ // We use path sensitivity to get the function declaration. Even when the
+ // function pointer is cast to non pointer-to-const parameter type, we can
+ // find the right function declaration.
+ if (b > 5)
+ fp = (NoConstType)ttt2;
+ else
+ fp = (NoConstType)ttt;
+ int x = 3;
+ int y = x + 1;
+ int *p = 0;
+ fp(&y);
+ if (x == y)
+ return *p; // no-warning
+ return 0;
+}
diff --git a/test/Analysis/nullptr.cpp b/test/Analysis/nullptr.cpp
index fc7e7ef482b8..3119b4fc390c 100644
--- a/test/Analysis/nullptr.cpp
+++ b/test/Analysis/nullptr.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=core -analyzer-store region -verify %s
+// RUN: %clang_cc1 -std=c++11 -Wno-conversion-null -analyze -analyzer-checker=core -analyzer-store region -verify %s
// test to see if nullptr is detected as a null pointer
void foo1(void) {
@@ -39,7 +39,6 @@ void foo4(void) {
*np = 0; // no-warning
}
-
int pr10372(void *& x) {
// GNU null is a pointer-sized integer, not a pointer.
x = __null;
@@ -47,3 +46,38 @@ int pr10372(void *& x) {
return __null;
}
+void zoo1() {
+ char **p = 0;
+ delete *(p + 0); // expected-warning{{Dereference of null pointer}}
+}
+
+void zoo2() {
+ int **a = 0;
+ int **b = 0;
+ asm ("nop"
+ :"=a"(*a)
+ :"0"(*b) // expected-warning{{Dereference of null pointer}}
+ );
+}
+
+int exprWithCleanups() {
+ struct S {
+ S(int a):a(a){}
+ ~S() {}
+
+ int a;
+ };
+
+ int *x = 0;
+ return S(*x).a; // expected-warning{{Dereference of null pointer}}
+}
+
+int materializeTempExpr() {
+ int *n = 0;
+ struct S {
+ int a;
+ S(int i): a(i) {}
+ };
+ const S &s = S(*n); // expected-warning{{Dereference of null pointer}}
+ return s.a;
+}
diff --git a/test/Analysis/objc-arc.m b/test/Analysis/objc-arc.m
index b02af0515186..e6c6ab546132 100644
--- a/test/Analysis/objc-arc.m
+++ b/test/Analysis/objc-arc.m
@@ -3,6 +3,7 @@
typedef signed char BOOL;
typedef struct _NSZone NSZone;
@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+typedef unsigned long NSUInteger;
@protocol NSObject
- (BOOL)isEqual:(id)object;
@@ -10,12 +11,30 @@ typedef struct _NSZone NSZone;
@protocol NSCopying
- (id)copyWithZone:(NSZone *)zone;
@end
-@protocol NSCoding
+@protocol NSCoding;
+@protocol NSMutableCopying;
+@protocol NSFastEnumeration
- (void)encodeWithCoder:(NSCoder *)aCoder;
@end
+@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
+@end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
@interface NSObject <NSObject> {}
+ (id)alloc;
+- (id)init;
+- (NSString *)description;
+@end
+@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
+- (NSUInteger)count;
+- (id)initWithObjects:(const id [])objects count:(NSUInteger)cnt;
++ (id)arrayWithObject:(id)anObject;
++ (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt;
++ (id)arrayWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
+- (id)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
+- (id)initWithArray:(NSArray *)array;
@end
+
typedef const struct __CFAllocator * CFAllocatorRef;
extern const CFAllocatorRef kCFAllocatorDefault;
typedef double CFTimeInterval;
@@ -153,3 +172,49 @@ id test_return() {
return x; // no-warning
}
+void test_objc_arrays() {
+ { // CASE ONE -- OBJECT IN ARRAY CREATED DIRECTLY
+ NSObject *o = [[NSObject alloc] init];
+ NSArray *a = [[NSArray alloc] initWithObjects:o, (void*)0];
+ [a description];
+ [o description];
+ }
+
+ { // CASE TWO -- OBJECT IN ARRAY CREATED BY DUPING AUTORELEASED ARRAY
+ NSObject *o = [[NSObject alloc] init];
+ NSArray *a1 = [NSArray arrayWithObjects:o, (void*)0];
+ NSArray *a2 = [[NSArray alloc] initWithArray:a1];
+ [a2 description];
+ [o description];
+ }
+
+ { // CASE THREE -- OBJECT IN RETAINED @[]
+ NSObject *o = [[NSObject alloc] init];
+ NSArray *a3 = @[o];
+ [a3 description];
+ [o description];
+ }
+ {
+ // CASE 4, verify analyzer still working.
+ CFCreateString(); // expected-warning {{leak}}
+ }
+}
+
+// <rdar://problem/11059275> - dispatch_set_context and ARC.
+__attribute__((cf_returns_retained)) CFTypeRef CFBridgingRetain(id X);
+typedef void* dispatch_object_t;
+void dispatch_set_context(dispatch_object_t object, const void *context);
+
+void rdar11059275(dispatch_object_t object) {
+ NSObject *o = [[NSObject alloc] init];
+ dispatch_set_context(object, CFBridgingRetain(o)); // no-warning
+}
+void rdar11059275_positive() {
+ NSObject *o = [[NSObject alloc] init]; // expected-warning {{leak}}
+ CFBridgingRetain(o);
+}
+void rdar11059275_negative() {
+ NSObject *o = [[NSObject alloc] init]; // no-warning
+ (void) o;
+}
+
diff --git a/test/Analysis/objc-bool.m b/test/Analysis/objc-bool.m
new file mode 100644
index 000000000000..631cd2d1fb21
--- /dev/null
+++ b/test/Analysis/objc-bool.m
@@ -0,0 +1,22 @@
+// RUN: %clang --analyze %s -o %t -verify
+
+// Test handling of ObjC bool literals.
+
+typedef signed char BOOL;
+
+void rdar_10597458() {
+ if (__objc_yes)
+ return;
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+}
+
+void rdar_10597458_b(BOOL b) {
+ if (b == __objc_no)
+ return;
+
+ if (b == __objc_no) {
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ }
+}
diff --git a/test/Analysis/objc-method-coverage.m b/test/Analysis/objc-method-coverage.m
new file mode 100644
index 000000000000..056aafe51873
--- /dev/null
+++ b/test/Analysis/objc-method-coverage.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-stats -fblocks %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=none -analyzer-stats -fblocks %s 2>&1 | FileCheck %s
+
+@interface I
+int f() {
+ return 0;
+}
+@end
+
+@implementation I
++ (void *)ff{
+ return (void*)0;
+}
+@end
+
+// CHECK: ... Statistics Collected ...
+// CHECK: 2 AnalysisConsumer - The # of functions analysed (as top level). \ No newline at end of file
diff --git a/test/Analysis/out-of-bounds.c b/test/Analysis/out-of-bounds.c
index ac2cdc82598d..a97bba5bb3b8 100644
--- a/test/Analysis/out-of-bounds.c
+++ b/test/Analysis/out-of-bounds.c
@@ -128,13 +128,11 @@ void test2_multi_ok(int x) {
buf[0][0] = 1; // no-warning
}
-// *** FIXME ***
-// We don't get a warning here yet because our symbolic constraint solving
-// doesn't handle: (symbol * constant) < constant
+// Testing if solver handles (symbol * constant) < constant
void test3(int x) {
int buf[100];
if (x < 0)
- buf[x] = 1;
+ buf[x] = 1; // expected-warning {{Out of bound memory access (accessed memory precedes memory block)}}
}
// *** FIXME ***
diff --git a/test/Analysis/plist-output-alternate.m b/test/Analysis/plist-output-alternate.m
index 23a260a129c7..83100dc20944 100644
--- a/test/Analysis/plist-output-alternate.m
+++ b/test/Analysis/plist-output-alternate.m
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-output=plist -o - %s | FileCheck %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-output=plist -o %t %s
+// RUN: FileCheck --input-file %t %s
void test_null_init(void) {
int *p = 0;
@@ -57,7 +58,6 @@ void rdar8331641(int x) {
}
// CHECK: <?xml version="1.0" encoding="UTF-8"?>
-// CHECK: <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
// CHECK: <plist version="1.0">
// CHECK: <dict>
// CHECK: <key>files</key>
@@ -76,12 +76,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>4</integer>
+// CHECK: <key>line</key><integer>5</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>4</integer>
+// CHECK: <key>line</key><integer>5</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -89,13 +89,13 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>line</key><integer>6</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
-// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>line</key><integer>6</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -106,7 +106,7 @@ void rdar8331641(int x) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>line</key><integer>6</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -114,17 +114,18 @@ void rdar8331641(int x) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>line</key><integer>6</integer>
// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>line</key><integer>6</integer>
// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
@@ -134,9 +135,11 @@ void rdar8331641(int x) {
// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_init</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>line</key><integer>6</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -152,12 +155,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>9</integer>
+// CHECK: <key>line</key><integer>10</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>9</integer>
+// CHECK: <key>line</key><integer>10</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -165,13 +168,13 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>line</key><integer>12</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
-// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -182,7 +185,7 @@ void rdar8331641(int x) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>line</key><integer>12</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -190,17 +193,18 @@ void rdar8331641(int x) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>line</key><integer>12</integer>
// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>line</key><integer>12</integer>
// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
@@ -210,9 +214,11 @@ void rdar8331641(int x) {
// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_assign</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>line</key><integer>12</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -228,12 +234,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>15</integer>
+// CHECK: <key>line</key><integer>16</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>15</integer>
+// CHECK: <key>line</key><integer>16</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -241,13 +247,13 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>line</key><integer>19</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
-// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -258,7 +264,7 @@ void rdar8331641(int x) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>line</key><integer>19</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -266,17 +272,18 @@ void rdar8331641(int x) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>line</key><integer>19</integer>
// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>line</key><integer>19</integer>
// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
// CHECK: <key>message</key>
@@ -286,9 +293,11 @@ void rdar8331641(int x) {
// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_assign_transitive</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>line</key><integer>19</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -304,12 +313,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>23</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>23</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -317,12 +326,12 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>23</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>23</integer>
// CHECK: <key>col</key><integer>8</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -334,7 +343,7 @@ void rdar8331641(int x) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>23</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -342,17 +351,18 @@ void rdar8331641(int x) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>23</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>23</integer>
// CHECK: <key>col</key><integer>8</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Assuming &apos;p&apos; is null</string>
// CHECK: <key>message</key>
@@ -366,12 +376,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>23</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>23</integer>
// CHECK: <key>col</key><integer>8</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -379,13 +389,13 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>line</key><integer>24</integer>
// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
-// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -396,7 +406,7 @@ void rdar8331641(int x) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>line</key><integer>24</integer>
// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -404,17 +414,18 @@ void rdar8331641(int x) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>line</key><integer>24</integer>
// CHECK: <key>col</key><integer>6</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>line</key><integer>24</integer>
// CHECK: <key>col</key><integer>6</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
@@ -424,9 +435,11 @@ void rdar8331641(int x) {
// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_cond</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>line</key><integer>24</integer>
// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -442,12 +455,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>29</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>29</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -455,12 +468,12 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>29</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>29</integer>
// CHECK: <key>col</key><integer>8</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -469,34 +482,6 @@ void rdar8331641(int x) {
// CHECK: </array>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>kind</key><string>event</string>
-// CHECK: <key>location</key>
-// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
-// CHECK: <key>col</key><integer>7</integer>
-// CHECK: <key>file</key><integer>0</integer>
-// CHECK: </dict>
-// CHECK: <key>ranges</key>
-// CHECK: <array>
-// CHECK: <array>
-// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
-// CHECK: <key>col</key><integer>7</integer>
-// CHECK: <key>file</key><integer>0</integer>
-// CHECK: </dict>
-// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
-// CHECK: <key>col</key><integer>8</integer>
-// CHECK: <key>file</key><integer>0</integer>
-// CHECK: </dict>
-// CHECK: </array>
-// CHECK: </array>
-// CHECK: <key>extended_message</key>
-// CHECK: <string>Assuming &apos;q&apos; is null</string>
-// CHECK: <key>message</key>
-// CHECK: <string>Assuming &apos;q&apos; is null</string>
-// CHECK: </dict>
-// CHECK: <dict>
// CHECK: <key>kind</key><string>control</string>
// CHECK: <key>edges</key>
// CHECK: <array>
@@ -504,12 +489,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>29</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>29</integer>
// CHECK: <key>col</key><integer>8</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -517,12 +502,12 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>line</key><integer>30</integer>
// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>line</key><integer>30</integer>
// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -538,12 +523,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>line</key><integer>30</integer>
// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>line</key><integer>30</integer>
// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -551,13 +536,13 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
+// CHECK: <key>line</key><integer>31</integer>
// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
-// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>line</key><integer>31</integer>
+// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -568,7 +553,7 @@ void rdar8331641(int x) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
+// CHECK: <key>line</key><integer>31</integer>
// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -576,17 +561,18 @@ void rdar8331641(int x) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
+// CHECK: <key>line</key><integer>31</integer>
// CHECK: <key>col</key><integer>6</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
+// CHECK: <key>line</key><integer>31</integer>
// CHECK: <key>col</key><integer>6</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
@@ -596,9 +582,11 @@ void rdar8331641(int x) {
// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_cond_transitive</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
+// CHECK: <key>line</key><integer>31</integer>
// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -614,12 +602,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>line</key><integer>36</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>line</key><integer>36</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -627,12 +615,12 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>line</key><integer>36</integer>
// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>line</key><integer>36</integer>
// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -648,12 +636,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>line</key><integer>36</integer>
// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>line</key><integer>36</integer>
// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -661,13 +649,13 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>line</key><integer>38</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>38</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -678,7 +666,7 @@ void rdar8331641(int x) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>line</key><integer>38</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -686,17 +674,18 @@ void rdar8331641(int x) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>line</key><integer>38</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>line</key><integer>38</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Dereference of null pointer (loaded from field &apos;p&apos;)</string>
// CHECK: <key>message</key>
@@ -706,9 +695,11 @@ void rdar8331641(int x) {
// CHECK: <key>description</key><string>Dereference of null pointer (loaded from field &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_field</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>line</key><integer>38</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -724,12 +715,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>52</integer>
+// CHECK: <key>line</key><integer>53</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>52</integer>
+// CHECK: <key>line</key><integer>53</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -737,12 +728,12 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>line</key><integer>54</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>line</key><integer>54</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -758,12 +749,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>line</key><integer>54</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>line</key><integer>54</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -771,12 +762,12 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>line</key><integer>54</integer>
// CHECK: <key>col</key><integer>23</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>line</key><integer>54</integer>
// CHECK: <key>col</key><integer>82</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -788,7 +779,7 @@ void rdar8331641(int x) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>line</key><integer>54</integer>
// CHECK: <key>col</key><integer>23</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -796,17 +787,18 @@ void rdar8331641(int x) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>line</key><integer>54</integer>
// CHECK: <key>col</key><integer>23</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>line</key><integer>54</integer>
// CHECK: <key>col</key><integer>82</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Call to function &apos;CFNumberCreate&apos; returns a Core Foundation object with a +1 retain count</string>
// CHECK: <key>message</key>
@@ -820,12 +812,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>line</key><integer>54</integer>
// CHECK: <key>col</key><integer>23</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>line</key><integer>54</integer>
// CHECK: <key>col</key><integer>82</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -833,12 +825,12 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>line</key><integer>55</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>line</key><integer>55</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -854,12 +846,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>line</key><integer>55</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>line</key><integer>55</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -867,12 +859,12 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>line</key><integer>55</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>line</key><integer>55</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -881,34 +873,6 @@ void rdar8331641(int x) {
// CHECK: </array>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>kind</key><string>event</string>
-// CHECK: <key>location</key>
-// CHECK: <dict>
-// CHECK: <key>line</key><integer>54</integer>
-// CHECK: <key>col</key><integer>7</integer>
-// CHECK: <key>file</key><integer>0</integer>
-// CHECK: </dict>
-// CHECK: <key>ranges</key>
-// CHECK: <array>
-// CHECK: <array>
-// CHECK: <dict>
-// CHECK: <key>line</key><integer>54</integer>
-// CHECK: <key>col</key><integer>7</integer>
-// CHECK: <key>file</key><integer>0</integer>
-// CHECK: </dict>
-// CHECK: <dict>
-// CHECK: <key>line</key><integer>54</integer>
-// CHECK: <key>col</key><integer>7</integer>
-// CHECK: <key>file</key><integer>0</integer>
-// CHECK: </dict>
-// CHECK: </array>
-// CHECK: </array>
-// CHECK: <key>extended_message</key>
-// CHECK: <string>Assuming &apos;x&apos; is 0</string>
-// CHECK: <key>message</key>
-// CHECK: <string>Assuming &apos;x&apos; is 0</string>
-// CHECK: </dict>
-// CHECK: <dict>
// CHECK: <key>kind</key><string>control</string>
// CHECK: <key>edges</key>
// CHECK: <array>
@@ -916,12 +880,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>line</key><integer>55</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>line</key><integer>55</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -929,12 +893,12 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>56</integer>
+// CHECK: <key>line</key><integer>57</integer>
// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>56</integer>
+// CHECK: <key>line</key><integer>57</integer>
// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -950,12 +914,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>56</integer>
+// CHECK: <key>line</key><integer>57</integer>
// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>56</integer>
+// CHECK: <key>line</key><integer>57</integer>
// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -963,12 +927,12 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>line</key><integer>58</integer>
// CHECK: <key>col</key><integer>1</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>line</key><integer>58</integer>
// CHECK: <key>col</key><integer>1</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -980,22 +944,25 @@ void rdar8331641(int x) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>line</key><integer>58</integer>
// CHECK: <key>col</key><integer>1</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Object leaked: object allocated and stored into &apos;value&apos; is not referenced later in this execution path and has a retain count of +1</string>
// CHECK: <key>message</key>
// CHECK: <string>Object leaked: object allocated and stored into &apos;value&apos; is not referenced later in this execution path and has a retain count of +1</string>
// CHECK: </dict>
// CHECK: </array>
-// CHECK: <key>description</key><string>Potential leak of an object allocated on line 53 and stored into &apos;value&apos;</string>
+// CHECK: <key>description</key><string>Potential leak of an object stored into &apos;value&apos;</string>
// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string>
// CHECK: <key>type</key><string>Leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>rdar8331641</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>line</key><integer>58</integer>
// CHECK: <key>col</key><integer>1</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
diff --git a/test/Analysis/plist-output.m b/test/Analysis/plist-output.m
index e08ccc43dec8..72e8f8d0aa66 100644
--- a/test/Analysis/plist-output.m
+++ b/test/Analysis/plist-output.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-output=plist -o - %s | FileCheck %s
-// XFAIL: *
+// RUN: %clang --analyze %s -o %t > /dev/null 2>&1
+// RUN: FileCheck -input-file %t %s
void test_null_init(void) {
int *p = 0;
@@ -24,9 +24,10 @@ void test_null_cond(int *p) {
*p = 0xDEADBEEF;
}
}
-
+
void test_null_cond_transitive(int *q) {
if (!q) {
+ // FIXME: we need a diagnostic saying that p is initialized to 0
int *p = q;
*p = 0xDEADBEEF;
}
@@ -38,8 +39,48 @@ void test_null_field(void) {
*(x.p) = 0xDEADBEEF;
}
+void test_assumptions(int a, int b)
+{
+ if (a == 0) {
+ return;
+ }
+ if (b != 0) {
+ return;
+ }
+ int *p = 0;
+ *p = 0xDEADBEEF;
+}
+
+int *bar_cond_assign();
+int test_cond_assign() {
+ int *p;
+ if (p = bar_cond_assign())
+ return 1;
+ return *p;
+}
+
+// The following previously crashed when generating extensive diagnostics.
+// <rdar://problem/10797980>
+@interface RDar10797980_help
+@property (readonly) int x;
+@end
+
+@interface RDar10797980 {
+ RDar10797980_help *y;
+}
+- (void) test;
+@end
+
+@implementation RDar10797980
+- (void) test {
+ if (y.x == 1) {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{deference}}
+ }
+}
+@end
+
// CHECK: <?xml version="1.0" encoding="UTF-8"?>
-// CHECK: <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
// CHECK: <plist version="1.0">
// CHECK: <dict>
// CHECK: <key>files</key>
@@ -51,10 +92,44 @@ void test_null_field(void) {
// CHECK: <key>path</key>
// CHECK: <array>
// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>6</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>6</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>4</integer>
+// CHECK: <key>line</key><integer>6</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -62,22 +137,39 @@ void test_null_field(void) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>4</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>line</key><integer>6</integer>
+// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>4</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>6</integer>
+// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
-// CHECK: <string>Variable &apos;p&apos; initialized to a null pointer value</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
-// CHECK: <string>Variable &apos;p&apos; initialized to a null pointer value</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_init</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>6</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
// CHECK: <dict>
// CHECK: <key>kind</key><string>control</string>
// CHECK: <key>edges</key>
@@ -86,26 +178,26 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>4</integer>
+// CHECK: <key>line</key><integer>10</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>4</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>line</key><integer>12</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
-// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -116,7 +208,7 @@ void test_null_field(void) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>line</key><integer>12</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -124,17 +216,18 @@ void test_null_field(void) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>line</key><integer>12</integer>
// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>line</key><integer>12</integer>
// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
@@ -144,9 +237,11 @@ void test_null_field(void) {
// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_assign</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>line</key><integer>12</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -162,12 +257,12 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>9</integer>
+// CHECK: <key>line</key><integer>16</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>9</integer>
+// CHECK: <key>line</key><integer>16</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -175,12 +270,12 @@ void test_null_field(void) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>line</key><integer>19</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>line</key><integer>19</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -192,7 +287,7 @@ void test_null_field(void) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>line</key><integer>19</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -200,22 +295,39 @@ void test_null_field(void) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>10</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>10</integer>
-// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
-// CHECK: <string>Null pointer value stored to &apos;p&apos;</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
// CHECK: <key>message</key>
-// CHECK: <string>Null pointer value stored to &apos;p&apos;</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_assign_transitive</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
// CHECK: <dict>
// CHECK: <key>kind</key><string>control</string>
// CHECK: <key>edges</key>
@@ -224,12 +336,12 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>line</key><integer>23</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>line</key><integer>23</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -237,13 +349,13 @@ void test_null_field(void) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
-// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>8</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -254,25 +366,89 @@ void test_null_field(void) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <key>ranges</key>
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
-// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
-// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>8</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Assuming &apos;p&apos; is null</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Assuming &apos;p&apos; is null</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
@@ -282,10 +458,12 @@ void test_null_field(void) {
// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_cond</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </dict>
@@ -300,12 +478,12 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>15</integer>
+// CHECK: <key>line</key><integer>29</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>15</integer>
+// CHECK: <key>line</key><integer>29</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -313,12 +491,12 @@ void test_null_field(void) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>17</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>17</integer>
+// CHECK: <key>line</key><integer>29</integer>
// CHECK: <key>col</key><integer>8</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -327,33 +505,118 @@ void test_null_field(void) {
// CHECK: </array>
// CHECK: </dict>
// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>31</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>31</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>31</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>31</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>32</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>32</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>17</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>line</key><integer>32</integer>
+// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <key>ranges</key>
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>17</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>line</key><integer>32</integer>
+// CHECK: <key>col</key><integer>6</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>17</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>32</integer>
+// CHECK: <key>col</key><integer>6</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
-// CHECK: <string>Variable &apos;q&apos; initialized to a null pointer value</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
-// CHECK: <string>Variable &apos;q&apos; initialized to a null pointer value</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_cond_transitive</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>32</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
// CHECK: <dict>
// CHECK: <key>kind</key><string>control</string>
// CHECK: <key>edges</key>
@@ -362,26 +625,60 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>17</integer>
+// CHECK: <key>line</key><integer>37</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>17</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>line</key><integer>39</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
-// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>line</key><integer>39</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -392,7 +689,7 @@ void test_null_field(void) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>line</key><integer>39</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -400,29 +697,32 @@ void test_null_field(void) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
-// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>line</key><integer>39</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
-// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>line</key><integer>39</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
-// CHECK: <string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
+// CHECK: <string>Dereference of null pointer (loaded from field &apos;p&apos;)</string>
// CHECK: <key>message</key>
-// CHECK: <string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
+// CHECK: <string>Dereference of null pointer (loaded from field &apos;p&apos;)</string>
// CHECK: </dict>
// CHECK: </array>
-// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from field &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_field</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>line</key><integer>39</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -438,12 +738,12 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>44</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>44</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -451,13 +751,13 @@ void test_null_field(void) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>44</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>44</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -465,32 +765,38 @@ void test_null_field(void) {
// CHECK: </array>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>kind</key><string>event</string>
-// CHECK: <key>location</key>
-// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
-// CHECK: <key>col</key><integer>7</integer>
-// CHECK: <key>file</key><integer>0</integer>
-// CHECK: </dict>
-// CHECK: <key>ranges</key>
-// CHECK: <array>
-// CHECK: <array>
-// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
-// CHECK: <key>col</key><integer>7</integer>
-// CHECK: <key>file</key><integer>0</integer>
-// CHECK: </dict>
-// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
-// CHECK: <key>col</key><integer>8</integer>
-// CHECK: <key>file</key><integer>0</integer>
-// CHECK: </dict>
-// CHECK: </array>
-// CHECK: </array>
-// CHECK: <key>extended_message</key>
-// CHECK: <string>Assuming pointer value is null</string>
-// CHECK: <key>message</key>
-// CHECK: <string>Assuming pointer value is null</string>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>44</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>44</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>47</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>47</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
// CHECK: </dict>
// CHECK: <dict>
// CHECK: <key>kind</key><string>control</string>
@@ -500,26 +806,94 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>47</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>47</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>47</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>47</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>47</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>47</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
-// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
-// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>51</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>51</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -530,25 +904,26 @@ void test_null_field(void) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
-// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>line</key><integer>51</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <key>ranges</key>
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
-// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>line</key><integer>51</integer>
+// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
-// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>line</key><integer>51</integer>
+// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
@@ -558,10 +933,12 @@ void test_null_field(void) {
// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_assumptions</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
-// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>line</key><integer>51</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </dict>
@@ -576,12 +953,46 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>56</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>56</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>57</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>57</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -589,13 +1000,13 @@ void test_null_field(void) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>57</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -606,7 +1017,7 @@ void test_null_field(void) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>57</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -614,21 +1025,22 @@ void test_null_field(void) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>57</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
-// CHECK: <string>Assuming pointer value is null</string>
+// CHECK: <string>Assuming &apos;p&apos; is null</string>
// CHECK: <key>message</key>
-// CHECK: <string>Assuming pointer value is null</string>
+// CHECK: <string>Assuming &apos;p&apos; is null</string>
// CHECK: </dict>
// CHECK: <dict>
// CHECK: <key>kind</key><string>control</string>
@@ -638,26 +1050,26 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>57</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>29</integer>
-// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>29</integer>
-// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -672,26 +1084,26 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>29</integer>
-// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>29</integer>
-// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
-// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
-// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>11</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -702,25 +1114,26 @@ void test_null_field(void) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
-// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <key>ranges</key>
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
-// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>11</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
-// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>11</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
@@ -730,10 +1143,12 @@ void test_null_field(void) {
// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_cond_assign</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
-// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </dict>
@@ -748,26 +1163,26 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>line</key><integer>76</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
-// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
-// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -782,26 +1197,94 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
-// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
-// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>line</key><integer>76</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>77</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>77</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>77</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>77</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>78</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>78</integer>
+// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -812,41 +1295,45 @@ void test_null_field(void) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>line</key><integer>78</integer>
+// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <key>ranges</key>
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>line</key><integer>78</integer>
+// CHECK: <key>col</key><integer>6</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>78</integer>
+// CHECK: <key>col</key><integer>6</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
-// CHECK: <string>Dereference of null pointer</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
-// CHECK: <string>Dereference of null pointer</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: </dict>
// CHECK: </array>
-// CHECK: <key>description</key><string>Dereference of null pointer</string>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>Objective-C method</string>
+// CHECK: <key>issue_context</key><string>test</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>line</key><integer>78</integer>
+// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </dict>
// CHECK: </plist>
+
diff --git a/test/Analysis/pr_2542_rdar_6793404.m b/test/Analysis/pr_2542_rdar_6793404.m
index d5125a649d2b..19c140d9e59a 100644
--- a/test/Analysis/pr_2542_rdar_6793404.m
+++ b/test/Analysis/pr_2542_rdar_6793404.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -pedantic -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -pedantic -analyzer-store=region -verify -Wno-objc-root-class %s
// BEGIN delta-debugging reduced header stuff
diff --git a/test/Analysis/properties.m b/test/Analysis/properties.m
index 6d04a4ab4e78..4aa91805fda6 100644
--- a/test/Analysis/properties.m
+++ b/test/Analysis/properties.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify -Wno-objc-root-class %s
typedef signed char BOOL;
typedef unsigned int NSUInteger;
@@ -143,3 +143,26 @@ void rdar6611873() {
return super.name;
}
@end
+
+// <rdar://problem/9241180> Static analyzer doesn't detect uninitialized variable issues for property accesses
+@interface RDar9241180
+@property (readwrite,assign) id x;
+-(id)testAnalyzer1:(int) y;
+-(void)testAnalyzer2;
+@end
+
+@implementation RDar9241180
+@synthesize x;
+-(id)testAnalyzer1:(int)y {
+ RDar9241180 *o;
+ if (y && o.x) // expected-warning {{Property access on an uninitialized object pointer}}
+ return o;
+ return o; // expected-warning {{Undefined or garbage value returned to caller}}
+}
+-(void)testAnalyzer2 {
+ id y;
+ self.x = y; // expected-warning {{Argument for property setter is an uninitialized value}}
+}
+@end
+
+
diff --git a/test/Analysis/ptr-arith.c b/test/Analysis/ptr-arith.c
index 995470a369cb..fb37f1c791a3 100644
--- a/test/Analysis/ptr-arith.c
+++ b/test/Analysis/ptr-arith.c
@@ -269,7 +269,7 @@ void symbolic_region(int *p) {
int a;
if (&a == p)
- WARN; // expected-warning{{}}
+ WARN; // no-warning
if (&a != p)
WARN; // expected-warning{{}}
if (&a > p)
diff --git a/test/Analysis/rdar-6540084.m b/test/Analysis/rdar-6540084.m
index b2a113c20dcf..d710c475defe 100644
--- a/test/Analysis/rdar-6540084.m
+++ b/test/Analysis/rdar-6540084.m
@@ -10,7 +10,7 @@ typedef struct _NSZone NSZone;
@interface NSObject <NSObject> {} @end
extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
@class NSArray;
-@class NSMutableArray, NSIndexSet, NSView, NSPredicate, NSString, NSViewAnimation, NSTimer;
+@class NSMutableArray, NSIndexSet, NSView, NSPredicate, NSString, NSViewAnimation, NSTimer; // expected-note{{forward declaration of class here}}
@interface FooBazController : NSObject {}
@end
typedef struct {} TazVersion;
diff --git a/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m b/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
index e9711e70c204..5af4776b32db 100644
--- a/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
+++ b/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region %s -verify
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region -verify -Wno-objc-root-class %s
typedef struct Foo { int x; } Bar;
@@ -14,12 +14,12 @@ typedef struct Foo { int x; } Bar;
void createFoo() {
MyClass *obj = 0;
- Bar f = [obj foo]; // expected-warning{{The receiver of message 'foo' is nil and returns a value of type 'Bar' that will be garbage}}
+ Bar f = [obj foo]; // no-warning
}
void createFoo2() {
MyClass *obj = 0;
[obj foo]; // no-warning
- Bar f = [obj foo]; // expected-warning{{The receiver of message 'foo' is nil and returns a value of type 'Bar' that will be garbage}}
+ Bar f = [obj foo]; // no-warning
}
diff --git a/test/Analysis/redefined_system.c b/test/Analysis/redefined_system.c
new file mode 100644
index 000000000000..3f585c4ef689
--- /dev/null
+++ b/test/Analysis/redefined_system.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix,core,experimental.security.taint -w -verify %s
+
+// Make sure we don't crash when someone redefines a system function we reason about.
+
+char memmove ();
+char malloc();
+char system();
+char stdin();
+char memccpy();
+char free();
+char strdup();
+char atoi();
+
+int foo () {
+ return memmove() + malloc() + system + stdin() + memccpy() + free() + strdup() + atoi();
+
+}
diff --git a/test/Analysis/reference.cpp b/test/Analysis/reference.cpp
index c7912f4f029e..5897e682884c 100644
--- a/test/Analysis/reference.cpp
+++ b/test/Analysis/reference.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -Wno-null-dereference %s
// XFAIL
typedef typeof(sizeof(int)) size_t;
diff --git a/test/Analysis/retain-release-gc-only.m b/test/Analysis/retain-release-gc-only.m
index 4e1b8466c322..0340a3c2a140 100644
--- a/test/Analysis/retain-release-gc-only.m
+++ b/test/Analysis/retain-release-gc-only.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,osx.cocoa.NSAutoreleasePool -analyzer-store=region -fobjc-gc-only -fblocks -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,osx.cocoa.NSAutoreleasePool -analyzer-store=region -fobjc-gc-only -fblocks -verify -Wno-objc-root-class %s
//===----------------------------------------------------------------------===//
// Header stuff.
@@ -279,7 +279,7 @@ void f5b() {
@implementation TestReturnNotOwnedWhenExpectedOwned
- (NSString*)newString {
- NSString *s = [NSString stringWithUTF8String:"hello"]; // expected-warning{{Potential leak (when using garbage collection) of an object allocated}}
+ NSString *s = [NSString stringWithUTF8String:"hello"]; // expected-warning{{Potential leak (when using garbage collection) of an object}}
CFRetain(s);
return s;
}
diff --git a/test/Analysis/retain-release-inline.m b/test/Analysis/retain-release-inline.m
new file mode 100644
index 000000000000..610df7f7e94a
--- /dev/null
+++ b/test/Analysis/retain-release-inline.m
@@ -0,0 +1,347 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -analyzer-ipa=inlining -verify %s
+
+//===----------------------------------------------------------------------===//
+// The following code is reduced using delta-debugging from Mac OS X headers:
+//
+// #include <Cocoa/Cocoa.h>
+// #include <CoreFoundation/CoreFoundation.h>
+// #include <DiskArbitration/DiskArbitration.h>
+// #include <QuartzCore/QuartzCore.h>
+// #include <Quartz/Quartz.h>
+// #include <IOKit/IOKitLib.h>
+//
+// It includes the basic definitions for the test cases below.
+//===----------------------------------------------------------------------===//
+
+typedef unsigned int __darwin_natural_t;
+typedef unsigned long uintptr_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+typedef unsigned int UInt32;
+typedef signed long CFIndex;
+typedef CFIndex CFByteOrder;
+typedef struct {
+ CFIndex location;
+ CFIndex length;
+} CFRange;
+static __inline__ __attribute__((always_inline)) CFRange CFRangeMake(CFIndex loc, CFIndex len) {
+ CFRange range;
+ range.location = loc;
+ range.length = len;
+ return range;
+}
+typedef const void * CFTypeRef;
+typedef const struct __CFString * CFStringRef;
+typedef const struct __CFAllocator * CFAllocatorRef;
+extern const CFAllocatorRef kCFAllocatorDefault;
+extern CFTypeRef CFRetain(CFTypeRef cf);
+extern void CFRelease(CFTypeRef cf);
+typedef struct {
+}
+CFArrayCallBacks;
+extern const CFArrayCallBacks kCFTypeArrayCallBacks;
+typedef const struct __CFArray * CFArrayRef;
+typedef struct __CFArray * CFMutableArrayRef;
+extern CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFArrayCallBacks *callBacks);
+extern const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx);
+extern void CFArrayAppendValue(CFMutableArrayRef theArray, const void *value);
+typedef struct {
+}
+CFDictionaryKeyCallBacks;
+extern const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks;
+typedef struct {
+}
+CFDictionaryValueCallBacks;
+extern const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks;
+typedef const struct __CFDictionary * CFDictionaryRef;
+typedef struct __CFDictionary * CFMutableDictionaryRef;
+extern CFMutableDictionaryRef CFDictionaryCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);
+typedef UInt32 CFStringEncoding;
+enum {
+kCFStringEncodingMacRoman = 0, kCFStringEncodingWindowsLatin1 = 0x0500, kCFStringEncodingISOLatin1 = 0x0201, kCFStringEncodingNextStepLatin = 0x0B01, kCFStringEncodingASCII = 0x0600, kCFStringEncodingUnicode = 0x0100, kCFStringEncodingUTF8 = 0x08000100, kCFStringEncodingNonLossyASCII = 0x0BFF , kCFStringEncodingUTF16 = 0x0100, kCFStringEncodingUTF16BE = 0x10000100, kCFStringEncodingUTF16LE = 0x14000100, kCFStringEncodingUTF32 = 0x0c000100, kCFStringEncodingUTF32BE = 0x18000100, kCFStringEncodingUTF32LE = 0x1c000100 };
+extern CFStringRef CFStringCreateWithCString(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding);
+typedef double CFTimeInterval;
+typedef CFTimeInterval CFAbsoluteTime;
+extern CFAbsoluteTime CFAbsoluteTimeGetCurrent(void);
+typedef const struct __CFDate * CFDateRef;
+extern CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at);
+extern CFAbsoluteTime CFDateGetAbsoluteTime(CFDateRef theDate);
+typedef __darwin_natural_t natural_t;
+typedef natural_t mach_port_name_t;
+typedef mach_port_name_t mach_port_t;
+typedef int kern_return_t;
+typedef kern_return_t mach_error_t;
+enum {
+kCFNumberSInt8Type = 1, kCFNumberSInt16Type = 2, kCFNumberSInt32Type = 3, kCFNumberSInt64Type = 4, kCFNumberFloat32Type = 5, kCFNumberFloat64Type = 6, kCFNumberCharType = 7, kCFNumberShortType = 8, kCFNumberIntType = 9, kCFNumberLongType = 10, kCFNumberLongLongType = 11, kCFNumberFloatType = 12, kCFNumberDoubleType = 13, kCFNumberCFIndexType = 14, kCFNumberNSIntegerType = 15, kCFNumberCGFloatType = 16, kCFNumberMaxType = 16 };
+typedef CFIndex CFNumberType;
+typedef const struct __CFNumber * CFNumberRef;
+extern CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr);
+typedef const struct __CFAttributedString *CFAttributedStringRef;
+typedef struct __CFAttributedString *CFMutableAttributedStringRef;
+extern CFAttributedStringRef CFAttributedStringCreate(CFAllocatorRef alloc, CFStringRef str, CFDictionaryRef attributes) ;
+extern CFMutableAttributedStringRef CFAttributedStringCreateMutableCopy(CFAllocatorRef alloc, CFIndex maxLength, CFAttributedStringRef aStr) ;
+extern void CFAttributedStringSetAttribute(CFMutableAttributedStringRef aStr, CFRange range, CFStringRef attrName, CFTypeRef value) ;
+typedef signed char BOOL;
+typedef unsigned long NSUInteger;
+@class NSString, Protocol;
+extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (id)retain;
+- (oneway void)release;
+- (id)autorelease;
+- (id)init;
+@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
+@end @protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
+@end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
++ (id)allocWithZone:(NSZone *)zone;
++ (id)alloc;
+- (void)dealloc;
+@end
+@interface NSObject (NSCoderMethods)
+- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder;
+@end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+typedef struct {
+}
+NSFastEnumerationState;
+@protocol NSFastEnumeration - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end @class NSString, NSDictionary;
+@interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value;
+@end @interface NSNumber : NSValue - (char)charValue;
+- (id)initWithInt:(int)value;
+@end @class NSString;
+@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
+@end @interface NSArray (NSArrayCreation) + (id)array;
+@end @interface NSAutoreleasePool : NSObject {
+}
+- (void)drain;
+@end extern NSString * const NSBundleDidLoadNotification;
+typedef double NSTimeInterval;
+@interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate;
+@end typedef unsigned short unichar;
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
+- (NSUInteger)length;
+- (NSString *)stringByAppendingString:(NSString *)aString;
+- ( const char *)UTF8String;
+- (id)initWithUTF8String:(const char *)nullTerminatedCString;
++ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
+@end @class NSString, NSURL, NSError;
+@interface NSData : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length;
++ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length;
++ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b;
+@end @class NSLocale, NSDate, NSCalendar, NSTimeZone, NSError, NSArray, NSMutableDictionary;
+@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
+@end @interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey;
+- (void)setObject:(id)anObject forKey:(id)aKey;
+@end @interface NSMutableDictionary (NSMutableDictionaryCreation) + (id)dictionaryWithCapacity:(NSUInteger)numItems;
+@end typedef double CGFloat;
+struct CGSize {
+};
+typedef struct CGSize CGSize;
+struct CGRect {
+};
+typedef struct CGRect CGRect;
+typedef mach_port_t io_object_t;
+typedef char io_name_t[128];
+typedef io_object_t io_iterator_t;
+typedef io_object_t io_service_t;
+typedef struct IONotificationPort * IONotificationPortRef;
+typedef void (*IOServiceMatchingCallback)( void * refcon, io_iterator_t iterator );
+io_service_t IOServiceGetMatchingService( mach_port_t masterPort, CFDictionaryRef matching );
+kern_return_t IOServiceGetMatchingServices( mach_port_t masterPort, CFDictionaryRef matching, io_iterator_t * existing );
+kern_return_t IOServiceAddNotification( mach_port_t masterPort, const io_name_t notificationType, CFDictionaryRef matching, mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) __attribute__((deprecated));
+kern_return_t IOServiceAddMatchingNotification( IONotificationPortRef notifyPort, const io_name_t notificationType, CFDictionaryRef matching, IOServiceMatchingCallback callback, void * refCon, io_iterator_t * notification );
+CFMutableDictionaryRef IOServiceMatching( const char * name );
+CFMutableDictionaryRef IOServiceNameMatching( const char * name );
+CFMutableDictionaryRef IOBSDNameMatching( mach_port_t masterPort, uint32_t options, const char * bsdName );
+CFMutableDictionaryRef IOOpenFirmwarePathMatching( mach_port_t masterPort, uint32_t options, const char * path );
+CFMutableDictionaryRef IORegistryEntryIDMatching( uint64_t entryID );
+typedef struct __DASession * DASessionRef;
+extern DASessionRef DASessionCreate( CFAllocatorRef allocator );
+typedef struct __DADisk * DADiskRef;
+extern DADiskRef DADiskCreateFromBSDName( CFAllocatorRef allocator, DASessionRef session, const char * name );
+extern DADiskRef DADiskCreateFromIOMedia( CFAllocatorRef allocator, DASessionRef session, io_service_t media );
+extern CFDictionaryRef DADiskCopyDescription( DADiskRef disk );
+extern DADiskRef DADiskCopyWholeDisk( DADiskRef disk );
+@interface NSTask : NSObject - (id)init;
+@end typedef struct CGColorSpace *CGColorSpaceRef;
+typedef struct CGImage *CGImageRef;
+typedef struct CGLayer *CGLayerRef;
+@interface NSResponder : NSObject <NSCoding> {
+}
+@end @protocol NSAnimatablePropertyContainer - (id)animator;
+@end extern NSString *NSAnimationTriggerOrderIn ;
+@interface NSView : NSResponder <NSAnimatablePropertyContainer> {
+}
+@end @protocol NSValidatedUserInterfaceItem - (SEL)action;
+@end @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem;
+@end @class NSDate, NSDictionary, NSError, NSException, NSNotification;
+@interface NSApplication : NSResponder <NSUserInterfaceValidations> {
+}
+@end enum {
+NSTerminateCancel = 0, NSTerminateNow = 1, NSTerminateLater = 2 };
+typedef NSUInteger NSApplicationTerminateReply;
+@protocol NSApplicationDelegate <NSObject> @optional - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
+@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView, NSTextView;
+@interface NSCell : NSObject <NSCopying, NSCoding> {
+}
+@end @class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError;
+typedef struct {
+}
+CVTimeStamp;
+@interface CIImage : NSObject <NSCoding, NSCopying> {
+}
+typedef int CIFormat;
+@end enum {
+kDAReturnSuccess = 0, kDAReturnError = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x01, kDAReturnBusy = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x02, kDAReturnBadArgument = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x03, kDAReturnExclusiveAccess = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x04, kDAReturnNoResources = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x05, kDAReturnNotFound = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x06, kDAReturnNotMounted = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x07, kDAReturnNotPermitted = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x08, kDAReturnNotPrivileged = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x09, kDAReturnNotReady = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0A, kDAReturnNotWritable = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0B, kDAReturnUnsupported = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0C };
+typedef mach_error_t DAReturn;
+typedef const struct __DADissenter * DADissenterRef;
+extern DADissenterRef DADissenterCreate( CFAllocatorRef allocator, DAReturn status, CFStringRef string );
+@interface CIContext: NSObject {
+}
+- (CGImageRef)createCGImage:(CIImage *)im fromRect:(CGRect)r;
+- (CGImageRef)createCGImage:(CIImage *)im fromRect:(CGRect)r format:(CIFormat)f colorSpace:(CGColorSpaceRef)cs;
+- (CGLayerRef)createCGLayerWithSize:(CGSize)size info:(CFDictionaryRef)d;
+@end extern NSString* const QCRendererEventKey;
+@protocol QCCompositionRenderer - (NSDictionary*) attributes;
+@end @interface QCRenderer : NSObject <QCCompositionRenderer> {
+}
+- (id) createSnapshotImageOfType:(NSString*)type;
+@end extern NSString* const QCViewDidStartRenderingNotification;
+@interface QCView : NSView <QCCompositionRenderer> {
+}
+- (id) createSnapshotImageOfType:(NSString*)type;
+@end enum {
+ICEXIFOrientation1 = 1, ICEXIFOrientation2 = 2, ICEXIFOrientation3 = 3, ICEXIFOrientation4 = 4, ICEXIFOrientation5 = 5, ICEXIFOrientation6 = 6, ICEXIFOrientation7 = 7, ICEXIFOrientation8 = 8, };
+@class ICDevice;
+@protocol ICDeviceDelegate <NSObject> @required - (void)didRemoveDevice:(ICDevice*)device;
+@end extern NSString *const ICScannerStatusWarmingUp;
+@class ICScannerDevice;
+@protocol ICScannerDeviceDelegate <ICDeviceDelegate> @optional - (void)scannerDeviceDidBecomeAvailable:(ICScannerDevice*)scanner;
+@end
+
+typedef long unsigned int __darwin_size_t;
+typedef __darwin_size_t size_t;
+typedef unsigned long CFTypeID;
+struct CGPoint {
+ CGFloat x;
+ CGFloat y;
+};
+typedef struct CGPoint CGPoint;
+typedef struct CGGradient *CGGradientRef;
+typedef uint32_t CGGradientDrawingOptions;
+extern CFTypeID CGGradientGetTypeID(void);
+extern CGGradientRef CGGradientCreateWithColorComponents(CGColorSpaceRef
+ space, const CGFloat components[], const CGFloat locations[], size_t count);
+extern CGGradientRef CGGradientCreateWithColors(CGColorSpaceRef space,
+ CFArrayRef colors, const CGFloat locations[]);
+extern CGGradientRef CGGradientRetain(CGGradientRef gradient);
+extern void CGGradientRelease(CGGradientRef gradient);
+typedef struct CGContext *CGContextRef;
+extern void CGContextDrawLinearGradient(CGContextRef context,
+ CGGradientRef gradient, CGPoint startPoint, CGPoint endPoint,
+ CGGradientDrawingOptions options);
+extern CGColorSpaceRef CGColorSpaceCreateDeviceRGB(void);
+
+@interface NSMutableArray : NSObject
+- (void)addObject:(id)object;
++ (id)array;
+@end
+
+enum {
+ NSASCIIStringEncoding = 1,
+ NSNEXTSTEPStringEncoding = 2,
+ NSJapaneseEUCStringEncoding = 3,
+ NSUTF8StringEncoding = 4,
+ NSISOLatin1StringEncoding = 5,
+ NSSymbolStringEncoding = 6,
+ NSNonLossyASCIIStringEncoding = 7,
+};
+typedef struct __CFString * CFMutableStringRef;
+typedef NSUInteger NSStringEncoding;
+
+extern CFStringRef CFStringCreateWithCStringNoCopy(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding, CFAllocatorRef contentsDeallocator);
+
+//===----------------------------------------------------------------------===//
+// Test cases.
+//===----------------------------------------------------------------------===//
+
+void foo(id x) {
+ [x retain];
+}
+
+void bar(id x) {
+ [x release];
+}
+
+void test() {
+ NSString *s = [[NSString alloc] init]; // expected-warning {{Potential leak}}
+ foo(s);
+ foo(s);
+ bar(s);
+}
+void test_neg() {
+ NSString *s = [[NSString alloc] init]; // no-warning
+ foo(s);
+ foo(s);
+ bar(s);
+ bar(s);
+ bar(s);
+}
+
+//===----------------------------------------------------------------------===//
+// Test returning retained and not-retained values.
+//===----------------------------------------------------------------------===//
+
+// On return (intraprocedural), assume CF objects are leaked.
+CFStringRef test_return_ratained_CF(char *bytes) {
+ CFStringRef str;
+ return CFStringCreateWithCStringNoCopy(0, bytes, NSNEXTSTEPStringEncoding, 0); // expected-warning {{leak}}
+}
+
+// On return (intraprocedural), assume NSObjects are not leaked.
+id test_return_retained_NS() {
+ return [[NSString alloc] init]; // no-warning
+}
+
+void test_test_return_retained() {
+ id x = test_return_retained_NS(); // expected-warning {{leak}}
+ [x retain];
+ [x release];
+}
+
+//===----------------------------------------------------------------------===//
+// Test not applying "double effects" from inlining and RetainCountChecker summaries.
+// If we inline a call, we should already see its retain/release semantics.
+//===----------------------------------------------------------------------===//
+
+__attribute__((cf_returns_retained)) CFStringRef test_return_inline(CFStringRef x) {
+ CFRetain(x);
+ return x;
+}
+
+void test_test_return_inline(char *bytes) {
+ CFStringRef str = CFStringCreateWithCStringNoCopy(0, bytes, NSNEXTSTEPStringEncoding, 0);
+ // After this call, 'str' really has +2 reference count.
+ CFStringRef str2 = test_return_inline(str);
+ // After this call, 'str' really has a +1 reference count.
+ CFRelease(str);
+ // After this call, 'str2' and 'str' has a +0 reference count.
+ CFRelease(str2);
+}
+
+void test_test_return_inline_2(char *bytes) {
+ CFStringRef str = CFStringCreateWithCStringNoCopy(0, bytes, NSNEXTSTEPStringEncoding, 0); // expected-warning {{leak}}
+ // After this call, 'str' really has +2 reference count.
+ CFStringRef str2 = test_return_inline(str);
+ // After this call, 'str' really has a +1 reference count.
+ CFRelease(str);
+}
+
+
+
diff --git a/test/Analysis/retain-release-path-notes-gc.m b/test/Analysis/retain-release-path-notes-gc.m
index 19e6d7b8b337..1e74f003e1a7 100644
--- a/test/Analysis/retain-release-path-notes-gc.m
+++ b/test/Analysis/retain-release-path-notes-gc.m
@@ -45,9 +45,9 @@ void creationViaCFCreate () {
void makeCollectable () {
CFTypeRef leaked = CFCreateSomething(); // expected-warning{{leak}} expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected}}
CFRetain(leaked); // expected-note{{Reference count incremented. The object now has a +2 retain count}}
- CFMakeCollectable(leaked); // expected-note{{In GC mode a call to 'CFMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. An object must have a 0 retain count to be garbage collected. After this call its retain count is +1.}}
+ CFMakeCollectable(leaked); // expected-note{{In GC mode a call to 'CFMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. An object must have a 0 retain count to be garbage collected. After this call its retain count is +1}}
NSMakeCollectable(leaked); // expected-note{{In GC mode a call to 'NSMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. Since it now has a 0 retain count the object can be automatically collected by the garbage collector}}
- CFRetain(leaked); // expected-note{{Reference count incremented. The object now has a +1 retain count. The object is not eligible for garbage collection until the retain count reaches 0 again.}}
+ CFRetain(leaked); // expected-note{{Reference count incremented. The object now has a +1 retain count. The object is not eligible for garbage collection until the retain count reaches 0 again}}
return; // expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
}
@@ -61,12 +61,12 @@ void retainReleaseIgnored () {
@implementation Foo (FundamentalRuleUnderGC)
- (id)getViolation {
- id object = (id) CFCreateSomething(); // expected-warning{{leak}} expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected.}}
+ id object = (id) CFCreateSomething(); // expected-warning{{leak}} expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected}}
return object; // expected-note{{Object returned to caller as an owning reference (single retain count transferred to caller)}} expected-note{{Object leaked: object allocated and stored into 'object' and returned from method 'getViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector}}
}
- (id)copyViolation {
- id object = (id) CFCreateSomething(); // expected-warning{{leak}} expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected.}}
+ id object = (id) CFCreateSomething(); // expected-warning{{leak}} expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected}}
return object; // expected-note{{Object returned to caller as an owning reference (single retain count transferred to caller)}} expected-note{{Object leaked: object allocated and stored into 'object' and returned from method 'copyViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector}}
}
@end
diff --git a/test/Analysis/retain-release-path-notes.m b/test/Analysis/retain-release-path-notes.m
index e34942a8968c..c3f5fcda4442 100644
--- a/test/Analysis/retain-release-path-notes.m
+++ b/test/Analysis/retain-release-path-notes.m
@@ -1,5 +1,9 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -analyzer-output=text -verify %s
+// This actually still works after the pseudo-object refactor, it just
+// uses messages that say 'method' instead of 'property'. Ted wanted
+// this xfailed and filed as a bug. rdar://problem/10402993
+
/***
This file is for testing the path-sensitive notes for retain/release errors.
Its goal is to have simple branch coverage of any path-based diagnostics,
@@ -100,13 +104,13 @@ void makeCollectableIgnored () {
}
CFTypeRef CFCopyRuleViolation () {
- CFTypeRef object = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain counte}}
+ CFTypeRef object = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count}}
return object; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} expected-note{{Object returned to caller with a +0 retain count}} expected-note{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}}
}
CFTypeRef CFGetRuleViolation () {
- CFTypeRef object = CFCreateSomething(); // expected-warning{{leak}} expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain counte}}
- return object; // expected-note{{Object returned to caller as an owning reference (single retain count transferred to caller)}} expected-note{{Object leaked: object allocated and stored into 'object' is return from a function whose name ('CFGetRuleViolation') does not contain 'Copy' or 'Create'. This violates the naming convention rules given the Memory Management Guide for Core Foundation}}
+ CFTypeRef object = CFCreateSomething(); // expected-warning{{leak}} expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count}}
+ return object; // expected-note{{Object returned to caller as an owning reference (single retain count transferred to caller)}} expected-note{{Object leaked: object allocated and stored into 'object' is returned from a function whose name ('CFGetRuleViolation') does not contain 'Copy' or 'Create'. This violates the naming convention rules given in the Memory Management Guide for Core Foundation}}
}
@implementation Foo (FundamentalMemoryManagementRules)
@@ -119,4 +123,10 @@ CFTypeRef CFGetRuleViolation () {
id result = [[Foo alloc] init]; // expected-warning{{leak}} expected-note{{Method returns an Objective-C object with a +1 retain count}}
return result; // expected-note{{Object returned to caller as an owning reference (single retain count transferred to caller)}} expected-note{{Object leaked: object allocated and stored into 'result' is returned from a method whose name ('getViolation') does not start with 'copy', 'mutableCopy', 'alloc' or 'new'. This violates the naming convention rules given in the Memory Management Guide for Cocoa}}
}
+
+- (id)copyAutorelease {
+ id result = [[Foo alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}}
+ [result autorelease]; // expected-note{{Object sent -autorelease message}}
+ return result; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} expected-note{{Object returned to caller with a +0 retain count}} expected-note{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}}
+}
@end
diff --git a/test/Analysis/retain-release-region-store.m b/test/Analysis/retain-release-region-store.m
index 89950ce7cd25..917381341a4b 100644
--- a/test/Analysis/retain-release-region-store.m
+++ b/test/Analysis/retain-release-region-store.m
@@ -100,6 +100,10 @@ struct foo {
NSDate* f;
};
+// FIXME: We should be warning about a use-after-free here, but we
+// temporarily "escape" retain counted objects stored to structs very eagerly
+// until we can properly tell whether they have escaped via a return value
+// or not.
CFAbsoluteTime f4() {
struct foo x;
@@ -110,7 +114,8 @@ CFAbsoluteTime f4() {
CFDateGetAbsoluteTime(date); // no-warning
x.f = (NSDate*) date;
[((NSDate*) date) release];
- t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released.}}
+ // FIXME: the following line should warn.
+ t = CFDateGetAbsoluteTime(date); // no-warning
return t;
}
diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m
index 6f8bf09ebd74..06c510e5dd3e 100644
--- a/test/Analysis/retain-release.m
+++ b/test/Analysis/retain-release.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify -x objective-c++ %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify -x objective-c++ -Wno-objc-root-class %s
#if __has_feature(attribute_ns_returns_retained)
#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
@@ -42,6 +42,7 @@ typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
typedef unsigned int UInt32;
typedef signed long CFIndex;
+typedef CFIndex CFByteOrder;
typedef struct {
CFIndex location;
CFIndex length;
@@ -114,10 +115,15 @@ typedef struct _NSZone NSZone;
- (id)retain;
- (oneway void)release;
- (id)autorelease;
+- (NSString *)description;
- (id)init;
-@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
-@end @protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
-@end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@protocol NSCopying
+- (id)copyWithZone:(NSZone *)zone;
+@end
+@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
+@end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
@end
@interface NSObject <NSObject> {}
+ (id)allocWithZone:(NSZone *)zone;
@@ -131,13 +137,22 @@ extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
typedef struct {
}
NSFastEnumerationState;
-@protocol NSFastEnumeration - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
-@end @class NSString, NSDictionary;
+@protocol NSFastEnumeration
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end
+@class NSString, NSDictionary;
@interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value;
@end @interface NSNumber : NSValue - (char)charValue;
- (id)initWithInt:(int)value;
@end @class NSString;
-@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
+@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
+- (NSUInteger)count;
+- (id)initWithObjects:(const id [])objects count:(NSUInteger)cnt;
++ (id)arrayWithObject:(id)anObject;
++ (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt;
++ (id)arrayWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
+- (id)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
+- (id)initWithArray:(NSArray *)array;
@end @interface NSArray (NSArrayCreation) + (id)array;
@end @interface NSAutoreleasePool : NSObject {
}
@@ -157,8 +172,12 @@ typedef double NSTimeInterval;
+ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length;
+ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b;
@end @class NSLocale, NSDate, NSCalendar, NSTimeZone, NSError, NSArray, NSMutableDictionary;
-@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
-@end @interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey;
+@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
+- (NSUInteger)count;
++ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt;
+@end
+@interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey;
- (void)setObject:(id)anObject forKey:(id)aKey;
@end @interface NSMutableDictionary (NSMutableDictionaryCreation) + (id)dictionaryWithCapacity:(NSUInteger)numItems;
@end typedef double CGFloat;
@@ -671,7 +690,7 @@ void rdar6704930(unsigned char *s, unsigned int length) {
//===----------------------------------------------------------------------===//
// <rdar://problem/6257780> clang checker fails to catch use-after-release
//===----------------------------------------------------------------------===//
-
+
int rdar_6257780_Case1() {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSArray *array = [NSArray array];
@@ -681,6 +700,15 @@ int rdar_6257780_Case1() {
}
//===----------------------------------------------------------------------===//
+// <rdar://problem/10640253> Analyzer is confused about NSAutoreleasePool -allocWithZone:.
+//===----------------------------------------------------------------------===//
+
+void rdar_10640253_autorelease_allocWithZone() {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool allocWithZone:(NSZone*)0] init];
+ (void) pool;
+}
+
+//===----------------------------------------------------------------------===//
// <rdar://problem/6866843> Checker should understand new/setObject:/release constructs
//===----------------------------------------------------------------------===//
@@ -1458,7 +1486,7 @@ static void rdar_8724287(CFErrorRef error)
while (error_to_dump != ((void*)0)) {
CFDictionaryRef info;
- info = CFErrorCopyUserInfo(error_to_dump); // expected-warning{{Potential leak of an object allocated on line}}
+ info = CFErrorCopyUserInfo(error_to_dump); // expected-warning{{Potential leak of an object}}
if (info != ((void*)0)) {
}
@@ -1604,3 +1632,110 @@ void rdar10232019_positive() {
NSLog(@"%@", otherString);
}
+// RetainCountChecker support for XPC.
+// <rdar://problem/9658496>
+typedef void * xpc_object_t;
+xpc_object_t _CFXPCCreateXPCObjectFromCFObject(CFTypeRef cf);
+void xpc_release(xpc_object_t object);
+
+void rdar9658496() {
+ CFStringRef cf;
+ xpc_object_t xpc;
+ cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning
+ xpc = _CFXPCCreateXPCObjectFromCFObject( cf );
+ CFRelease(cf);
+ xpc_release(xpc);
+}
+
+// Support annotations with method families.
+@interface RDar10824732 : NSObject
+- (id)initWithObj:(id CF_CONSUMED)obj;
+@end
+
+@implementation RDar10824732
+- (id)initWithObj:(id)obj {
+ [obj release];
+ return [super init];
+}
+@end
+
+void rdar_10824732() {
+ @autoreleasepool {
+ NSString *obj = @"test";
+ RDar10824732 *foo = [[RDar10824732 alloc] initWithObj:obj]; // no-warning
+ [foo release];
+ }
+}
+
+//===----------------------------------------------------------------------===//
+// Test returning allocated memory in a struct.
+//
+// We currently don't have a general way to track pointers that "escape".
+// Here we test that RetainCountChecker doesn't get excited about returning
+// allocated CF objects in struct fields.
+//===----------------------------------------------------------------------===//
+void *malloc(size_t);
+struct rdar11104566 { CFStringRef myStr; };
+struct rdar11104566 test_rdar11104566() {
+ CFStringRef cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning
+ struct rdar11104566 V;
+ V.myStr = cf;
+ return V; // no-warning
+}
+
+struct rdar11104566 *test_2_rdar11104566() {
+ CFStringRef cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning
+ struct rdar11104566 *V = (struct rdar11104566 *) malloc(sizeof(*V));
+ V->myStr = cf;
+ return V; // no-warning
+}
+
+//===----------------------------------------------------------------------===//
+// ObjC literals support.
+//===----------------------------------------------------------------------===//
+
+void test_objc_arrays() {
+ { // CASE ONE -- OBJECT IN ARRAY CREATED DIRECTLY
+ NSObject *o = [[NSObject alloc] init];
+ NSArray *a = [[NSArray alloc] initWithObjects:o, (void*)0]; // expected-warning {{leak}}
+ [o release];
+ [a description];
+ [o description];
+ }
+
+ { // CASE TWO -- OBJECT IN ARRAY CREATED BY DUPING AUTORELEASED ARRAY
+ NSObject *o = [[NSObject alloc] init];
+ NSArray *a1 = [NSArray arrayWithObjects:o, (void*)0];
+ NSArray *a2 = [[NSArray alloc] initWithArray:a1]; // expected-warning {{leak}}
+ [o release];
+ [a2 description];
+ [o description];
+ }
+
+ { // CASE THREE -- OBJECT IN RETAINED @[]
+ NSObject *o = [[NSObject alloc] init];
+ NSArray *a3 = [@[o] retain]; // expected-warning {{leak}}
+ [o release];
+ [a3 description];
+ [o description];
+ }
+
+ { // CASE FOUR -- OBJECT IN ARRAY CREATED BY DUPING @[]
+ NSObject *o = [[NSObject alloc] init];
+ NSArray *a = [[NSArray alloc] initWithArray:@[o]]; // expected-warning {{leak}}
+ [o release];
+
+ [a description];
+ [o description];
+ }
+
+ { // CASE FIVE -- OBJECT IN RETAINED @{}
+ NSValue *o = [[NSValue alloc] init];
+ NSDictionary *a = [@{o : o} retain]; // expected-warning {{leak}}
+ [o release];
+
+ [a description];
+ [o description];
+ }
+}
+
diff --git a/test/Analysis/retain-release.mm b/test/Analysis/retain-release.mm
index bae8dc339254..01727ea64434 100644
--- a/test/Analysis/retain-release.mm
+++ b/test/Analysis/retain-release.mm
@@ -111,6 +111,7 @@ typedef struct _NSZone NSZone;
@protocol NSObject
- (BOOL)isEqual:(id)object;
- (id)retain;
+- (id)copy;
- (oneway void)release;
- (id)autorelease;
@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
@@ -304,6 +305,12 @@ void test_smartpointer_3() {
foo.noAdopt(x);
}
+void test_smartpointer_4() {
+ id x = [[NSObject alloc] init]; // no-warning
+ SmartPointer *foo = new SmartPointer(x);
+ delete foo;
+}
+
extern CFStringRef ElectronMicroscopyEngage(void);
void test_microscopy() {
NSString *token = (NSString*) ElectronMicroscopyEngage();
@@ -315,3 +322,47 @@ void test_Scopy() {
NSString *token = (NSString*) Scopy();
[token release]; // expected-warning {{object that is not owned}}
}
+
+//===----------------------------------------------------------------------===//
+// Test handling of template functions used to do magic with
+// tracked retained pointers.
+//===----------------------------------------------------------------------===//
+
+template <typename T, typename U> T static_objc_cast(U* value)
+{
+ // ...debugging code omitted...
+ return static_cast<T>(value);
+}
+
+int rdar10553686(void)
+{
+ NSObject* bar = static_objc_cast<NSObject*>([[NSObject alloc] init]);
+ [bar release];
+ return 0;
+}
+int rdar10553686_positive(void)
+{
+ NSObject* bar = static_objc_cast<NSObject*>([[NSObject alloc] init]);
+ [bar release];
+ [bar retain]; // expected-warning {{used after it is released}}
+ return 0;
+}
+
+@interface NSMapTable : NSObject <NSCopying, NSCoding, NSFastEnumeration>
+@end
+extern void *NSMapGet(NSMapTable *table, const void *key);
+extern void NSMapInsert(NSMapTable *table, const void *key, const void *value);
+extern void NSMapInsertKnownAbsent(NSMapTable *table, const void *key, const void *value);
+char *strdup(const char *s);
+
+NSString * radar11152419(NSString *string1, NSString *key1, NSMapTable *map) {
+ NSString *string = ( NSString *)NSMapGet(map, key1);
+ if (!string) {
+ string = [string1 copy];
+ NSString *key = [key1 copy];
+ NSMapInsert(map, (void*) key, (void*)string); // no warning
+ NSMapInsertKnownAbsent(map, (void*)key, (void*)string); // no warning
+ }
+ return string;
+}
+
diff --git a/test/Analysis/security-syntax-checks-no-emit.c b/test/Analysis/security-syntax-checks-no-emit.c
index cbd432a19b31..c2869cabae99 100644
--- a/test/Analysis/security-syntax-checks-no-emit.c
+++ b/test/Analysis/security-syntax-checks-no-emit.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i686-pc-linux-gnu -analyze -analyzer-checker=experimental.security.SecuritySyntactic %s -verify
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -analyze -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify
// This file complements 'security-syntax-checks.m', but tests that we omit
// specific checks on platforms where they don't make sense.
diff --git a/test/Analysis/security-syntax-checks.m b/test/Analysis/security-syntax-checks.m
index a04401b531f5..f4ccefe58cdb 100644
--- a/test/Analysis/security-syntax-checks.m
+++ b/test/Analysis/security-syntax-checks.m
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=experimental.security.SecuritySyntactic %s -verify
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -DUSE_BUILTINS -analyzer-checker=experimental.security.SecuritySyntactic %s -verify
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -DVARIANT -analyzer-checker=experimental.security.SecuritySyntactic %s -verify
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=experimental.security.SecuritySyntactic %s -verify
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -DUSE_BUILTINS -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -DVARIANT -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify
#ifdef USE_BUILTINS
# define BUILTIN(f) __builtin_ ## f
@@ -138,7 +138,7 @@ void test_strcpy() {
char x[4];
char *y;
- strcpy(x, y); //expected-warning{{Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strncpy'. CWE-119.}}
+ strcpy(x, y); //expected-warning{{Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119.}}
}
//===----------------------------------------------------------------------===
@@ -162,7 +162,7 @@ void test_strcat() {
char x[4];
char *y;
- strcat(x, y); //expected-warning{{Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strncat'. CWE-119.}}
+ strcat(x, y); //expected-warning{{Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119.}}
}
//===----------------------------------------------------------------------===
@@ -175,3 +175,25 @@ pid_t vfork(void);
void test_vfork() {
vfork(); //expected-warning{{Call to function 'vfork' is insecure as it can lead to denial of service situations in the parent process.}}
}
+
+//===----------------------------------------------------------------------===
+// mkstemp()
+//===----------------------------------------------------------------------===
+
+char *mkdtemp(char *template);
+int mkstemps(char *template, int suffixlen);
+int mkstemp(char *template);
+char *mktemp(char *template);
+
+void test_mkstemp() {
+ mkstemp("XX"); // expected-warning {{Call to 'mkstemp' should have at least 6 'X's in the format string to be secure (2 'X's seen)}}
+ mkstemp("XXXXXX");
+ mkstemp("XXXXXXX");
+ mkstemps("XXXXXX", 0);
+ mkstemps("XXXXXX", 1); // expected-warning {{5 'X's seen}}
+ mkstemps("XXXXXX", 2); // expected-warning {{Call to 'mkstemps' should have at least 6 'X's in the format string to be secure (4 'X's seen, 2 characters used as a suffix)}}
+ mkdtemp("XX"); // expected-warning {{2 'X's seen}}
+ mkstemp("X"); // expected-warning {{Call to 'mkstemp' should have at least 6 'X's in the format string to be secure (1 'X' seen)}}
+ mkdtemp("XXXXXX");
+}
+
diff --git a/test/Analysis/self-init.m b/test/Analysis/self-init.m
index 019fdcd0c2bf..3db42e9cf5ac 100644
--- a/test/Analysis/self-init.m
+++ b/test/Analysis/self-init.m
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.osx.cocoa.SelfInit %s -verify
+// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.SelfInit %s -verify
@class NSZone, NSCoder;
-@protocol NSObject
-@end
+@protocol NSObject- (id)self;
+@end
@protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
@end
@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
@@ -22,9 +22,14 @@
//#import "Foundation/NSObject.h"
typedef unsigned NSUInteger;
-typedef int NSInteger;
+typedef long NSInteger;
+
+@interface NSInvocation : NSObject {}
+- (void)getArgument:(void *)argumentLocation atIndex:(NSInteger)idx;
+- (void)setArgument:(void *)argumentLocation atIndex:(NSInteger)idx;
+@end
-@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@class NSMethodSignature, NSCoder, NSString, NSEnumerator;
@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
- (NSUInteger)length;
+ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
@@ -147,13 +152,30 @@ static id _commonInit(MyObj *self) {
}
-(id)init14 {
- if (!(self = [super init]))
- return 0;
if (!(self = _commonInit(self)))
return 0;
return self;
}
+-(id)init15 {
+ if (!(self = [super init]))
+ return 0;
+ return self;
+}
+
+-(id)init16 {
+ somePtr = [super init];
+ self = somePtr;
+ myivar = 0;
+ return self;
+}
+
+-(id)init17 {
+ somePtr = [super init];
+ myivar = 0; // expected-warning {{Instance variable used}}
+ return 0;
+}
+
-(void)doSomething {}
@end
@@ -163,3 +185,19 @@ static id _commonInit(MyObj *self) {
- (id)init { return self; }
@end
+
+
+// Test for radar://10973514 : self should not be invalidated by a method call.
+@interface Test : NSObject {
+ NSInvocation *invocation_;
+}
+@end
+@implementation Test
+-(id) initWithTarget:(id) rec selector:(SEL) cb {
+ if (self=[super init]) {
+ [invocation_ setArgument:&self atIndex:2];
+ }
+ return self;
+}
+@end
+
diff --git a/test/Analysis/stack-addr-ps.c b/test/Analysis/stack-addr-ps.c
index 558986d308d4..a443a32396f5 100644
--- a/test/Analysis/stack-addr-ps.c
+++ b/test/Analysis/stack-addr-ps.c
@@ -57,8 +57,15 @@ int struct_test(struct baz byVal, int flag) {
typedef int (^ComparatorBlock)(int a, int b);
ComparatorBlock test_return_block(void) {
+ // This block is a global since it has no captures.
ComparatorBlock b = ^int(int a, int b){ return a > b; };
- return b; // expected-warning{{Address of stack-allocated block declared on line 60 returned to caller}}
+ return b; // no-warning
+}
+
+ComparatorBlock test_return_block_with_capture(int x) {
+ // This block is stack allocated because it has captures.
+ ComparatorBlock b = ^int(int a, int b){ return a > b + x; };
+ return b; // expected-warning{{Address of stack-allocated block}}
}
ComparatorBlock test_return_block_neg_aux(void);
@@ -73,4 +80,13 @@ int *rdar_7523821_f2() {
return a; // expected-warning 2 {{ddress of stack memory associated with local variable 'a' returned}}
};
+// Handle blocks that have no captures or are otherwise declared 'static'.
+// <rdar://problem/10348049>
+typedef int (^RDar10348049)(int value);
+RDar10348049 test_rdar10348049(void) {
+ static RDar10348049 b = ^int(int x) {
+ return x + 2;
+ };
+ return b; // no-warning
+}
diff --git a/test/Analysis/stats.c b/test/Analysis/stats.c
new file mode 100644
index 000000000000..6beadbeb412e
--- /dev/null
+++ b/test/Analysis/stats.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-stats %s 2>&1 | FileCheck %s
+
+void foo() {
+ int x;
+}
+// CHECK: ... Statistics Collected ...
+// CHECK:100 AnalysisConsumer - The % of reachable basic blocks.
+// CHECK:The # of times RemoveDeadBindings is called
diff --git a/test/Analysis/string.c b/test/Analysis/string.c
index a71e1f008817..c0814b89c17c 100644
--- a/test/Analysis/string.c
+++ b/test/Analysis/string.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.unix.CString,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,experimental.unix.CString,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,experimental.unix.CString,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=core,experimental.unix.CString,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,experimental.unix.cstring,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,experimental.unix.cstring,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,unix.cstring,experimental.unix.cstring,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=experimental.security.taint,core,unix.cstring,experimental.unix.cstring,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
//===----------------------------------------------------------------------===
// Declarations
@@ -26,6 +26,7 @@
#define NULL 0
typedef typeof(sizeof(int)) size_t;
+int scanf(const char *restrict format, ...);
//===----------------------------------------------------------------------===
// strlen()
@@ -132,6 +133,18 @@ void strlen_indirect(char *x) {
(void)*(char*)0; // expected-warning{{null}}
}
+void strlen_indirect2(char *x) {
+ size_t a = strlen(x);
+ char *p = x;
+ char **p2 = &p;
+ extern void use_string_ptr2(char**);
+ use_string_ptr2(p2);
+
+ size_t c = strlen(x);
+ if (a == 0 && c != 0)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
void strlen_liveness(const char *x) {
if (strlen(x) < 5)
return;
@@ -284,6 +297,10 @@ void strcpy_fn(char *x) {
strcpy(x, (char*)&strcpy_fn); // expected-warning{{Argument to string copy function is the address of the function 'strcpy_fn', which is not a null-terminated string}}
}
+void strcpy_fn_const(char *x) {
+ strcpy(x, (const char*)&strcpy_fn); // expected-warning{{Argument to string copy function is the address of the function 'strcpy_fn', which is not a null-terminated string}}
+}
+
void strcpy_effects(char *x, char *y) {
char a = x[0];
@@ -436,6 +453,13 @@ void strcat_symbolic_src_length(char *src) {
(void)*(char*)0; // no-warning
}
+void strcat_symbolic_dst_length_taint(char *dst) {
+ scanf("%s", dst); // Taint data.
+ strcat(dst, "1234");
+ if (strlen(dst) < 4)
+ (void)*(char*)0; // no-warning
+}
+
void strcat_unknown_src_length(char *src, int offset) {
char dst[8] = "1234";
strcat(dst, &src[offset]);
diff --git a/test/Analysis/system-header-simulator-objc.h b/test/Analysis/system-header-simulator-objc.h
new file mode 100644
index 000000000000..92d5899abf8d
--- /dev/null
+++ b/test/Analysis/system-header-simulator-objc.h
@@ -0,0 +1,114 @@
+#pragma clang system_header
+
+typedef unsigned int UInt32;
+typedef unsigned short UInt16;
+
+typedef signed long CFIndex;
+typedef signed char BOOL;
+typedef unsigned long NSUInteger;
+typedef unsigned short unichar;
+typedef UInt16 UniChar;
+
+enum {
+ NSASCIIStringEncoding = 1,
+ NSNEXTSTEPStringEncoding = 2,
+ NSJapaneseEUCStringEncoding = 3,
+ NSUTF8StringEncoding = 4,
+ NSISOLatin1StringEncoding = 5,
+ NSSymbolStringEncoding = 6,
+ NSNonLossyASCIIStringEncoding = 7,
+};
+typedef const struct __CFString * CFStringRef;
+typedef struct __CFString * CFMutableStringRef;
+typedef NSUInteger NSStringEncoding;
+typedef UInt32 CFStringEncoding;
+
+typedef const void * CFTypeRef;
+
+typedef const struct __CFAllocator * CFAllocatorRef;
+extern const CFAllocatorRef kCFAllocatorDefault;
+extern const CFAllocatorRef kCFAllocatorSystemDefault;
+extern const CFAllocatorRef kCFAllocatorMalloc;
+extern const CFAllocatorRef kCFAllocatorMallocZone;
+extern const CFAllocatorRef kCFAllocatorNull;
+
+@class NSString, Protocol;
+extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (id)retain;
+- (id)copy;
+- (oneway void)release;
+- (id)autorelease;
+- (id)init;
+@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
+@end @protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
+@end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
++ (id)allocWithZone:(NSZone *)zone;
++ (id)alloc;
+- (void)dealloc;
+@end
+@interface NSObject (NSCoderMethods)
+- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder;
+@end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+typedef struct {
+}
+NSFastEnumerationState;
+@protocol NSFastEnumeration - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end @class NSString, NSDictionary;
+@interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value;
+@end @interface NSNumber : NSValue - (char)charValue;
+- (id)initWithInt:(int)value;
+@end @class NSString;
+@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
+@end @interface NSArray (NSArrayCreation) + (id)array;
+@end @interface NSAutoreleasePool : NSObject {
+}
+- (void)drain;
+@end extern NSString * const NSBundleDidLoadNotification;
+typedef double NSTimeInterval;
+@interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate;
+@end
+
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
+- (NSUInteger)length;
+- (NSString *)stringByAppendingString:(NSString *)aString;
+- ( const char *)UTF8String;
+- (id)initWithUTF8String:(const char *)nullTerminatedCString;
+- (id)initWithCharactersNoCopy:(unichar *)characters length:(NSUInteger)length freeWhenDone:(BOOL)freeBuffer;
+- (id)initWithCharacters:(const unichar *)characters length:(NSUInteger)length;
+- (id)initWithBytes:(const void *)bytes length:(NSUInteger)len encoding:(NSStringEncoding)encoding;
+- (id)initWithBytesNoCopy:(void *)bytes length:(NSUInteger)len encoding:(NSStringEncoding)encoding freeWhenDone:(BOOL)freeBuffer;
++ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
+@end @class NSString, NSURL, NSError;
+@interface NSData : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length;
++ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length;
++ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b;
+- (id)initWithBytesNoCopy:(void *)bytes length:(NSUInteger)length;
+- (id)initWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b;
+@end
+
+typedef struct {
+}
+CFDictionaryKeyCallBacks;
+extern const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks;
+typedef struct {
+}
+CFDictionaryValueCallBacks;
+extern const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks;
+typedef const struct __CFDictionary * CFDictionaryRef;
+typedef struct __CFDictionary * CFMutableDictionaryRef;
+extern CFMutableDictionaryRef CFDictionaryCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);
+void CFDictionarySetValue(CFMutableDictionaryRef, const void *, const void *);
+
+
+extern void CFRelease(CFTypeRef cf);
+
+extern CFMutableStringRef CFStringCreateMutableWithExternalCharactersNoCopy(CFAllocatorRef alloc, UniChar *chars, CFIndex numChars, CFIndex capacity, CFAllocatorRef externalCharactersAllocator);
+extern CFStringRef CFStringCreateWithCStringNoCopy(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding, CFAllocatorRef contentsDeallocator);
+extern void CFStringAppend(CFMutableStringRef theString, CFStringRef appendedString);
diff --git a/test/Analysis/system-header-simulator.h b/test/Analysis/system-header-simulator.h
new file mode 100644
index 000000000000..6212131071de
--- /dev/null
+++ b/test/Analysis/system-header-simulator.h
@@ -0,0 +1,38 @@
+#pragma clang system_header
+
+typedef struct _FILE FILE;
+extern FILE *stdin;
+extern FILE *stdout;
+extern FILE *stderr;
+// Include a variant of standard streams that occur in the pre-processed file.
+extern FILE *__stdinp;
+extern FILE *__stdoutp;
+extern FILE *__stderrp;
+
+
+int fscanf(FILE *restrict, const char *restrict, ...);
+
+// Note, on some platforms errno macro gets replaced with a function call.
+extern int errno;
+
+unsigned long strlen(const char *);
+
+char *strcpy(char *restrict, const char *restrict);
+
+typedef unsigned long __darwin_pthread_key_t;
+typedef __darwin_pthread_key_t pthread_key_t;
+int pthread_setspecific(pthread_key_t, const void *);
+
+typedef long long __int64_t;
+typedef __int64_t __darwin_off_t;
+typedef __darwin_off_t fpos_t;
+
+void setbuf(FILE * restrict, char * restrict);
+int setvbuf(FILE * restrict, char * restrict, int, size_t);
+
+FILE *funopen(const void *,
+ int (*)(void *, char *, int),
+ int (*)(void *, const char *, int),
+ fpos_t (*)(void *, fpos_t, int),
+ int (*)(void *));
+
diff --git a/test/Analysis/taint-generic.c b/test/Analysis/taint-generic.c
new file mode 100644
index 000000000000..b00372a3ffbd
--- /dev/null
+++ b/test/Analysis/taint-generic.c
@@ -0,0 +1,185 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.security.taint,core,experimental.security.ArrayBoundV2 -Wno-format-security -verify %s
+
+int scanf(const char *restrict format, ...);
+int getchar(void);
+
+typedef struct _FILE FILE;
+extern FILE *stdin;
+int fscanf(FILE *restrict stream, const char *restrict format, ...);
+int sprintf(char *str, const char *format, ...);
+void setproctitle(const char *fmt, ...);
+typedef __typeof(sizeof(int)) size_t;
+
+// Define string functions. Use builtin for some of them. They all default to
+// the processing in the taint checker.
+#define strcpy(dest, src) \
+ ((__builtin_object_size(dest, 0) != -1ULL) \
+ ? __builtin___strcpy_chk (dest, src, __builtin_object_size(dest, 1)) \
+ : __inline_strcpy_chk(dest, src))
+
+static char *__inline_strcpy_chk (char *dest, const char *src) {
+ return __builtin___strcpy_chk(dest, src, __builtin_object_size(dest, 1));
+}
+char *stpcpy(char *restrict s1, const char *restrict s2);
+char *strncpy( char * destination, const char * source, size_t num );
+char *strndup(const char *s, size_t n);
+char *strncat(char *restrict s1, const char *restrict s2, size_t n);
+
+void *malloc(size_t);
+void *calloc(size_t nmemb, size_t size);
+void bcopy(void *s1, void *s2, size_t n);
+
+#define BUFSIZE 10
+
+int Buffer[BUFSIZE];
+void bufferScanfDirect(void)
+{
+ int n;
+ scanf("%d", &n);
+ Buffer[n] = 1; // expected-warning {{Out of bound memory access }}
+}
+
+void bufferScanfArithmetic1(int x) {
+ int n;
+ scanf("%d", &n);
+ int m = (n - 3);
+ Buffer[m] = 1; // expected-warning {{Out of bound memory access }}
+}
+
+void bufferScanfArithmetic2(int x) {
+ int n;
+ scanf("%d", &n);
+ int m = 100 - (n + 3) * x;
+ Buffer[m] = 1; // expected-warning {{Out of bound memory access }}
+}
+
+void bufferScanfAssignment(int x) {
+ int n;
+ scanf("%d", &n);
+ int m;
+ if (x > 0) {
+ m = n;
+ Buffer[m] = 1; // expected-warning {{Out of bound memory access }}
+ }
+}
+
+void scanfArg() {
+ int t = 0;
+ scanf("%d", t); // expected-warning {{format specifies type 'int *' but the argument has type 'int'}}
+}
+
+void bufferGetchar(int x) {
+ int m = getchar();
+ Buffer[m] = 1; //expected-warning {{Out of bound memory access (index is tainted)}}
+}
+
+void testUncontrolledFormatString(char **p) {
+ char s[80];
+ fscanf(stdin, "%s", s);
+ char buf[128];
+ sprintf(buf,s); // expected-warning {{Uncontrolled Format String}}
+ setproctitle(s, 3); // expected-warning {{Uncontrolled Format String}}
+
+ // Test taint propagation through strcpy and family.
+ char scpy[80];
+ strcpy(scpy, s);
+ sprintf(buf,scpy); // expected-warning {{Uncontrolled Format String}}
+
+ stpcpy(*(++p), s); // this generates __inline.
+ setproctitle(*(p), 3); // expected-warning {{Uncontrolled Format String}}
+
+ char spcpy[80];
+ stpcpy(spcpy, s);
+ setproctitle(spcpy, 3); // expected-warning {{Uncontrolled Format String}}
+
+ char *spcpyret;
+ spcpyret = stpcpy(spcpy, s);
+ setproctitle(spcpyret, 3); // expected-warning {{Uncontrolled Format String}}
+
+ char sncpy[80];
+ strncpy(sncpy, s, 20);
+ setproctitle(sncpy, 3); // expected-warning {{Uncontrolled Format String}}
+
+ char *dup;
+ dup = strndup(s, 20);
+ setproctitle(dup, 3); // expected-warning {{Uncontrolled Format String}}
+
+}
+
+int system(const char *command);
+void testTaintSystemCall() {
+ char buffer[156];
+ char addr[128];
+ scanf("%s", addr);
+ system(addr); // expected-warning {{Untrusted data is passed to a system call}}
+
+ // Test that spintf transfers taint.
+ sprintf(buffer, "/bin/mail %s < /tmp/email", addr);
+ system(buffer); // expected-warning {{Untrusted data is passed to a system call}}
+}
+
+void testTaintSystemCall2() {
+ // Test that snpintf transfers taint.
+ char buffern[156];
+ char addr[128];
+ scanf("%s", addr);
+ __builtin_snprintf(buffern, 10, "/bin/mail %s < /tmp/email", addr);
+ system(buffern); // expected-warning {{Untrusted data is passed to a system call}}
+}
+
+void testTaintSystemCall3() {
+ char buffern2[156];
+ int numt;
+ char addr[128];
+ scanf("%s %d", addr, &numt);
+ __builtin_snprintf(buffern2, numt, "/bin/mail %s < /tmp/email", "abcd");
+ system(buffern2); // expected-warning {{Untrusted data is passed to a system call}}
+}
+
+void testTaintedBufferSize() {
+ size_t ts;
+ scanf("%zd", &ts);
+
+ int *buf1 = (int*)malloc(ts*sizeof(int)); // expected-warning {{Untrusted data is used to specify the buffer size}}
+ char *dst = (char*)calloc(ts, sizeof(char)); //expected-warning {{Untrusted data is used to specify the buffer size}}
+ bcopy(buf1, dst, ts); // expected-warning {{Untrusted data is used to specify the buffer size}}
+ __builtin_memcpy(dst, buf1, (ts + 4)*sizeof(char)); // expected-warning {{Untrusted data is used to specify the buffer size}}
+
+ // If both buffers are trusted, do not issue a warning.
+ char *dst2 = (char*)malloc(ts*sizeof(char)); // expected-warning {{Untrusted data is used to specify the buffer size}}
+ strncat(dst2, dst, ts); // no-warning
+}
+
+#define AF_UNIX 1 /* local to host (pipes) */
+#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
+#define AF_LOCAL AF_UNIX /* backward compatibility */
+#define SOCK_STREAM 1
+int socket(int, int, int);
+size_t read(int, void *, size_t);
+int execl(const char *, const char *, ...);
+
+void testSocket() {
+ int sock;
+ char buffer[100];
+
+ sock = socket(AF_INET, SOCK_STREAM, 0);
+ read(sock, buffer, 100);
+ execl(buffer, "filename", 0); // expected-warning {{Untrusted data is passed to a system call}}
+
+ sock = socket(AF_LOCAL, SOCK_STREAM, 0);
+ read(sock, buffer, 100);
+ execl(buffer, "filename", 0); // no-warning
+}
+
+int testDivByZero() {
+ int x;
+ scanf("%d", &x);
+ return 5/x; // expected-warning {{Division by a tainted value, possibly zero}}
+}
+
+// Zero-sized VLAs.
+void testTaintedVLASize() {
+ int x;
+ scanf("%d", &x);
+ int vla[x]; // expected-warning{{Declared variable-length array (VLA) has tainted size}}
+}
diff --git a/test/Analysis/taint-tester.c b/test/Analysis/taint-tester.c
new file mode 100644
index 000000000000..377333505e18
--- /dev/null
+++ b/test/Analysis/taint-tester.c
@@ -0,0 +1,204 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.security.taint,debug.TaintTest %s -verify
+
+#include <stdarg.h>
+
+int scanf(const char *restrict format, ...);
+int getchar(void);
+typedef __typeof(sizeof(int)) size_t;
+
+#define BUFSIZE 10
+int Buffer[BUFSIZE];
+
+struct XYStruct {
+ int x;
+ int y;
+ char z;
+};
+
+void taintTracking(int x) {
+ int n;
+ int *addr = &Buffer[0];
+ scanf("%d", &n);
+ addr += n;// expected-warning + {{tainted}}
+ *addr = n; // expected-warning + {{tainted}}
+
+ double tdiv = n / 30; // expected-warning+ {{tainted}}
+ char *loc_cast = (char *) n; // expected-warning +{{tainted}}
+ char tinc = tdiv++; // expected-warning + {{tainted}}
+ int tincdec = (char)tinc--; // expected-warning+{{tainted}}
+
+ // Tainted ptr arithmetic/array element address.
+ int tprtarithmetic1 = *(addr+1); // expected-warning + {{tainted}}
+
+ // Dereference.
+ int *ptr;
+ scanf("%p", &ptr);
+ int ptrDeref = *ptr; // expected-warning + {{tainted}}
+ int _ptrDeref = ptrDeref + 13; // expected-warning + {{tainted}}
+
+ // Pointer arithmetic + dereferencing.
+ // FIXME: We fail to propagate the taint here because RegionStore does not
+ // handle ElementRegions with symbolic indexes.
+ int addrDeref = *addr; // expected-warning + {{tainted}}
+ int _addrDeref = addrDeref;
+
+ // Tainted struct address, casts.
+ struct XYStruct *xyPtr = 0;
+ scanf("%p", &xyPtr);
+ void *tXYStructPtr = xyPtr; // expected-warning + {{tainted}}
+ struct XYStruct *xyPtrCopy = tXYStructPtr; // expected-warning + {{tainted}}
+ int ptrtx = xyPtr->x;// expected-warning + {{tainted}}
+ int ptrty = xyPtr->y;// expected-warning + {{tainted}}
+
+ // Taint on fields of a struct.
+ struct XYStruct xy = {2, 3, 11};
+ scanf("%d", &xy.y);
+ scanf("%d", &xy.x);
+ int tx = xy.x; // expected-warning + {{tainted}}
+ int ty = xy.y; // FIXME: This should be tainted as well.
+ char ntz = xy.z;// no warning
+ // Now, scanf scans both.
+ scanf("%d %d", &xy.y, &xy.x);
+ int ttx = xy.x; // expected-warning + {{tainted}}
+ int tty = xy.y; // expected-warning + {{tainted}}
+}
+
+void BitwiseOp(int in, char inn) {
+ // Taint on bitwise operations, integer to integer cast.
+ int m;
+ int x = 0;
+ scanf("%d", &x);
+ int y = (in << (x << in)) * 5;// expected-warning + {{tainted}}
+ // The next line tests integer to integer cast.
+ int z = y & inn; // expected-warning + {{tainted}}
+ if (y == 5) // expected-warning + {{tainted}}
+ m = z | z;// expected-warning + {{tainted}}
+ else
+ m = inn;
+ int mm = m; // expected-warning + {{tainted}}
+}
+
+// Test getenv.
+char *getenv(const char *name);
+void getenvTest(char *home) {
+ home = getenv("HOME"); // expected-warning + {{tainted}}
+ if (home != 0) { // expected-warning + {{tainted}}
+ char d = home[0]; // expected-warning + {{tainted}}
+ }
+}
+
+typedef struct _FILE FILE;
+extern FILE *stdin;
+extern FILE *stdout;
+extern FILE *stderr;
+int fscanf(FILE *restrict stream, const char *restrict format, ...);
+int fprintf(FILE *stream, const char *format, ...);
+int fclose(FILE *stream);
+FILE *fopen(const char *path, const char *mode);
+
+int fscanfTest(void) {
+ FILE *fp;
+ char s[80];
+ int t;
+
+ // Check if stdin is treated as tainted.
+ fscanf(stdin, "%s %d", s, &t);
+ // Note, here, s is not tainted, but the data s points to is tainted.
+ char *ts = s;
+ char tss = s[0]; // expected-warning + {{tainted}}
+ int tt = t; // expected-warning + {{tainted}}
+ if((fp=fopen("test", "w")) == 0) // expected-warning + {{tainted}}
+ return 1;
+ fprintf(fp, "%s %d", s, t); // expected-warning + {{tainted}}
+ fclose(fp); // expected-warning + {{tainted}}
+
+ // Test fscanf and fopen.
+ if((fp=fopen("test","r")) == 0) // expected-warning + {{tainted}}
+ return 1;
+ fscanf(fp, "%s%d", s, &t); // expected-warning + {{tainted}}
+ fprintf(stdout, "%s %d", s, t); // expected-warning + {{tainted}}
+ return 0;
+}
+
+// Check if we propagate taint from stdin when it's used in an assignment.
+void stdinTest1() {
+ int i;
+ fscanf(stdin, "%d", &i);
+ int j = i; // expected-warning + {{tainted}}
+}
+void stdinTest2(FILE *pIn) {
+ FILE *p = stdin;
+ FILE *pp = p;
+ int ii;
+
+ fscanf(pp, "%d", &ii);
+ int jj = ii;// expected-warning + {{tainted}}
+
+ fscanf(p, "%d", &ii);
+ int jj2 = ii;// expected-warning + {{tainted}}
+
+ ii = 3;
+ int jj3 = ii;// no warning
+
+ p = pIn;
+ fscanf(p, "%d", &ii);
+ int jj4 = ii;// no warning
+}
+
+void stdinTest3() {
+ FILE **ppp = &stdin;
+ int iii;
+ fscanf(*ppp, "%d", &iii);
+ int jjj = iii;// expected-warning + {{tainted}}
+}
+
+// Test that stdin does not get invalidated by calls.
+void foo();
+void stdinTest4() {
+ int i;
+ fscanf(stdin, "%d", &i);
+ foo();
+ int j = i; // expected-warning + {{tainted}}
+}
+
+int getw(FILE *);
+void getwTest() {
+ int i = getw(stdin); // expected-warning + {{tainted}}
+}
+
+typedef long ssize_t;
+ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict);
+int printf(const char * __restrict, ...);
+void free(void *ptr);
+void getlineTest(void) {
+ FILE *fp;
+ char *line = 0;
+ size_t len = 0;
+ ssize_t read;
+ while ((read = getline(&line, &len, stdin)) != -1) {
+ printf("%s", line); // expected-warning + {{tainted}}
+ }
+ free(line); // expected-warning + {{tainted}}
+}
+
+// Test propagation functions - the ones that propagate taint from arguments to
+// return value, ptr arguments.
+
+int atoi(const char *nptr);
+long atol(const char *nptr);
+long long atoll(const char *nptr);
+
+void atoiTest() {
+ char s[80];
+ scanf("%s", s);
+ int d = atoi(s); // expected-warning + {{tainted}}
+ int td = d; // expected-warning + {{tainted}}
+
+ long l = atol(s); // expected-warning + {{tainted}}
+ int tl = l; // expected-warning + {{tainted}}
+
+ long long ll = atoll(s); // expected-warning + {{tainted}}
+ int tll = ll; // expected-warning + {{tainted}}
+
+}
+
diff --git a/test/Analysis/taint-tester.cpp b/test/Analysis/taint-tester.cpp
new file mode 100644
index 000000000000..679fbc2bf41a
--- /dev/null
+++ b/test/Analysis/taint-tester.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.security.taint,debug.TaintTest %s -verify
+
+typedef struct _FILE FILE;
+typedef __typeof(sizeof(int)) size_t;
+extern FILE *stdin;
+typedef long ssize_t;
+ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict);
+int printf(const char * __restrict, ...);
+void free(void *ptr);
+
+struct GetLineTestStruct {
+ ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict);
+};
+
+void getlineTest(void) {
+ FILE *fp;
+ char *line = 0;
+ size_t len = 0;
+ ssize_t read;
+ struct GetLineTestStruct T;
+
+ while ((read = T.getline(&line, &len, stdin)) != -1) {
+ printf("%s", line); // no warning
+ }
+ free(line);
+}
diff --git a/test/Analysis/taint-tester.m b/test/Analysis/taint-tester.m
new file mode 100644
index 000000000000..ae55c6618dab
--- /dev/null
+++ b/test/Analysis/taint-tester.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.security.taint,debug.TaintTest %s -verify
+
+#import <stdarg.h>
+
+@interface NSString
+- (NSString *)stringByAppendingString:(NSString *)aString;
+@end
+extern void NSLog (NSString *format, ...);
+extern void NSLogv(NSString *format, va_list args);
+
+void TestLog (NSString *format, ...);
+void TestLog (NSString *format, ...) {
+ va_list ap;
+ va_start(ap, format);
+ NSString *string = @"AAA: ";
+
+ NSLogv([string stringByAppendingString:format], ap);
+
+ va_end(ap);
+} \ No newline at end of file
diff --git a/test/Analysis/temp-obj-dtors-cfg-output.cpp b/test/Analysis/temp-obj-dtors-cfg-output.cpp
index 17864e4c5485..53ab211615c3 100644
--- a/test/Analysis/temp-obj-dtors-cfg-output.cpp
+++ b/test/Analysis/temp-obj-dtors-cfg-output.cpp
@@ -106,661 +106,662 @@ TestCtorInits::TestCtorInits()
: a(int(A()) + int(B()))
, b() {}
-// CHECK: [ B2 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B1
-// CHECK: [ B1 ]
-// CHECK: 1: A()
-// CHECK: 2: [B1.1] (BindTemporary)
-// CHECK: 3: [B1.2].operator int
-// CHECK: 4: [B1.3]()
-// CHECK: 5: [B1.4]
-// CHECK: 6: int([B1.5])
-// CHECK: 7: B()
-// CHECK: 8: [B1.7] (BindTemporary)
-// CHECK: 9: [B1.8].operator int
-// CHECK: 10: [B1.9]()
-// CHECK: 11: [B1.10]
-// CHECK: 12: int([B1.11])
-// CHECK: 13: [B1.6] + [B1.12]
-// CHECK: 14: int a = int(A().operator int()) + int(B().operator int());
-// CHECK: 15: ~B() (Temporary object destructor)
-// CHECK: 16: ~A() (Temporary object destructor)
-// CHECK: 17: A()
-// CHECK: 18: [B1.17] (BindTemporary)
-// CHECK: 19: [B1.18].operator int
-// CHECK: 20: [B1.19]()
-// CHECK: 21: [B1.20]
-// CHECK: 22: int([B1.21])
-// CHECK: 23: B()
-// CHECK: 24: [B1.23] (BindTemporary)
-// CHECK: 25: [B1.24].operator int
-// CHECK: 26: [B1.25]()
-// CHECK: 27: [B1.26]
-// CHECK: 28: int([B1.27])
-// CHECK: 29: [B1.22] + [B1.28]
-// CHECK: 30: foo
-// CHECK: 31: [B1.30]
-// CHECK: 32: [B1.31]([B1.29])
-// CHECK: 33: ~B() (Temporary object destructor)
-// CHECK: 34: ~A() (Temporary object destructor)
-// CHECK: 35: int b;
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (1): B0
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B10 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B8
-// CHECK: [ B1 ]
-// CHECK: 1: ~A() (Temporary object destructor)
-// CHECK: 2: int b;
-// CHECK: Predecessors (2): B2 B3
-// CHECK: Successors (1): B0
-// CHECK: [ B2 ]
-// CHECK: 1: ~B() (Temporary object destructor)
-// CHECK: Predecessors (1): B3
-// CHECK: Successors (1): B1
-// CHECK: [ B3 ]
-// CHECK: 1: [B4.5] && [B5.4]
-// CHECK: 2: foo
-// CHECK: 3: [B3.2]
-// CHECK: 4: [B3.3]([B3.1])
-// CHECK: T: [B4.5] && ...
-// CHECK: Predecessors (2): B5 B4
-// CHECK: Successors (2): B2 B1
-// CHECK: [ B4 ]
-// CHECK: 1: ~A() (Temporary object destructor)
-// CHECK: 2: A()
-// CHECK: 3: [B4.2] (BindTemporary)
-// CHECK: 4: [B4.3].operator _Bool
-// CHECK: 5: [B4.4]()
-// CHECK: T: [B4.5] && ...
-// CHECK: Predecessors (2): B6 B7
-// CHECK: Successors (2): B5 B3
-// CHECK: [ B5 ]
-// CHECK: 1: B()
-// CHECK: 2: [B5.1] (BindTemporary)
-// CHECK: 3: [B5.2].operator _Bool
-// CHECK: 4: [B5.3]()
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B3
-// CHECK: [ B6 ]
-// CHECK: 1: ~B() (Temporary object destructor)
-// CHECK: Predecessors (1): B7
-// CHECK: Successors (1): B4
-// CHECK: [ B7 ]
-// CHECK: 1: [B8.4] && [B9.4]
-// CHECK: 2: bool a = A().operator _Bool() && B().operator _Bool();
-// CHECK: T: [B8.4] && ...
-// CHECK: Predecessors (2): B9 B8
-// CHECK: Successors (2): B6 B4
-// CHECK: [ B8 ]
-// CHECK: 1: A()
-// CHECK: 2: [B8.1] (BindTemporary)
-// CHECK: 3: [B8.2].operator _Bool
-// CHECK: 4: [B8.3]()
-// CHECK: T: [B8.4] && ...
-// CHECK: Predecessors (1): B10
-// CHECK: Successors (2): B9 B7
-// CHECK: [ B9 ]
-// CHECK: 1: B()
-// CHECK: 2: [B9.1] (BindTemporary)
-// CHECK: 3: [B9.2].operator _Bool
-// CHECK: 4: [B9.3]()
-// CHECK: Predecessors (1): B8
-// CHECK: Successors (1): B7
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B10 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B8
-// CHECK: [ B1 ]
-// CHECK: 1: ~A() (Temporary object destructor)
-// CHECK: 2: int b;
-// CHECK: Predecessors (2): B2 B3
-// CHECK: Successors (1): B0
-// CHECK: [ B2 ]
-// CHECK: 1: ~B() (Temporary object destructor)
-// CHECK: Predecessors (1): B3
-// CHECK: Successors (1): B1
-// CHECK: [ B3 ]
-// CHECK: 1: [B4.5] || [B5.4]
-// CHECK: 2: foo
-// CHECK: 3: [B3.2]
-// CHECK: 4: [B3.3]([B3.1])
-// CHECK: T: [B4.5] || ...
-// CHECK: Predecessors (2): B5 B4
-// CHECK: Successors (2): B1 B2
-// CHECK: [ B4 ]
-// CHECK: 1: ~A() (Temporary object destructor)
-// CHECK: 2: A()
-// CHECK: 3: [B4.2] (BindTemporary)
-// CHECK: 4: [B4.3].operator _Bool
-// CHECK: 5: [B4.4]()
-// CHECK: T: [B4.5] || ...
-// CHECK: Predecessors (2): B6 B7
-// CHECK: Successors (2): B3 B5
-// CHECK: [ B5 ]
-// CHECK: 1: B()
-// CHECK: 2: [B5.1] (BindTemporary)
-// CHECK: 3: [B5.2].operator _Bool
-// CHECK: 4: [B5.3]()
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B3
-// CHECK: [ B6 ]
-// CHECK: 1: ~B() (Temporary object destructor)
-// CHECK: Predecessors (1): B7
-// CHECK: Successors (1): B4
-// CHECK: [ B7 ]
-// CHECK: 1: [B8.4] || [B9.4]
-// CHECK: 2: bool a = A().operator _Bool() || B().operator _Bool();
-// CHECK: T: [B8.4] || ...
-// CHECK: Predecessors (2): B9 B8
-// CHECK: Successors (2): B4 B6
-// CHECK: [ B8 ]
-// CHECK: 1: A()
-// CHECK: 2: [B8.1] (BindTemporary)
-// CHECK: 3: [B8.2].operator _Bool
-// CHECK: 4: [B8.3]()
-// CHECK: T: [B8.4] || ...
-// CHECK: Predecessors (1): B10
-// CHECK: Successors (2): B7 B9
-// CHECK: [ B9 ]
-// CHECK: 1: B()
-// CHECK: 2: [B9.1] (BindTemporary)
-// CHECK: 3: [B9.2].operator _Bool
-// CHECK: 4: [B9.3]()
-// CHECK: Predecessors (1): B8
-// CHECK: Successors (1): B7
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B11 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B10
-// CHECK: [ B1 ]
-// CHECK: 1: int b;
-// CHECK: 2: [B7.4].~A() (Implicit destructor)
-// CHECK: Predecessors (2): B2 B3
-// CHECK: Successors (1): B0
-// CHECK: [ B2 ]
-// CHECK: 1: 0
-// CHECK: 2: foo
-// CHECK: 3: [B2.2]
-// CHECK: 4: [B2.3]([B2.1])
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B1
-// CHECK: [ B3 ]
-// CHECK: 1: 0
-// CHECK: 2: foo
-// CHECK: 3: [B3.2]
-// CHECK: 4: [B3.3]([B3.1])
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B1
-// CHECK: [ B4 ]
-// CHECK: 1: ~B() (Temporary object destructor)
-// CHECK: 2: B()
-// CHECK: 3: [B4.2] (BindTemporary)
-// CHECK: 4: [B4.3].operator _Bool
-// CHECK: 5: [B4.4]()
-// CHECK: 6: ~B() (Temporary object destructor)
-// CHECK: T: if [B4.5]
-// CHECK: Predecessors (2): B5 B6
-// CHECK: Successors (2): B3 B2
-// CHECK: [ B5 ]
-// CHECK: 1: ~A() (Temporary object destructor)
-// CHECK: 2: ~A() (Temporary object destructor)
-// CHECK: Predecessors (1): B7
-// CHECK: Successors (1): B4
-// CHECK: [ B6 ]
-// CHECK: 1: ~A() (Temporary object destructor)
-// CHECK: 2: ~A() (Temporary object destructor)
-// CHECK: 3: ~A() (Temporary object destructor)
-// CHECK: 4: ~B() (Temporary object destructor)
-// CHECK: Predecessors (1): B7
-// CHECK: Successors (1): B4
-// CHECK: [ B7 ]
-// CHECK: 1: [B10.4] ? [B8.5] : [B9.13]
-// CHECK: 2: [B7.1]
-// CHECK: 3: [B7.2]
-// CHECK: 4: A a = B().operator _Bool() ? A() : A(B().operator A());
-// CHECK: T: [B10.4] ? ... : ...
-// CHECK: Predecessors (2): B8 B9
-// CHECK: Successors (2): B5 B6
-// CHECK: [ B8 ]
-// CHECK: 1: A()
-// CHECK: 2: [B8.1] (BindTemporary)
-// CHECK: 3: [B8.2]
-// CHECK: 4: [B8.3]
-// CHECK: 5: [B8.4] (BindTemporary)
-// CHECK: Predecessors (1): B10
-// CHECK: Successors (1): B7
-// CHECK: [ B9 ]
-// CHECK: 1: B()
-// CHECK: 2: [B9.1] (BindTemporary)
-// CHECK: 3: [B9.2].operator A
-// CHECK: 4: [B9.3]()
-// CHECK: 5: [B9.4] (BindTemporary)
-// CHECK: 6: [B9.5]
-// CHECK: 7: [B9.6]
-// CHECK: 8: [B9.7]
-// CHECK: 9: [B9.8] (BindTemporary)
-// CHECK: 10: A([B9.9])
-// CHECK: 11: [B9.10]
-// CHECK: 12: [B9.11]
-// CHECK: 13: [B9.12] (BindTemporary)
-// CHECK: Predecessors (1): B10
-// CHECK: Successors (1): B7
-// CHECK: [ B10 ]
-// CHECK: 1: B()
-// CHECK: 2: [B10.1] (BindTemporary)
-// CHECK: 3: [B10.2].operator _Bool
-// CHECK: 4: [B10.3]()
-// CHECK: T: [B10.4] ? ... : ...
-// CHECK: Predecessors (1): B11
-// CHECK: Successors (2): B8 B9
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B14 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B13
-// CHECK: [ B1 ]
-// CHECK: 1: ~B() (Temporary object destructor)
-// CHECK: 2: int b;
-// CHECK: 3: [B10.4].~A() (Implicit destructor)
-// CHECK: Predecessors (2): B2 B3
-// CHECK: Successors (1): B0
-// CHECK: [ B2 ]
-// CHECK: 1: ~A() (Temporary object destructor)
-// CHECK: 2: ~A() (Temporary object destructor)
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B1
-// CHECK: [ B3 ]
-// CHECK: 1: ~A() (Temporary object destructor)
-// CHECK: 2: ~A() (Temporary object destructor)
-// CHECK: 3: ~A() (Temporary object destructor)
-// CHECK: 4: ~B() (Temporary object destructor)
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B1
-// CHECK: [ B4 ]
-// CHECK: 1: [B7.5] ? [B5.5] : [B6.13]
-// CHECK: 2: [B4.1]
-// CHECK: 3: [B4.2]
-// CHECK: 4: foo
-// CHECK: 5: [B4.4]
-// CHECK: 6: [B4.5]([B4.3])
-// CHECK: T: [B7.5] ? ... : ...
-// CHECK: Predecessors (2): B5 B6
-// CHECK: Successors (2): B2 B3
-// CHECK: [ B5 ]
-// CHECK: 1: A()
-// CHECK: 2: [B5.1] (BindTemporary)
-// CHECK: 3: [B5.2]
-// CHECK: 4: [B5.3]
-// CHECK: 5: [B5.4] (BindTemporary)
-// CHECK: Predecessors (1): B7
-// CHECK: Successors (1): B4
-// CHECK: [ B6 ]
-// CHECK: 1: B()
-// CHECK: 2: [B6.1] (BindTemporary)
-// CHECK: 3: [B6.2].operator A
-// CHECK: 4: [B6.3]()
-// CHECK: 5: [B6.4] (BindTemporary)
-// CHECK: 6: [B6.5]
-// CHECK: 7: [B6.6]
-// CHECK: 8: [B6.7]
-// CHECK: 9: [B6.8] (BindTemporary)
-// CHECK: 10: A([B6.9])
-// CHECK: 11: [B6.10]
-// CHECK: 12: [B6.11]
-// CHECK: 13: [B6.12] (BindTemporary)
-// CHECK: Predecessors (1): B7
-// CHECK: Successors (1): B4
-// CHECK: [ B7 ]
-// CHECK: 1: ~B() (Temporary object destructor)
-// CHECK: 2: B()
-// CHECK: 3: [B7.2] (BindTemporary)
-// CHECK: 4: [B7.3].operator _Bool
-// CHECK: 5: [B7.4]()
-// CHECK: T: [B7.5] ? ... : ...
-// CHECK: Predecessors (2): B8 B9
-// CHECK: Successors (2): B5 B6
-// CHECK: [ B8 ]
-// CHECK: 1: ~A() (Temporary object destructor)
-// CHECK: Predecessors (1): B10
-// CHECK: Successors (1): B7
-// CHECK: [ B9 ]
-// CHECK: 1: ~A() (Temporary object destructor)
-// CHECK: 2: ~A() (Temporary object destructor)
-// CHECK: 3: ~B() (Temporary object destructor)
-// CHECK: Predecessors (1): B10
-// CHECK: Successors (1): B7
-// CHECK: [ B10 ]
-// CHECK: 1: [B13.4] ? [B11.5] : [B12.13]
-// CHECK: 2: [B10.1]
-// CHECK: 3: [B10.2]
-// CHECK: 4: const A &a = B().operator _Bool() ? A() : A(B().operator A());
-// CHECK: T: [B13.4] ? ... : ...
-// CHECK: Predecessors (2): B11 B12
-// CHECK: Successors (2): B8 B9
-// CHECK: [ B11 ]
-// CHECK: 1: A()
-// CHECK: 2: [B11.1] (BindTemporary)
-// CHECK: 3: [B11.2]
-// CHECK: 4: [B11.3]
-// CHECK: 5: [B11.4] (BindTemporary)
-// CHECK: Predecessors (1): B13
-// CHECK: Successors (1): B10
-// CHECK: [ B12 ]
-// CHECK: 1: B()
-// CHECK: 2: [B12.1] (BindTemporary)
-// CHECK: 3: [B12.2].operator A
-// CHECK: 4: [B12.3]()
-// CHECK: 5: [B12.4] (BindTemporary)
-// CHECK: 6: [B12.5]
-// CHECK: 7: [B12.6]
-// CHECK: 8: [B12.7]
-// CHECK: 9: [B12.8] (BindTemporary)
-// CHECK: 10: A([B12.9])
-// CHECK: 11: [B12.10]
-// CHECK: 12: [B12.11]
-// CHECK: 13: [B12.12] (BindTemporary)
-// CHECK: Predecessors (1): B13
-// CHECK: Successors (1): B10
-// CHECK: [ B13 ]
-// CHECK: 1: B()
-// CHECK: 2: [B13.1] (BindTemporary)
-// CHECK: 3: [B13.2].operator _Bool
-// CHECK: 4: [B13.3]()
-// CHECK: T: [B13.4] ? ... : ...
-// CHECK: Predecessors (1): B14
-// CHECK: Successors (2): B11 B12
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B8 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B7
-// CHECK: [ B1 ]
-// CHECK: 1: ~A() (Temporary object destructor)
-// CHECK: 2: int b;
-// CHECK: 3: [B4.4].~A() (Implicit destructor)
-// CHECK: Predecessors (2): B2 B3
-// CHECK: Successors (1): B0
-// CHECK: [ B2 ]
-// CHECK: 1: ~A() (Temporary object destructor)
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B1
-// CHECK: [ B3 ]
-// CHECK: 1: ~A() (Temporary object destructor)
-// CHECK: 2: ~A() (Temporary object destructor)
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B1
-// CHECK: [ B4 ]
-// CHECK: 1: [B7.2] ?: [B6.5]
-// CHECK: 2: [B4.1]
-// CHECK: 3: [B4.2]
-// CHECK: 4: A a = A() ?: A();
-// CHECK: T: [B7.5] ? ... : ...
-// CHECK: Predecessors (2): B5 B6
-// CHECK: Successors (2): B2 B3
-// CHECK: [ B5 ]
-// CHECK: 1: [B7.3]
-// CHECK: 2: [B7.3]
-// CHECK: 3: [B5.2]
-// CHECK: 4: [B5.3]
-// CHECK: 5: [B5.4] (BindTemporary)
-// CHECK: Predecessors (1): B7
-// CHECK: Successors (1): B4
-// CHECK: [ B6 ]
-// CHECK: 1: A()
-// CHECK: 2: [B6.1] (BindTemporary)
-// CHECK: 3: [B6.2]
-// CHECK: 4: [B6.3]
-// CHECK: 5: [B6.4] (BindTemporary)
-// CHECK: Predecessors (1): B7
-// CHECK: Successors (1): B4
-// CHECK: [ B7 ]
-// CHECK: 1: A()
-// CHECK: 2: [B7.1] (BindTemporary)
-// CHECK: 3:
-// CHECK: 4: [B7.3].operator _Bool
-// CHECK: 5: [B7.4]()
-// CHECK: T: [B7.5] ? ... : ...
-// CHECK: Predecessors (1): B8
-// CHECK: Successors (2): B5 B6
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B13 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B12
-// CHECK: [ B1 ]
-// CHECK: 1: ~A() (Temporary object destructor)
-// CHECK: 2: int b;
-// CHECK: 3: [B9.4].~A() (Implicit destructor)
-// CHECK: Predecessors (2): B2 B3
-// CHECK: Successors (1): B0
-// CHECK: [ B2 ]
-// CHECK: 1: ~A() (Temporary object destructor)
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B1
-// CHECK: [ B3 ]
-// CHECK: 1: ~A() (Temporary object destructor)
-// CHECK: 2: ~A() (Temporary object destructor)
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B1
-// CHECK: [ B4 ]
-// CHECK: 1: [B7.3] ?: [B6.5]
-// CHECK: 2: [B4.1]
-// CHECK: 3: [B4.2]
-// CHECK: 4: foo
-// CHECK: 5: [B4.4]
-// CHECK: 6: [B4.5]([B4.3])
-// CHECK: T: [B7.6] ? ... : ...
-// CHECK: Predecessors (2): B5 B6
-// CHECK: Successors (2): B2 B3
-// CHECK: [ B5 ]
-// CHECK: 1: [B7.4]
-// CHECK: 2: [B7.4]
-// CHECK: 3: [B5.2]
-// CHECK: 4: [B5.3]
-// CHECK: 5: [B5.4] (BindTemporary)
-// CHECK: Predecessors (1): B7
-// CHECK: Successors (1): B4
-// CHECK: [ B6 ]
-// CHECK: 1: A()
-// CHECK: 2: [B6.1] (BindTemporary)
-// CHECK: 3: [B6.2]
-// CHECK: 4: [B6.3]
-// CHECK: 5: [B6.4] (BindTemporary)
-// CHECK: Predecessors (1): B7
-// CHECK: Successors (1): B4
-// CHECK: [ B7 ]
-// CHECK: 1: ~A() (Temporary object destructor)
-// CHECK: 2: A()
-// CHECK: 3: [B7.2] (BindTemporary)
-// CHECK: 4:
-// CHECK: 5: [B7.4].operator _Bool
-// CHECK: 6: [B7.5]()
-// CHECK: T: [B7.6] ? ... : ...
-// CHECK: Predecessors (2): B9 B8
-// CHECK: Successors (2): B5 B6
-// CHECK: [ B8 ]
-// CHECK: 1: ~A() (Temporary object destructor)
-// CHECK: Predecessors (1): B9
-// CHECK: Successors (1): B7
-// CHECK: [ B9 ]
-// CHECK: 1: [B12.2] ?: [B11.5]
-// CHECK: 2: [B9.1]
-// CHECK: 3: [B9.2]
-// CHECK: 4: const A &a = A() ?: A();
-// CHECK: T: [B12.5] ? ... : ...
-// CHECK: Predecessors (2): B10 B11
-// CHECK: Successors (2): B7 B8
-// CHECK: [ B10 ]
-// CHECK: 1: [B12.3]
-// CHECK: 2: [B12.3]
-// CHECK: 3: [B10.2]
-// CHECK: 4: [B10.3]
-// CHECK: 5: [B10.4] (BindTemporary)
-// CHECK: Predecessors (1): B12
-// CHECK: Successors (1): B9
-// CHECK: [ B11 ]
-// CHECK: 1: A()
-// CHECK: 2: [B11.1] (BindTemporary)
-// CHECK: 3: [B11.2]
-// CHECK: 4: [B11.3]
-// CHECK: 5: [B11.4] (BindTemporary)
-// CHECK: Predecessors (1): B12
-// CHECK: Successors (1): B9
-// CHECK: [ B12 ]
-// CHECK: 1: A()
-// CHECK: 2: [B12.1] (BindTemporary)
-// CHECK: 3:
-// CHECK: 4: [B12.3].operator _Bool
-// CHECK: 5: [B12.4]()
-// CHECK: T: [B12.5] ? ... : ...
-// CHECK: Predecessors (1): B13
-// CHECK: Successors (2): B10 B11
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B2 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B1
-// CHECK: [ B1 ]
-// CHECK: 1: A()
-// CHECK: 2: [B1.1] (BindTemporary)
-// CHECK: 3: [B1.2]
-// CHECK: 4: [B1.3]
-// CHECK: 5: A a = A();
-// CHECK: 6: ~A() (Temporary object destructor)
-// CHECK: 7: int b;
-// CHECK: 8: [B1.5].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (1): B0
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B2 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B1
-// CHECK: [ B1 ]
-// CHECK: 1: A()
-// CHECK: 2: [B1.1] (BindTemporary)
-// CHECK: 3: [B1.2]
-// CHECK: 4: [B1.3]
-// CHECK: 5: const A &a = A();
-// CHECK: 6: A()
-// CHECK: 7: [B1.6] (BindTemporary)
-// CHECK: 8: [B1.7]
-// CHECK: 9: [B1.8]
-// CHECK: 10: foo
-// CHECK: 11: [B1.10]
-// CHECK: 12: [B1.11]([B1.9])
-// CHECK: 13: ~A() (Temporary object destructor)
-// CHECK: 14: int b;
-// CHECK: 15: [B1.5].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (1): B0
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B2 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B1
-// CHECK: [ B1 ]
-// CHECK: 1: A::make
-// CHECK: 2: [B1.1]
-// CHECK: 3: [B1.2]()
-// CHECK: 4: [B1.3] (BindTemporary)
-// CHECK: 5: [B1.4]
-// CHECK: 6: [B1.5]
-// CHECK: 7: A a = A::make();
-// CHECK: 8: ~A() (Temporary object destructor)
-// CHECK: 9: int b;
-// CHECK: 10: [B1.7].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (1): B0
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B2 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B1
-// CHECK: [ B1 ]
-// CHECK: 1: A::make
-// CHECK: 2: [B1.1]
-// CHECK: 3: [B1.2]()
-// CHECK: 4: [B1.3] (BindTemporary)
-// CHECK: 5: [B1.4]
-// CHECK: 6: [B1.5]
-// CHECK: 7: const A &a = A::make();
-// CHECK: 8: A::make
-// CHECK: 9: [B1.8]
-// CHECK: 10: [B1.9]()
-// CHECK: 11: [B1.10] (BindTemporary)
-// CHECK: 12: [B1.11]
-// CHECK: 13: [B1.12]
-// CHECK: 14: foo
-// CHECK: 15: [B1.14]
-// CHECK: 16: [B1.15]([B1.13])
-// CHECK: 17: ~A() (Temporary object destructor)
-// CHECK: 18: int b;
-// CHECK: 19: [B1.7].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (1): B0
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B2 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B1
-// CHECK: [ B1 ]
-// CHECK: 1: int a;
-// CHECK: 2: A()
-// CHECK: 3: [B1.2] (BindTemporary)
-// CHECK: 4: [B1.3].operator int
-// CHECK: 5: [B1.4]()
-// CHECK: 6: a
-// CHECK: 7: [B1.6] = [B1.5]
-// CHECK: 8: ~A() (Temporary object destructor)
-// CHECK: 9: int b;
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (1): B0
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-// CHECK: [ B2 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B1
-// CHECK: [ B1 ]
-// CHECK: 1: A()
-// CHECK: 2: [B1.1] (BindTemporary)
-// CHECK: 3: [B1.2].operator int
-// CHECK: 4: [B1.3]()
-// CHECK: 5: [B1.4]
-// CHECK: 6: int([B1.5])
-// CHECK: 7: B()
-// CHECK: 8: [B1.7] (BindTemporary)
-// CHECK: 9: [B1.8].operator int
-// CHECK: 10: [B1.9]()
-// CHECK: 11: [B1.10]
-// CHECK: 12: int([B1.11])
-// CHECK: 13: [B1.6] + [B1.12]
-// CHECK: 14: a([B1.13]) (Member initializer)
-// CHECK: 15: ~B() (Temporary object destructor)
-// CHECK: 16: ~A() (Temporary object destructor)
-// CHECK: 17: /*implicit*/int()
-// CHECK: 18: b([B1.17]) (Member initializer)
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (1): B0
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+
+// CHECK: [B1]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B1.1] (BindTemporary)
+// CHECK: 3: [B1.2].operator int
+// CHECK: 4: [B1.3]()
+// CHECK: 5: [B1.4] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 6: int([B1.5]) (CXXFunctionalCastExpr, NoOp, int)
+// CHECK: 7: B() (CXXConstructExpr, class B)
+// CHECK: 8: [B1.7] (BindTemporary)
+// CHECK: 9: [B1.8].operator int
+// CHECK: 10: [B1.9]()
+// CHECK: 11: [B1.10] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 12: int([B1.11]) (CXXFunctionalCastExpr, NoOp, int)
+// CHECK: 13: [B1.6] + [B1.12]
+// CHECK: 14: int a = int(A().operator int()) + int(B().operator int());
+// CHECK: 15: ~B() (Temporary object destructor)
+// CHECK: 16: ~A() (Temporary object destructor)
+// CHECK: 17: A() (CXXConstructExpr, class A)
+// CHECK: 18: [B1.17] (BindTemporary)
+// CHECK: 19: [B1.18].operator int
+// CHECK: 20: [B1.19]()
+// CHECK: 21: [B1.20] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 22: int([B1.21]) (CXXFunctionalCastExpr, NoOp, int)
+// CHECK: 23: B() (CXXConstructExpr, class B)
+// CHECK: 24: [B1.23] (BindTemporary)
+// CHECK: 25: [B1.24].operator int
+// CHECK: 26: [B1.25]()
+// CHECK: 27: [B1.26] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 28: int([B1.27]) (CXXFunctionalCastExpr, NoOp, int)
+// CHECK: 29: [B1.22] + [B1.28]
+// CHECK: 30: foo
+// CHECK: 31: [B1.30] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(int))
+// CHECK: 32: [B1.31]([B1.29])
+// CHECK: 33: ~B() (Temporary object destructor)
+// CHECK: 34: ~A() (Temporary object destructor)
+// CHECK: 35: int b;
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B10 (ENTRY)]
+// CHECK: Succs (1): B8
+// CHECK: [B1]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: int b;
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: ~B() (Temporary object destructor)
+// CHECK: Preds (1): B3
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: [B4.6] && [B5.5]
+// CHECK: 2: foo
+// CHECK: 3: [B3.2] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(_Bool))
+// CHECK: 4: [B3.3]([B3.1])
+// CHECK: T: [B4.6] && ...
+// CHECK: Preds (2): B5 B4
+// CHECK: Succs (2): B2 B1
+// CHECK: [B4]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: A() (CXXConstructExpr, class A)
+// CHECK: 3: [B4.2] (BindTemporary)
+// CHECK: 4: [B4.3].operator _Bool
+// CHECK: 5: [B4.4]()
+// CHECK: 6: [B4.5] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B4.6] && ...
+// CHECK: Preds (2): B6 B7
+// CHECK: Succs (2): B5 B3
+// CHECK: [B5]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B5.1] (BindTemporary)
+// CHECK: 3: [B5.2].operator _Bool
+// CHECK: 4: [B5.3]()
+// CHECK: 5: [B5.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B3
+// CHECK: [B6]
+// CHECK: 1: ~B() (Temporary object destructor)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B7]
+// CHECK: 1: [B8.5] && [B9.5]
+// CHECK: 2: bool a = A().operator _Bool() && B().operator _Bool();
+// CHECK: T: [B8.5] && ...
+// CHECK: Preds (2): B9 B8
+// CHECK: Succs (2): B6 B4
+// CHECK: [B8]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B8.1] (BindTemporary)
+// CHECK: 3: [B8.2].operator _Bool
+// CHECK: 4: [B8.3]()
+// CHECK: 5: [B8.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B8.5] && ...
+// CHECK: Preds (1): B10
+// CHECK: Succs (2): B9 B7
+// CHECK: [B9]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B9.1] (BindTemporary)
+// CHECK: 3: [B9.2].operator _Bool
+// CHECK: 4: [B9.3]()
+// CHECK: 5: [B9.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: Preds (1): B8
+// CHECK: Succs (1): B7
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B10 (ENTRY)]
+// CHECK: Succs (1): B8
+// CHECK: [B1]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: int b;
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: ~B() (Temporary object destructor)
+// CHECK: Preds (1): B3
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: [B4.6] || [B5.5]
+// CHECK: 2: foo
+// CHECK: 3: [B3.2] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(_Bool))
+// CHECK: 4: [B3.3]([B3.1])
+// CHECK: T: [B4.6] || ...
+// CHECK: Preds (2): B5 B4
+// CHECK: Succs (2): B1 B2
+// CHECK: [B4]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: A() (CXXConstructExpr, class A)
+// CHECK: 3: [B4.2] (BindTemporary)
+// CHECK: 4: [B4.3].operator _Bool
+// CHECK: 5: [B4.4]()
+// CHECK: 6: [B4.5] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B4.6] || ...
+// CHECK: Preds (2): B6 B7
+// CHECK: Succs (2): B3 B5
+// CHECK: [B5]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B5.1] (BindTemporary)
+// CHECK: 3: [B5.2].operator _Bool
+// CHECK: 4: [B5.3]()
+// CHECK: 5: [B5.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B3
+// CHECK: [B6]
+// CHECK: 1: ~B() (Temporary object destructor)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B7]
+// CHECK: 1: [B8.5] || [B9.5]
+// CHECK: 2: bool a = A().operator _Bool() || B().operator _Bool();
+// CHECK: T: [B8.5] || ...
+// CHECK: Preds (2): B9 B8
+// CHECK: Succs (2): B4 B6
+// CHECK: [B8]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B8.1] (BindTemporary)
+// CHECK: 3: [B8.2].operator _Bool
+// CHECK: 4: [B8.3]()
+// CHECK: 5: [B8.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B8.5] || ...
+// CHECK: Preds (1): B10
+// CHECK: Succs (2): B7 B9
+// CHECK: [B9]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B9.1] (BindTemporary)
+// CHECK: 3: [B9.2].operator _Bool
+// CHECK: 4: [B9.3]()
+// CHECK: 5: [B9.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: Preds (1): B8
+// CHECK: Succs (1): B7
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B11 (ENTRY)]
+// CHECK: Succs (1): B10
+// CHECK: [B1]
+// CHECK: 1: int b;
+// CHECK: 2: [B7.5].~A() (Implicit destructor)
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: 0
+// CHECK: 2: foo
+// CHECK: 3: [B2.2] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(int))
+// CHECK: 4: [B2.3]([B2.1])
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: 0
+// CHECK: 2: foo
+// CHECK: 3: [B3.2] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(int))
+// CHECK: 4: [B3.3]([B3.1])
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: ~B() (Temporary object destructor)
+// CHECK: 2: B() (CXXConstructExpr, class B)
+// CHECK: 3: [B4.2] (BindTemporary)
+// CHECK: 4: [B4.3].operator _Bool
+// CHECK: 5: [B4.4]()
+// CHECK: 6: [B4.5] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: 7: ~B() (Temporary object destructor)
+// CHECK: T: if [B4.6]
+// CHECK: Preds (2): B5 B6
+// CHECK: Succs (2): B3 B2
+// CHECK: [B5]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B6]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: ~A() (Temporary object destructor)
+// CHECK: 3: ~A() (Temporary object destructor)
+// CHECK: 4: ~B() (Temporary object destructor)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B7]
+// CHECK: 1: [B10.5] ? [B8.6] : [B9.15]
+// CHECK: 2: [B7.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B7.2]
+// CHECK: 4: [B7.3] (CXXConstructExpr, class A)
+// CHECK: 5: A a = B().operator _Bool() ? A() : A(B().operator A());
+// CHECK: T: [B10.5] ? ... : ...
+// CHECK: Preds (2): B8 B9
+// CHECK: Succs (2): B5 B6
+// CHECK: [B8]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B8.1] (BindTemporary)
+// CHECK: 3: [B8.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B8.3]
+// CHECK: 5: [B8.4] (CXXConstructExpr, class A)
+// CHECK: 6: [B8.5] (BindTemporary)
+// CHECK: Preds (1): B10
+// CHECK: Succs (1): B7
+// CHECK: [B9]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B9.1] (BindTemporary)
+// CHECK: 3: [B9.2].operator A
+// CHECK: 4: [B9.3]()
+// CHECK: 5: [B9.4] (ImplicitCastExpr, UserDefinedConversion, class A)
+// CHECK: 6: [B9.5] (BindTemporary)
+// CHECK: 7: [B9.6] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 8: [B9.7]
+// CHECK: 9: [B9.8] (CXXConstructExpr, class A)
+// CHECK: 10: [B9.9] (BindTemporary)
+// CHECK: 11: A([B9.10]) (CXXFunctionalCastExpr, ConstructorConversion, class A)
+// CHECK: 12: [B9.11] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 13: [B9.12]
+// CHECK: 14: [B9.13] (CXXConstructExpr, class A)
+// CHECK: 15: [B9.14] (BindTemporary)
+// CHECK: Preds (1): B10
+// CHECK: Succs (1): B7
+// CHECK: [B10]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B10.1] (BindTemporary)
+// CHECK: 3: [B10.2].operator _Bool
+// CHECK: 4: [B10.3]()
+// CHECK: 5: [B10.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B10.5] ? ... : ...
+// CHECK: Preds (1): B11
+// CHECK: Succs (2): B8 B9
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B14 (ENTRY)]
+// CHECK: Succs (1): B13
+// CHECK: [B1]
+// CHECK: 1: ~B() (Temporary object destructor)
+// CHECK: 2: int b;
+// CHECK: 3: [B10.4].~A() (Implicit destructor)
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: ~A() (Temporary object destructor)
+// CHECK: 3: ~A() (Temporary object destructor)
+// CHECK: 4: ~B() (Temporary object destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: [B7.6] ? [B5.6] : [B6.15]
+// CHECK: 2: [B4.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B4.2]
+// CHECK: 4: foo
+// CHECK: 5: [B4.4] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(const class A &))
+// CHECK: 6: [B4.5]([B4.3])
+// CHECK: T: [B7.6] ? ... : ...
+// CHECK: Preds (2): B5 B6
+// CHECK: Succs (2): B2 B3
+// CHECK: [B5]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B5.1] (BindTemporary)
+// CHECK: 3: [B5.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B5.3]
+// CHECK: 5: [B5.4] (CXXConstructExpr, class A)
+// CHECK: 6: [B5.5] (BindTemporary)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B6]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B6.1] (BindTemporary)
+// CHECK: 3: [B6.2].operator A
+// CHECK: 4: [B6.3]()
+// CHECK: 5: [B6.4] (ImplicitCastExpr, UserDefinedConversion, class A)
+// CHECK: 6: [B6.5] (BindTemporary)
+// CHECK: 7: [B6.6] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 8: [B6.7]
+// CHECK: 9: [B6.8] (CXXConstructExpr, class A)
+// CHECK: 10: [B6.9] (BindTemporary)
+// CHECK: 11: A([B6.10]) (CXXFunctionalCastExpr, ConstructorConversion, class A)
+// CHECK: 12: [B6.11] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 13: [B6.12]
+// CHECK: 14: [B6.13] (CXXConstructExpr, class A)
+// CHECK: 15: [B6.14] (BindTemporary)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B7]
+// CHECK: 1: ~B() (Temporary object destructor)
+// CHECK: 2: B() (CXXConstructExpr, class B)
+// CHECK: 3: [B7.2] (BindTemporary)
+// CHECK: 4: [B7.3].operator _Bool
+// CHECK: 5: [B7.4]()
+// CHECK: 6: [B7.5] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B7.6] ? ... : ...
+// CHECK: Preds (2): B8 B9
+// CHECK: Succs (2): B5 B6
+// CHECK: [B8]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B10
+// CHECK: Succs (1): B7
+// CHECK: [B9]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: ~A() (Temporary object destructor)
+// CHECK: 3: ~B() (Temporary object destructor)
+// CHECK: Preds (1): B10
+// CHECK: Succs (1): B7
+// CHECK: [B10]
+// CHECK: 1: [B13.5] ? [B11.6] : [B12.15]
+// CHECK: 2: [B10.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B10.2]
+// CHECK: 4: const A &a = B().operator _Bool() ? A() : A(B().operator A());
+// CHECK: T: [B13.5] ? ... : ...
+// CHECK: Preds (2): B11 B12
+// CHECK: Succs (2): B8 B9
+// CHECK: [B11]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B11.1] (BindTemporary)
+// CHECK: 3: [B11.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B11.3]
+// CHECK: 5: [B11.4] (CXXConstructExpr, class A)
+// CHECK: 6: [B11.5] (BindTemporary)
+// CHECK: Preds (1): B13
+// CHECK: Succs (1): B10
+// CHECK: [B12]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B12.1] (BindTemporary)
+// CHECK: 3: [B12.2].operator A
+// CHECK: 4: [B12.3]()
+// CHECK: 5: [B12.4] (ImplicitCastExpr, UserDefinedConversion, class A)
+// CHECK: 6: [B12.5] (BindTemporary)
+// CHECK: 7: [B12.6] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 8: [B12.7]
+// CHECK: 9: [B12.8] (CXXConstructExpr, class A)
+// CHECK: 10: [B12.9] (BindTemporary)
+// CHECK: 11: A([B12.10]) (CXXFunctionalCastExpr, ConstructorConversion, class A)
+// CHECK: 12: [B12.11] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 13: [B12.12]
+// CHECK: 14: [B12.13] (CXXConstructExpr, class A)
+// CHECK: 15: [B12.14] (BindTemporary)
+// CHECK: Preds (1): B13
+// CHECK: Succs (1): B10
+// CHECK: [B13]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B13.1] (BindTemporary)
+// CHECK: 3: [B13.2].operator _Bool
+// CHECK: 4: [B13.3]()
+// CHECK: 5: [B13.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B13.5] ? ... : ...
+// CHECK: Preds (1): B14
+// CHECK: Succs (2): B11 B12
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B8 (ENTRY)]
+// CHECK: Succs (1): B7
+// CHECK: [B1]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: int b;
+// CHECK: 3: [B4.5].~A() (Implicit destructor)
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: [B7.2] ?: [B6.6]
+// CHECK: 2: [B4.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B4.2]
+// CHECK: 4: [B4.3] (CXXConstructExpr, class A)
+// CHECK: 5: A a = A() ?: A();
+// CHECK: T: [B7.5] ? ... : ...
+// CHECK: Preds (2): B5 B6
+// CHECK: Succs (2): B2 B3
+// CHECK: [B5]
+// CHECK: 1: [B7.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 2: [B5.1]
+// CHECK: 3: [B5.2] (CXXConstructExpr, class A)
+// CHECK: 4: [B5.3] (BindTemporary)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B6]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B6.1] (BindTemporary)
+// CHECK: 3: [B6.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B6.3]
+// CHECK: 5: [B6.4] (CXXConstructExpr, class A)
+// CHECK: 6: [B6.5] (BindTemporary)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B7]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B7.1] (BindTemporary)
+// CHECK: 3: [B7.2].operator _Bool
+// CHECK: 4: [B7.3]()
+// CHECK: 5: [B7.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B7.5] ? ... : ...
+// CHECK: Preds (1): B8
+// CHECK: Succs (2): B5 B6
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B13 (ENTRY)]
+// CHECK: Succs (1): B12
+// CHECK: [B1]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: int b;
+// CHECK: 3: [B9.4].~A() (Implicit destructor)
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: [B7.3] ?: [B6.6]
+// CHECK: 2: [B4.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B4.2]
+// CHECK: 4: foo
+// CHECK: 5: [B4.4] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(const class A &))
+// CHECK: 6: [B4.5]([B4.3])
+// CHECK: T: [B7.6] ? ... : ...
+// CHECK: Preds (2): B5 B6
+// CHECK: Succs (2): B2 B3
+// CHECK: [B5]
+// CHECK: 1: [B7.3] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 2: [B5.1]
+// CHECK: 3: [B5.2] (CXXConstructExpr, class A)
+// CHECK: 4: [B5.3] (BindTemporary)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B6]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B6.1] (BindTemporary)
+// CHECK: 3: [B6.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B6.3]
+// CHECK: 5: [B6.4] (CXXConstructExpr, class A)
+// CHECK: 6: [B6.5] (BindTemporary)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B7]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: A() (CXXConstructExpr, class A)
+// CHECK: 3: [B7.2] (BindTemporary)
+// CHECK: 4: [B7.3].operator _Bool
+// CHECK: 5: [B7.4]()
+// CHECK: 6: [B7.5] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B7.6] ? ... : ...
+// CHECK: Preds (2): B9 B8
+// CHECK: Succs (2): B5 B6
+// CHECK: [B8]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B9
+// CHECK: Succs (1): B7
+// CHECK: [B9]
+// CHECK: 1: [B12.2] ?: [B11.6]
+// CHECK: 2: [B9.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B9.2]
+// CHECK: 4: const A &a = A() ?: A();
+// CHECK: T: [B12.5] ? ... : ...
+// CHECK: Preds (2): B10 B11
+// CHECK: Succs (2): B7 B8
+// CHECK: [B10]
+// CHECK: 1: [B12.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 2: [B10.1]
+// CHECK: 3: [B10.2] (CXXConstructExpr, class A)
+// CHECK: 4: [B10.3] (BindTemporary)
+// CHECK: Preds (1): B12
+// CHECK: Succs (1): B9
+// CHECK: [B11]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B11.1] (BindTemporary)
+// CHECK: 3: [B11.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B11.3]
+// CHECK: 5: [B11.4] (CXXConstructExpr, class A)
+// CHECK: 6: [B11.5] (BindTemporary)
+// CHECK: Preds (1): B12
+// CHECK: Succs (1): B9
+// CHECK: [B12]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B12.1] (BindTemporary)
+// CHECK: 3: [B12.2].operator _Bool
+// CHECK: 4: [B12.3]()
+// CHECK: 5: [B12.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B12.5] ? ... : ...
+// CHECK: Preds (1): B13
+// CHECK: Succs (2): B10 B11
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B1.1] (BindTemporary)
+// CHECK: 3: [B1.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B1.3]
+// CHECK: 5: [B1.4] (CXXConstructExpr, class A)
+// CHECK: 6: A a = A();
+// CHECK: 7: ~A() (Temporary object destructor)
+// CHECK: 8: int b;
+// CHECK: 9: [B1.6].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B1.1] (BindTemporary)
+// CHECK: 3: [B1.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B1.3]
+// CHECK: 5: const A &a = A();
+// CHECK: 6: A() (CXXConstructExpr, class A)
+// CHECK: 7: [B1.6] (BindTemporary)
+// CHECK: 8: [B1.7] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 9: [B1.8]
+// CHECK: 10: foo
+// CHECK: 11: [B1.10] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(const class A &))
+// CHECK: 12: [B1.11]([B1.9])
+// CHECK: 13: ~A() (Temporary object destructor)
+// CHECK: 14: int b;
+// CHECK: 15: [B1.5].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: A::make
+// CHECK: 2: [B1.1] (ImplicitCastExpr, FunctionToPointerDecay, class A (*)(void))
+// CHECK: 3: [B1.2]()
+// CHECK: 4: [B1.3] (BindTemporary)
+// CHECK: 5: [B1.4] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 6: [B1.5]
+// CHECK: 7: [B1.6] (CXXConstructExpr, class A)
+// CHECK: 8: A a = A::make();
+// CHECK: 9: ~A() (Temporary object destructor)
+// CHECK: 10: int b;
+// CHECK: 11: [B1.8].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: A::make
+// CHECK: 2: [B1.1] (ImplicitCastExpr, FunctionToPointerDecay, class A (*)(void))
+// CHECK: 3: [B1.2]()
+// CHECK: 4: [B1.3] (BindTemporary)
+// CHECK: 5: [B1.4] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 6: [B1.5]
+// CHECK: 7: const A &a = A::make();
+// CHECK: 8: A::make
+// CHECK: 9: [B1.8] (ImplicitCastExpr, FunctionToPointerDecay, class A (*)(void))
+// CHECK: 10: [B1.9]()
+// CHECK: 11: [B1.10] (BindTemporary)
+// CHECK: 12: [B1.11] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 13: [B1.12]
+// CHECK: 14: foo
+// CHECK: 15: [B1.14] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(const class A &))
+// CHECK: 16: [B1.15]([B1.13])
+// CHECK: 17: ~A() (Temporary object destructor)
+// CHECK: 18: int b;
+// CHECK: 19: [B1.7].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: int a;
+// CHECK: 2: A() (CXXConstructExpr, class A)
+// CHECK: 3: [B1.2] (BindTemporary)
+// CHECK: 4: [B1.3].operator int
+// CHECK: 5: [B1.4]()
+// CHECK: 6: [B1.5] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 7: a
+// CHECK: 8: [B1.7] = [B1.6]
+// CHECK: 9: ~A() (Temporary object destructor)
+// CHECK: 10: int b;
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B1.1] (BindTemporary)
+// CHECK: 3: [B1.2].operator int
+// CHECK: 4: [B1.3]()
+// CHECK: 5: [B1.4] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 6: int([B1.5]) (CXXFunctionalCastExpr, NoOp, int)
+// CHECK: 7: B() (CXXConstructExpr, class B)
+// CHECK: 8: [B1.7] (BindTemporary)
+// CHECK: 9: [B1.8].operator int
+// CHECK: 10: [B1.9]()
+// CHECK: 11: [B1.10] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 12: int([B1.11]) (CXXFunctionalCastExpr, NoOp, int)
+// CHECK: 13: [B1.6] + [B1.12]
+// CHECK: 14: a([B1.13]) (Member initializer)
+// CHECK: 15: ~B() (Temporary object destructor)
+// CHECK: 16: ~A() (Temporary object destructor)
+// CHECK: 17: /*implicit*/int()
+// CHECK: 18: b([B1.17]) (Member initializer)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
diff --git a/test/Analysis/uninit-vals-ps-region.m b/test/Analysis/uninit-vals-ps-region.m
index c62818a12e0d..d613c7174f1a 100644
--- a/test/Analysis/uninit-vals-ps-region.m
+++ b/test/Analysis/uninit-vals-ps-region.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-checker=core,deadcode.IdempotentOperations -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-checker=core,experimental.deadcode.IdempotentOperations -verify %s
struct s {
int data;
diff --git a/test/Analysis/unix-fns.c b/test/Analysis/unix-fns.c
index cf5ca810de33..ec620985d95a 100644
--- a/test/Analysis/unix-fns.c
+++ b/test/Analysis/unix-fns.c
@@ -9,7 +9,11 @@ typedef __darwin_pthread_once_t pthread_once_t;
int pthread_once(pthread_once_t *, void (*)(void));
typedef long unsigned int __darwin_size_t;
typedef __darwin_size_t size_t;
+void *calloc(size_t, size_t);
void *malloc(size_t);
+void *realloc(void *, size_t);
+void *alloca(size_t);
+void *valloc(size_t);
typedef void (^dispatch_block_t)(void);
typedef long dispatch_once_t;
@@ -66,3 +70,69 @@ void pr2899_nowarn(size_t size) {
foo[i] = 0;
}
}
+void test_calloc(void) {
+ char *foo = calloc(0, 42); // expected-warning{{Call to 'calloc' has an allocation size of 0 bytes}}
+ for (unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_calloc2(void) {
+ char *foo = calloc(42, 0); // expected-warning{{Call to 'calloc' has an allocation size of 0 bytes}}
+ for (unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_calloc_nowarn(size_t nmemb, size_t size) {
+ char *foo = calloc(nmemb, size); // no-warning
+ for (unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_realloc(char *ptr) {
+ char *foo = realloc(ptr, 0); // expected-warning{{Call to 'realloc' has an allocation size of 0 bytes}}
+ for (unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_realloc_nowarn(char *ptr, size_t size) {
+ char *foo = realloc(ptr, size); // no-warning
+ for (unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_alloca() {
+ char *foo = alloca(0); // expected-warning{{Call to 'alloca' has an allocation size of 0 bytes}}
+ for(unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_alloca_nowarn(size_t sz) {
+ char *foo = alloca(sz); // no-warning
+ for(unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_builtin_alloca() {
+ char *foo2 = __builtin_alloca(0); // expected-warning{{Call to 'alloca' has an allocation size of 0 bytes}}
+ for(unsigned i = 0; i < 100; i++) {
+ foo2[i] = 0;
+ }
+}
+void test_builtin_alloca_nowarn(size_t sz) {
+ char *foo2 = __builtin_alloca(sz); // no-warning
+ for(unsigned i = 0; i < 100; i++) {
+ foo2[i] = 0;
+ }
+}
+void test_valloc() {
+ char *foo = valloc(0); // expected-warning{{Call to 'valloc' has an allocation size of 0 bytes}}
+ for(unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_valloc_nowarn(size_t sz) {
+ char *foo = valloc(sz); // no-warning
+ for(unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
diff --git a/test/Analysis/unreachable-code-path.c b/test/Analysis/unreachable-code-path.c
index da14f4c010d6..48a3462ca1e5 100644
--- a/test/Analysis/unreachable-code-path.c
+++ b/test/Analysis/unreachable-code-path.c
@@ -122,3 +122,20 @@ void test10() {
goto d;
f: ;
}
+
+// test11: we can actually end up in the default case, even if it is not
+// obvious: there might be something wrong with the given argument.
+enum foobar { FOO, BAR };
+extern void error();
+void test11(enum foobar fb) {
+ switch (fb) {
+ case FOO:
+ break;
+ case BAR:
+ break;
+ default:
+ error(); // no-warning
+ return;
+ error(); // expected-warning {{never executed}}
+ }
+}
diff --git a/test/Analysis/unused-ivars.m b/test/Analysis/unused-ivars.m
index 42bde1004dcc..894184078039 100644
--- a/test/Analysis/unused-ivars.m
+++ b/test/Analysis/unused-ivars.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fblocks -analyze -analyzer-checker=osx.cocoa.UnusedIvars %s -verify
+// RUN: %clang_cc1 -fblocks -analyze -analyzer-checker=osx.cocoa.UnusedIvars -verify -Wno-objc-root-class %s
//===--- BEGIN: Delta-debugging reduced headers. --------------------------===//
diff --git a/test/Analysis/variadic-method-types.m b/test/Analysis/variadic-method-types.m
index caa0c59debba..4d0f6bc3f75a 100644
--- a/test/Analysis/variadic-method-types.m
+++ b/test/Analysis/variadic-method-types.m
@@ -57,6 +57,12 @@ typedef struct {} NSFastEnumerationState;
+ (id)setWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
- (id)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
@end
+@interface NSOrderedSet : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
+@end
+@interface NSOrderedSet (NSOrderedSetCreation)
++ (id)orderedSetWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
+- (id)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
+@end
@protocol P;
@class C;
@@ -71,6 +77,7 @@ void f(id a, id<P> b, C* c, C<P> *d, FooType fooType, BarType barType) {
[NSArray arrayWithObjects:@"Foo", "Bar", "Baz", nil]; // expected-warning 2 {{Argument to 'NSArray' method 'arrayWithObjects:' should be an Objective-C pointer type, not 'char *'}}
[NSDictionary dictionaryWithObjectsAndKeys:@"Foo", "Bar", nil]; // expected-warning {{Argument to 'NSDictionary' method 'dictionaryWithObjectsAndKeys:' should be an Objective-C pointer type, not 'char *'}}
[NSSet setWithObjects:@"Foo", "Bar", nil]; // expected-warning {{Argument to 'NSSet' method 'setWithObjects:' should be an Objective-C pointer type, not 'char *'}}
+ [NSOrderedSet orderedSetWithObjects:@"Foo", "Bar", nil]; // expected-warning {{Argument to 'NSOrderedSet' method 'orderedSetWithObjects:' should be an Objective-C pointer type, not 'char *'}}
[[[NSArray alloc] initWithObjects:@"Foo", "Bar", nil] autorelease]; // expected-warning {{Argument to 'NSArray' method 'initWithObjects:' should be an Objective-C pointer type, not 'char *'}}
[[[NSDictionary alloc] initWithObjectsAndKeys:@"Foo", "Bar", nil] autorelease]; // expected-warning {{Argument to 'NSDictionary' method 'initWithObjectsAndKeys:' should be an Objective-C pointer type, not 'char *'}}
@@ -79,6 +86,7 @@ void f(id a, id<P> b, C* c, C<P> *d, FooType fooType, BarType barType) {
[[[NSDictionary alloc] initWithObjectsAndKeys:@"Foo", fooType, nil] autorelease]; // no-warning
[[[NSDictionary alloc] initWithObjectsAndKeys:@"Foo", barType, nil] autorelease]; // expected-warning {{Argument to 'NSDictionary' method 'initWithObjectsAndKeys:' should be an Objective-C pointer type, not 'BarType'}}
[[[NSSet alloc] initWithObjects:@"Foo", "Bar", nil] autorelease]; // expected-warning {{Argument to 'NSSet' method 'initWithObjects:' should be an Objective-C pointer type, not 'char *'}}
+ [[[NSOrderedSet alloc] initWithObjects:@"Foo", "Bar", nil] autorelease]; // expected-warning {{Argument to 'NSOrderedSet' method 'initWithObjects:' should be an Objective-C pointer type, not 'char *'}}
}
// This previously crashed the variadic argument checker.
diff --git a/test/Analysis/virtualcall.cpp b/test/Analysis/virtualcall.cpp
new file mode 100644
index 000000000000..127d04f58ae7
--- /dev/null
+++ b/test/Analysis/virtualcall.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.cplusplus.VirtualCall -analyzer-store region -verify %s
+
+class A {
+public:
+ A();
+ ~A() {};
+
+ virtual int foo() = 0;
+ virtual void bar() = 0;
+ void f() {
+ foo(); // expected-warning{{Call pure virtual functions during construction or destruction may leads undefined behaviour}}
+ }
+};
+
+class B : public A {
+public:
+ B() {
+ foo(); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+ }
+ ~B();
+
+ virtual int foo();
+ virtual void bar() { foo(); } // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+};
+
+A::A() {
+ f();
+}
+
+B::~B() {
+ this->B::foo(); // no-warning
+ this->B::bar();
+ this->foo(); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+}
+
+class C : public B {
+public:
+ C();
+ ~C();
+
+ virtual int foo();
+ void f(int i);
+};
+
+C::C() {
+ f(foo()); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+}
+
+int main() {
+ A *a;
+ B *b;
+ C *c;
+}