1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -analyze -analyzer-checker=core -analyzer-config inline-lambdas=true -analyzer-output plist -verify %s -o %t
2 // RUN: FileCheck --input-file=%t %s
3 
4 
5 // Diagnostic inside a lambda
6 
diagnosticFromLambda()7 void diagnosticFromLambda() {
8   int i = 0;
9   [=] {
10     int p = 5/i; // expected-warning{{Division by zero}}
11     (void)p;
12   }();
13 }
14 
15 // CHECK: <key>diagnostics</key>
16 // CHECK-NEXT: <array>
17 // CHECK-NEXT:  <dict>
18 // CHECK-NEXT:   <key>path</key>
19 // CHECK-NEXT:   <array>
20 // CHECK-NEXT:    <dict>
21 // CHECK-NEXT:     <key>kind</key><string>control</string>
22 // CHECK-NEXT:     <key>edges</key>
23 // CHECK-NEXT:      <array>
24 // CHECK-NEXT:       <dict>
25 // CHECK-NEXT:        <key>start</key>
26 // CHECK-NEXT:         <array>
27 // CHECK-NEXT:          <dict>
28 // CHECK-NEXT:           <key>line</key><integer>8</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:          <dict>
33 // CHECK-NEXT:           <key>line</key><integer>8</integer>
34 // CHECK-NEXT:           <key>col</key><integer>5</integer>
35 // CHECK-NEXT:           <key>file</key><integer>0</integer>
36 // CHECK-NEXT:          </dict>
37 // CHECK-NEXT:         </array>
38 // CHECK-NEXT:        <key>end</key>
39 // CHECK-NEXT:         <array>
40 // CHECK-NEXT:          <dict>
41 // CHECK-NEXT:           <key>line</key><integer>9</integer>
42 // CHECK-NEXT:           <key>col</key><integer>3</integer>
43 // CHECK-NEXT:           <key>file</key><integer>0</integer>
44 // CHECK-NEXT:          </dict>
45 // CHECK-NEXT:          <dict>
46 // CHECK-NEXT:           <key>line</key><integer>9</integer>
47 // CHECK-NEXT:           <key>col</key><integer>3</integer>
48 // CHECK-NEXT:           <key>file</key><integer>0</integer>
49 // CHECK-NEXT:          </dict>
50 // CHECK-NEXT:         </array>
51 // CHECK-NEXT:       </dict>
52 // CHECK-NEXT:      </array>
53 // CHECK-NEXT:    </dict>
54 // CHECK-NEXT:    <dict>
55 // CHECK-NEXT:     <key>kind</key><string>event</string>
56 // CHECK-NEXT:     <key>location</key>
57 // CHECK-NEXT:     <dict>
58 // CHECK-NEXT:      <key>line</key><integer>9</integer>
59 // CHECK-NEXT:      <key>col</key><integer>3</integer>
60 // CHECK-NEXT:      <key>file</key><integer>0</integer>
61 // CHECK-NEXT:     </dict>
62 // CHECK-NEXT:     <key>ranges</key>
63 // CHECK-NEXT:     <array>
64 // CHECK-NEXT:       <array>
65 // CHECK-NEXT:        <dict>
66 // CHECK-NEXT:         <key>line</key><integer>9</integer>
67 // CHECK-NEXT:         <key>col</key><integer>3</integer>
68 // CHECK-NEXT:         <key>file</key><integer>0</integer>
69 // CHECK-NEXT:        </dict>
70 // CHECK-NEXT:        <dict>
71 // CHECK-NEXT:         <key>line</key><integer>12</integer>
72 // CHECK-NEXT:         <key>col</key><integer>5</integer>
73 // CHECK-NEXT:         <key>file</key><integer>0</integer>
74 // CHECK-NEXT:        </dict>
75 // CHECK-NEXT:       </array>
76 // CHECK-NEXT:     </array>
77 // CHECK-NEXT:     <key>depth</key><integer>0</integer>
78 // CHECK-NEXT:     <key>extended_message</key>
79 // CHECK-NEXT:     <string>The value 0 is assigned to field &apos;&apos;</string>
80 // CHECK-NEXT:     <key>message</key>
81 // CHECK-NEXT:     <string>The value 0 is assigned to field &apos;&apos;</string>
82 // CHECK-NEXT:    </dict>
83 // CHECK-NEXT:    <dict>
84 // CHECK-NEXT:     <key>kind</key><string>event</string>
85 // CHECK-NEXT:     <key>location</key>
86 // CHECK-NEXT:     <dict>
87 // CHECK-NEXT:      <key>line</key><integer>9</integer>
88 // CHECK-NEXT:      <key>col</key><integer>3</integer>
89 // CHECK-NEXT:      <key>file</key><integer>0</integer>
90 // CHECK-NEXT:     </dict>
91 // CHECK-NEXT:     <key>ranges</key>
92 // CHECK-NEXT:     <array>
93 // CHECK-NEXT:       <array>
94 // CHECK-NEXT:        <dict>
95 // CHECK-NEXT:         <key>line</key><integer>9</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>12</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:     </array>
106 // CHECK-NEXT:     <key>depth</key><integer>0</integer>
107 // CHECK-NEXT:     <key>extended_message</key>
108 // CHECK-NEXT:     <string>Calling &apos;operator()&apos;</string>
109 // CHECK-NEXT:     <key>message</key>
110 // CHECK-NEXT:     <string>Calling &apos;operator()&apos;</string>
111 // CHECK-NEXT:    </dict>
112 // CHECK-NEXT:    <dict>
113 // CHECK-NEXT:     <key>kind</key><string>event</string>
114 // CHECK-NEXT:     <key>location</key>
115 // CHECK-NEXT:     <dict>
116 // CHECK-NEXT:      <key>line</key><integer>9</integer>
117 // CHECK-NEXT:      <key>col</key><integer>5</integer>
118 // CHECK-NEXT:      <key>file</key><integer>0</integer>
119 // CHECK-NEXT:     </dict>
120 // CHECK-NEXT:     <key>depth</key><integer>1</integer>
121 // CHECK-NEXT:     <key>extended_message</key>
122 // CHECK-NEXT:     <string>Entered call from &apos;diagnosticFromLambda&apos;</string>
123 // CHECK-NEXT:     <key>message</key>
124 // CHECK-NEXT:     <string>Entered call from &apos;diagnosticFromLambda&apos;</string>
125 // CHECK-NEXT:    </dict>
126 // CHECK-NEXT:    <dict>
127 // CHECK-NEXT:     <key>kind</key><string>control</string>
128 // CHECK-NEXT:     <key>edges</key>
129 // CHECK-NEXT:      <array>
130 // CHECK-NEXT:       <dict>
131 // CHECK-NEXT:        <key>start</key>
132 // CHECK-NEXT:         <array>
133 // CHECK-NEXT:          <dict>
134 // CHECK-NEXT:           <key>line</key><integer>9</integer>
135 // CHECK-NEXT:           <key>col</key><integer>5</integer>
136 // CHECK-NEXT:           <key>file</key><integer>0</integer>
137 // CHECK-NEXT:          </dict>
138 // CHECK-NEXT:          <dict>
139 // CHECK-NEXT:           <key>line</key><integer>9</integer>
140 // CHECK-NEXT:           <key>col</key><integer>5</integer>
141 // CHECK-NEXT:           <key>file</key><integer>0</integer>
142 // CHECK-NEXT:          </dict>
143 // CHECK-NEXT:         </array>
144 // CHECK-NEXT:        <key>end</key>
145 // CHECK-NEXT:         <array>
146 // CHECK-NEXT:          <dict>
147 // CHECK-NEXT:           <key>line</key><integer>10</integer>
148 // CHECK-NEXT:           <key>col</key><integer>14</integer>
149 // CHECK-NEXT:           <key>file</key><integer>0</integer>
150 // CHECK-NEXT:          </dict>
151 // CHECK-NEXT:          <dict>
152 // CHECK-NEXT:           <key>line</key><integer>10</integer>
153 // CHECK-NEXT:           <key>col</key><integer>14</integer>
154 // CHECK-NEXT:           <key>file</key><integer>0</integer>
155 // CHECK-NEXT:          </dict>
156 // CHECK-NEXT:         </array>
157 // CHECK-NEXT:       </dict>
158 // CHECK-NEXT:      </array>
159 // CHECK-NEXT:    </dict>
160 // CHECK-NEXT:    <dict>
161 // CHECK-NEXT:     <key>kind</key><string>event</string>
162 // CHECK-NEXT:     <key>location</key>
163 // CHECK-NEXT:     <dict>
164 // CHECK-NEXT:      <key>line</key><integer>10</integer>
165 // CHECK-NEXT:      <key>col</key><integer>14</integer>
166 // CHECK-NEXT:      <key>file</key><integer>0</integer>
167 // CHECK-NEXT:     </dict>
168 // CHECK-NEXT:     <key>ranges</key>
169 // CHECK-NEXT:     <array>
170 // CHECK-NEXT:       <array>
171 // CHECK-NEXT:        <dict>
172 // CHECK-NEXT:         <key>line</key><integer>10</integer>
173 // CHECK-NEXT:         <key>col</key><integer>13</integer>
174 // CHECK-NEXT:         <key>file</key><integer>0</integer>
175 // CHECK-NEXT:        </dict>
176 // CHECK-NEXT:        <dict>
177 // CHECK-NEXT:         <key>line</key><integer>10</integer>
178 // CHECK-NEXT:         <key>col</key><integer>15</integer>
179 // CHECK-NEXT:         <key>file</key><integer>0</integer>
180 // CHECK-NEXT:        </dict>
181 // CHECK-NEXT:       </array>
182 // CHECK-NEXT:     </array>
183 // CHECK-NEXT:     <key>depth</key><integer>1</integer>
184 // CHECK-NEXT:     <key>extended_message</key>
185 // CHECK-NEXT:     <string>Division by zero</string>
186 // CHECK-NEXT:     <key>message</key>
187 // CHECK-NEXT:     <string>Division by zero</string>
188 // CHECK-NEXT:    </dict>
189 // CHECK-NEXT:   </array>
190 // CHECK-NEXT:   <key>description</key><string>Division by zero</string>
191 // CHECK-NEXT:   <key>category</key><string>Logic error</string>
192 // CHECK-NEXT:   <key>type</key><string>Division by zero</string>
193 // CHECK-NEXT:   <key>check_name</key><string>core.DivideZero</string>
194 // CHECK-NEXT:   <!-- This hash is experimental and going to change! -->
195 // CHECK-NEXT:   <key>issue_hash_content_of_line_in_context</key><string>bd4eed3234018edced5efc2ed5562a74</string>
196 // CHECK-NEXT:  <key>issue_context_kind</key><string>C++ method</string>
197 // CHECK-NEXT:  <key>issue_context</key><string>operator()</string>
198 // CHECK-NEXT:  <key>issue_hash_function_offset</key><string>1</string>
199 // CHECK-NEXT:  <key>location</key>
200 // CHECK-NEXT:  <dict>
201 // CHECK-NEXT:   <key>line</key><integer>10</integer>
202 // CHECK-NEXT:   <key>col</key><integer>14</integer>
203 // CHECK-NEXT:   <key>file</key><integer>0</integer>
204 // CHECK-NEXT:  </dict>
205 // CHECK-NEXT:  </dict>
206 // CHECK-NEXT: </array>
207