• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang --analyze %s -Xanalyzer -analyzer-config -Xanalyzer path-diagnostics-alternate=false -o %t > /dev/null 2>&1
2 // RUN: FileCheck -input-file %t %s
3 
bug(int * p)4 static inline bug(int *p) {
5   *p = 0xDEADBEEF;
6 }
7 
test_bug_1()8 void test_bug_1() {
9   int *p = 0;
10   bug(p);
11 }
12 
test_bug_2()13 void test_bug_2() {
14   int *p = 0;
15   bug(p);
16 }
17 
18 
19 // CHECK:  <key>diagnostics</key>
20 // CHECK-NEXT:  <array>
21 // CHECK-NEXT:   <dict>
22 // CHECK-NEXT:    <key>path</key>
23 // CHECK-NEXT:    <array>
24 // CHECK-NEXT:     <dict>
25 // CHECK-NEXT:      <key>kind</key><string>event</string>
26 // CHECK-NEXT:      <key>location</key>
27 // CHECK-NEXT:      <dict>
28 // CHECK-NEXT:       <key>line</key><integer>14</integer>
29 // CHECK-NEXT:       <key>col</key><integer>3</integer>
30 // CHECK-NEXT:       <key>file</key><integer>0</integer>
31 // CHECK-NEXT:      </dict>
32 // CHECK-NEXT:      <key>ranges</key>
33 // CHECK-NEXT:      <array>
34 // CHECK-NEXT:        <array>
35 // CHECK-NEXT:         <dict>
36 // CHECK-NEXT:          <key>line</key><integer>14</integer>
37 // CHECK-NEXT:          <key>col</key><integer>3</integer>
38 // CHECK-NEXT:          <key>file</key><integer>0</integer>
39 // CHECK-NEXT:         </dict>
40 // CHECK-NEXT:         <dict>
41 // CHECK-NEXT:          <key>line</key><integer>14</integer>
42 // CHECK-NEXT:          <key>col</key><integer>8</integer>
43 // CHECK-NEXT:          <key>file</key><integer>0</integer>
44 // CHECK-NEXT:         </dict>
45 // CHECK-NEXT:        </array>
46 // CHECK-NEXT:      </array>
47 // CHECK-NEXT:      <key>depth</key><integer>0</integer>
48 // CHECK-NEXT:      <key>extended_message</key>
49 // CHECK-NEXT:      <string>&apos;p&apos; initialized to a null pointer value</string>
50 // CHECK-NEXT:      <key>message</key>
51 // CHECK-NEXT:      <string>&apos;p&apos; initialized to a null pointer value</string>
52 // CHECK-NEXT:     </dict>
53 // CHECK-NEXT:     <dict>
54 // CHECK-NEXT:      <key>kind</key><string>control</string>
55 // CHECK-NEXT:      <key>edges</key>
56 // CHECK-NEXT:       <array>
57 // CHECK-NEXT:        <dict>
58 // CHECK-NEXT:         <key>start</key>
59 // CHECK-NEXT:          <array>
60 // CHECK-NEXT:           <dict>
61 // CHECK-NEXT:            <key>line</key><integer>14</integer>
62 // CHECK-NEXT:            <key>col</key><integer>3</integer>
63 // CHECK-NEXT:            <key>file</key><integer>0</integer>
64 // CHECK-NEXT:           </dict>
65 // CHECK-NEXT:           <dict>
66 // CHECK-NEXT:            <key>line</key><integer>14</integer>
67 // CHECK-NEXT:            <key>col</key><integer>5</integer>
68 // CHECK-NEXT:            <key>file</key><integer>0</integer>
69 // CHECK-NEXT:           </dict>
70 // CHECK-NEXT:          </array>
71 // CHECK-NEXT:         <key>end</key>
72 // CHECK-NEXT:          <array>
73 // CHECK-NEXT:           <dict>
74 // CHECK-NEXT:            <key>line</key><integer>15</integer>
75 // CHECK-NEXT:            <key>col</key><integer>3</integer>
76 // CHECK-NEXT:            <key>file</key><integer>0</integer>
77 // CHECK-NEXT:           </dict>
78 // CHECK-NEXT:           <dict>
79 // CHECK-NEXT:            <key>line</key><integer>15</integer>
80 // CHECK-NEXT:            <key>col</key><integer>5</integer>
81 // CHECK-NEXT:            <key>file</key><integer>0</integer>
82 // CHECK-NEXT:           </dict>
83 // CHECK-NEXT:          </array>
84 // CHECK-NEXT:        </dict>
85 // CHECK-NEXT:       </array>
86 // CHECK-NEXT:     </dict>
87 // CHECK-NEXT:     <dict>
88 // CHECK-NEXT:      <key>kind</key><string>control</string>
89 // CHECK-NEXT:      <key>edges</key>
90 // CHECK-NEXT:       <array>
91 // CHECK-NEXT:        <dict>
92 // CHECK-NEXT:         <key>start</key>
93 // CHECK-NEXT:          <array>
94 // CHECK-NEXT:           <dict>
95 // CHECK-NEXT:            <key>line</key><integer>15</integer>
96 // CHECK-NEXT:            <key>col</key><integer>3</integer>
97 // CHECK-NEXT:            <key>file</key><integer>0</integer>
98 // CHECK-NEXT:           </dict>
99 // CHECK-NEXT:           <dict>
100 // CHECK-NEXT:            <key>line</key><integer>15</integer>
101 // CHECK-NEXT:            <key>col</key><integer>5</integer>
102 // CHECK-NEXT:            <key>file</key><integer>0</integer>
103 // CHECK-NEXT:           </dict>
104 // CHECK-NEXT:          </array>
105 // CHECK-NEXT:         <key>end</key>
106 // CHECK-NEXT:          <array>
107 // CHECK-NEXT:           <dict>
108 // CHECK-NEXT:            <key>line</key><integer>15</integer>
109 // CHECK-NEXT:            <key>col</key><integer>7</integer>
110 // CHECK-NEXT:            <key>file</key><integer>0</integer>
111 // CHECK-NEXT:           </dict>
112 // CHECK-NEXT:           <dict>
113 // CHECK-NEXT:            <key>line</key><integer>15</integer>
114 // CHECK-NEXT:            <key>col</key><integer>7</integer>
115 // CHECK-NEXT:            <key>file</key><integer>0</integer>
116 // CHECK-NEXT:           </dict>
117 // CHECK-NEXT:          </array>
118 // CHECK-NEXT:        </dict>
119 // CHECK-NEXT:       </array>
120 // CHECK-NEXT:     </dict>
121 // CHECK-NEXT:     <dict>
122 // CHECK-NEXT:      <key>kind</key><string>event</string>
123 // CHECK-NEXT:      <key>location</key>
124 // CHECK-NEXT:      <dict>
125 // CHECK-NEXT:       <key>line</key><integer>15</integer>
126 // CHECK-NEXT:       <key>col</key><integer>7</integer>
127 // CHECK-NEXT:       <key>file</key><integer>0</integer>
128 // CHECK-NEXT:      </dict>
129 // CHECK-NEXT:      <key>ranges</key>
130 // CHECK-NEXT:      <array>
131 // CHECK-NEXT:        <array>
132 // CHECK-NEXT:         <dict>
133 // CHECK-NEXT:          <key>line</key><integer>15</integer>
134 // CHECK-NEXT:          <key>col</key><integer>7</integer>
135 // CHECK-NEXT:          <key>file</key><integer>0</integer>
136 // CHECK-NEXT:         </dict>
137 // CHECK-NEXT:         <dict>
138 // CHECK-NEXT:          <key>line</key><integer>15</integer>
139 // CHECK-NEXT:          <key>col</key><integer>7</integer>
140 // CHECK-NEXT:          <key>file</key><integer>0</integer>
141 // CHECK-NEXT:         </dict>
142 // CHECK-NEXT:        </array>
143 // CHECK-NEXT:      </array>
144 // CHECK-NEXT:      <key>depth</key><integer>0</integer>
145 // CHECK-NEXT:      <key>extended_message</key>
146 // CHECK-NEXT:      <string>Passing null pointer value via 1st parameter &apos;p&apos;</string>
147 // CHECK-NEXT:      <key>message</key>
148 // CHECK-NEXT:      <string>Passing null pointer value via 1st parameter &apos;p&apos;</string>
149 // CHECK-NEXT:     </dict>
150 // CHECK-NEXT:     <dict>
151 // CHECK-NEXT:      <key>kind</key><string>event</string>
152 // CHECK-NEXT:      <key>location</key>
153 // CHECK-NEXT:      <dict>
154 // CHECK-NEXT:       <key>line</key><integer>15</integer>
155 // CHECK-NEXT:       <key>col</key><integer>3</integer>
156 // CHECK-NEXT:       <key>file</key><integer>0</integer>
157 // CHECK-NEXT:      </dict>
158 // CHECK-NEXT:      <key>ranges</key>
159 // CHECK-NEXT:      <array>
160 // CHECK-NEXT:        <array>
161 // CHECK-NEXT:         <dict>
162 // CHECK-NEXT:          <key>line</key><integer>15</integer>
163 // CHECK-NEXT:          <key>col</key><integer>3</integer>
164 // CHECK-NEXT:          <key>file</key><integer>0</integer>
165 // CHECK-NEXT:         </dict>
166 // CHECK-NEXT:         <dict>
167 // CHECK-NEXT:          <key>line</key><integer>15</integer>
168 // CHECK-NEXT:          <key>col</key><integer>8</integer>
169 // CHECK-NEXT:          <key>file</key><integer>0</integer>
170 // CHECK-NEXT:         </dict>
171 // CHECK-NEXT:        </array>
172 // CHECK-NEXT:      </array>
173 // CHECK-NEXT:      <key>depth</key><integer>0</integer>
174 // CHECK-NEXT:      <key>extended_message</key>
175 // CHECK-NEXT:      <string>Calling &apos;bug&apos;</string>
176 // CHECK-NEXT:      <key>message</key>
177 // CHECK-NEXT:      <string>Calling &apos;bug&apos;</string>
178 // CHECK-NEXT:     </dict>
179 // CHECK-NEXT:     <dict>
180 // CHECK-NEXT:      <key>kind</key><string>event</string>
181 // CHECK-NEXT:      <key>location</key>
182 // CHECK-NEXT:      <dict>
183 // CHECK-NEXT:       <key>line</key><integer>4</integer>
184 // CHECK-NEXT:       <key>col</key><integer>1</integer>
185 // CHECK-NEXT:       <key>file</key><integer>0</integer>
186 // CHECK-NEXT:      </dict>
187 // CHECK-NEXT:      <key>depth</key><integer>1</integer>
188 // CHECK-NEXT:      <key>extended_message</key>
189 // CHECK-NEXT:      <string>Entered call from &apos;test_bug_2&apos;</string>
190 // CHECK-NEXT:      <key>message</key>
191 // CHECK-NEXT:      <string>Entered call from &apos;test_bug_2&apos;</string>
192 // CHECK-NEXT:     </dict>
193 // CHECK-NEXT:     <dict>
194 // CHECK-NEXT:      <key>kind</key><string>control</string>
195 // CHECK-NEXT:      <key>edges</key>
196 // CHECK-NEXT:       <array>
197 // CHECK-NEXT:        <dict>
198 // CHECK-NEXT:         <key>start</key>
199 // CHECK-NEXT:          <array>
200 // CHECK-NEXT:           <dict>
201 // CHECK-NEXT:            <key>line</key><integer>4</integer>
202 // CHECK-NEXT:            <key>col</key><integer>1</integer>
203 // CHECK-NEXT:            <key>file</key><integer>0</integer>
204 // CHECK-NEXT:           </dict>
205 // CHECK-NEXT:           <dict>
206 // CHECK-NEXT:            <key>line</key><integer>4</integer>
207 // CHECK-NEXT:            <key>col</key><integer>6</integer>
208 // CHECK-NEXT:            <key>file</key><integer>0</integer>
209 // CHECK-NEXT:           </dict>
210 // CHECK-NEXT:          </array>
211 // CHECK-NEXT:         <key>end</key>
212 // CHECK-NEXT:          <array>
213 // CHECK-NEXT:           <dict>
214 // CHECK-NEXT:            <key>line</key><integer>5</integer>
215 // CHECK-NEXT:            <key>col</key><integer>3</integer>
216 // CHECK-NEXT:            <key>file</key><integer>0</integer>
217 // CHECK-NEXT:           </dict>
218 // CHECK-NEXT:           <dict>
219 // CHECK-NEXT:            <key>line</key><integer>5</integer>
220 // CHECK-NEXT:            <key>col</key><integer>3</integer>
221 // CHECK-NEXT:            <key>file</key><integer>0</integer>
222 // CHECK-NEXT:           </dict>
223 // CHECK-NEXT:          </array>
224 // CHECK-NEXT:        </dict>
225 // CHECK-NEXT:       </array>
226 // CHECK-NEXT:     </dict>
227 // CHECK-NEXT:     <dict>
228 // CHECK-NEXT:      <key>kind</key><string>control</string>
229 // CHECK-NEXT:      <key>edges</key>
230 // CHECK-NEXT:       <array>
231 // CHECK-NEXT:        <dict>
232 // CHECK-NEXT:         <key>start</key>
233 // CHECK-NEXT:          <array>
234 // CHECK-NEXT:           <dict>
235 // CHECK-NEXT:            <key>line</key><integer>5</integer>
236 // CHECK-NEXT:            <key>col</key><integer>3</integer>
237 // CHECK-NEXT:            <key>file</key><integer>0</integer>
238 // CHECK-NEXT:           </dict>
239 // CHECK-NEXT:           <dict>
240 // CHECK-NEXT:            <key>line</key><integer>5</integer>
241 // CHECK-NEXT:            <key>col</key><integer>3</integer>
242 // CHECK-NEXT:            <key>file</key><integer>0</integer>
243 // CHECK-NEXT:           </dict>
244 // CHECK-NEXT:          </array>
245 // CHECK-NEXT:         <key>end</key>
246 // CHECK-NEXT:          <array>
247 // CHECK-NEXT:           <dict>
248 // CHECK-NEXT:            <key>line</key><integer>5</integer>
249 // CHECK-NEXT:            <key>col</key><integer>6</integer>
250 // CHECK-NEXT:            <key>file</key><integer>0</integer>
251 // CHECK-NEXT:           </dict>
252 // CHECK-NEXT:           <dict>
253 // CHECK-NEXT:            <key>line</key><integer>5</integer>
254 // CHECK-NEXT:            <key>col</key><integer>6</integer>
255 // CHECK-NEXT:            <key>file</key><integer>0</integer>
256 // CHECK-NEXT:           </dict>
257 // CHECK-NEXT:          </array>
258 // CHECK-NEXT:        </dict>
259 // CHECK-NEXT:       </array>
260 // CHECK-NEXT:     </dict>
261 // CHECK-NEXT:     <dict>
262 // CHECK-NEXT:      <key>kind</key><string>event</string>
263 // CHECK-NEXT:      <key>location</key>
264 // CHECK-NEXT:      <dict>
265 // CHECK-NEXT:       <key>line</key><integer>5</integer>
266 // CHECK-NEXT:       <key>col</key><integer>6</integer>
267 // CHECK-NEXT:       <key>file</key><integer>0</integer>
268 // CHECK-NEXT:      </dict>
269 // CHECK-NEXT:      <key>ranges</key>
270 // CHECK-NEXT:      <array>
271 // CHECK-NEXT:        <array>
272 // CHECK-NEXT:         <dict>
273 // CHECK-NEXT:          <key>line</key><integer>5</integer>
274 // CHECK-NEXT:          <key>col</key><integer>4</integer>
275 // CHECK-NEXT:          <key>file</key><integer>0</integer>
276 // CHECK-NEXT:         </dict>
277 // CHECK-NEXT:         <dict>
278 // CHECK-NEXT:          <key>line</key><integer>5</integer>
279 // CHECK-NEXT:          <key>col</key><integer>4</integer>
280 // CHECK-NEXT:          <key>file</key><integer>0</integer>
281 // CHECK-NEXT:         </dict>
282 // CHECK-NEXT:        </array>
283 // CHECK-NEXT:      </array>
284 // CHECK-NEXT:      <key>depth</key><integer>1</integer>
285 // CHECK-NEXT:      <key>extended_message</key>
286 // CHECK-NEXT:      <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
287 // CHECK-NEXT:      <key>message</key>
288 // CHECK-NEXT:      <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
289 // CHECK-NEXT:     </dict>
290 // CHECK-NEXT:    </array>
291 // CHECK-NEXT:    <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
292 // CHECK-NEXT:    <key>category</key><string>Logic error</string>
293 // CHECK-NEXT:    <key>type</key><string>Dereference of null pointer</string>
294 // CHECK-NEXT:   <key>issue_context_kind</key><string>function</string>
295 // CHECK-NEXT:   <key>issue_context</key><string>bug</string>
296 // CHECK-NEXT:   <key>issue_hash</key><string>1</string>
297 // CHECK-NEXT:   <key>location</key>
298 // CHECK-NEXT:   <dict>
299 // CHECK-NEXT:    <key>line</key><integer>5</integer>
300 // CHECK-NEXT:    <key>col</key><integer>6</integer>
301 // CHECK-NEXT:    <key>file</key><integer>0</integer>
302 // CHECK-NEXT:   </dict>
303 // CHECK-NEXT:   </dict>
304 // CHECK-NEXT:  </array>
305