1 // RUN: %clang_analyze_cc1 -analyzer-config eagerly-assume=false %s -analyzer-checker=osx.cocoa.RetainCount,deadcode.DeadStores,core -analyzer-output=plist -analyzer-config deadcode.DeadStores:ShowFixIts=true -o %t.plist
2 // RUN: %normalize_plist <%t.plist | diff -ub %S/Inputs/expected-plists/plist-output.m.plist -
4 void test_null_init(void) {
9 void test_null_assign(void) {
15 void test_null_assign_transitive(void) {
22 void test_null_cond(int *p) {
28 void test_null_cond_transitive(int *q) {
35 void test_null_field(void) {
36 struct s { int *p; } x;
41 void test_assumptions(int a, int b)
53 int *bar_cond_assign(void);
54 int test_cond_assign(void) {
56 if (p = bar_cond_assign())
61 // The following previously crashed when generating extensive diagnostics.
62 // <rdar://problem/10797980>
63 @interface RDar10797980_help
64 @property (readonly) int x;
67 @interface RDar10797980 {
73 @implementation RDar10797980
77 *p = 0xDEADBEEF; // expected-warning {{deference}}
81 // The original source for the above Radar contains another problem:
82 // if the end-of-path node is an implicit statement, it may not have a valid
83 // source location. <rdar://problem/12446776>
85 if (bar_cond_assign()) {
86 id foo = [[RDar10797980 alloc] init]; // leak
88 (void)y; // first statement after the 'if' is an implicit 'self' DeclRefExpr
93 // Test that loops are documented in the path.
94 void rdar12280665(void) {
95 for (unsigned i = 0; i < 2; ++i) {
98 *p = 0xDEADBEEF; // expected-warning {{dereference}}
103 // Test for a "loop executed 0 times" diagnostic.
104 int *radar12322528_bar(void);
106 void radar12322528_for(int x) {
108 for (unsigned i = 0; i < x; ++i) {
109 p = radar12322528_bar();
114 void radar12322528_while(int x) {
119 p = radar12322528_bar();
124 void radar12322528_foo_2(void) {
126 for (unsigned i = 0; i < 2; ++i) {
133 void test_loop_diagnostics(void) {
135 for (int i = 0; i < 2; ++i) { p = 0; }
139 void test_loop_diagnostics_2(void) {
141 for (int i = 0; i < 2; ) {
148 void test_loop_diagnostics_3(void) {
158 void test_loop_fast_enumeration(id arr) {
160 for (id obj in arr) {
166 @interface RDar12114812 { char *p; }
169 @implementation RDar12114812
176 // Test diagnostics for initialization of structs.
177 void RDar13295437_f(void *i) __attribute__((__nonnull__));
179 struct RDar13295437_S { int *i; };
181 int RDar13295437(void) {
182 struct RDar13295437_S s = {0};
183 struct RDar13295437_S *sp = &s;
184 RDar13295437_f(sp->i);
188 - (int *) returnsPointer;
191 int testFoo(Foo *x) {
194 return *[x returnsPointer];