xref: /minix3/external/bsd/llvm/dist/clang/test/Analysis/MismatchedDeallocator-path-notes.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.MismatchedDeallocator -analyzer-output=text -verify %s
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.MismatchedDeallocator -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false %s -o %t.plist
3*f4a2713aSLionel Sambuc // RUN: FileCheck --input-file=%t.plist %s
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc void changePointee(int *p);
test()6*f4a2713aSLionel Sambuc void test() {
7*f4a2713aSLionel Sambuc   int *p = new int[1];
8*f4a2713aSLionel Sambuc   // expected-note@-1 {{Memory is allocated}}
9*f4a2713aSLionel Sambuc   changePointee(p);
10*f4a2713aSLionel Sambuc   delete p; // expected-warning {{Memory allocated by 'new[]' should be deallocated by 'delete[]', not 'delete'}}
11*f4a2713aSLionel Sambuc   // expected-note@-1 {{Memory allocated by 'new[]' should be deallocated by 'delete[]', not 'delete'}}
12*f4a2713aSLionel Sambuc }
13*f4a2713aSLionel Sambuc 
14*f4a2713aSLionel Sambuc // CHECK: <key>diagnostics</key>
15*f4a2713aSLionel Sambuc // CHECK-NEXT: <array>
16*f4a2713aSLionel Sambuc // CHECK-NEXT:  <dict>
17*f4a2713aSLionel Sambuc // CHECK-NEXT:   <key>path</key>
18*f4a2713aSLionel Sambuc // CHECK-NEXT:   <array>
19*f4a2713aSLionel Sambuc // CHECK-NEXT:    <dict>
20*f4a2713aSLionel Sambuc // CHECK-NEXT:     <key>kind</key><string>control</string>
21*f4a2713aSLionel Sambuc // CHECK-NEXT:     <key>edges</key>
22*f4a2713aSLionel Sambuc // CHECK-NEXT:      <array>
23*f4a2713aSLionel Sambuc // CHECK-NEXT:       <dict>
24*f4a2713aSLionel Sambuc // CHECK-NEXT:        <key>start</key>
25*f4a2713aSLionel Sambuc // CHECK-NEXT:         <array>
26*f4a2713aSLionel Sambuc // CHECK-NEXT:          <dict>
27*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>line</key><integer>7</integer>
28*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>col</key><integer>3</integer>
29*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>file</key><integer>0</integer>
30*f4a2713aSLionel Sambuc // CHECK-NEXT:          </dict>
31*f4a2713aSLionel Sambuc // CHECK-NEXT:          <dict>
32*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>line</key><integer>7</integer>
33*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>col</key><integer>5</integer>
34*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>file</key><integer>0</integer>
35*f4a2713aSLionel Sambuc // CHECK-NEXT:          </dict>
36*f4a2713aSLionel Sambuc // CHECK-NEXT:         </array>
37*f4a2713aSLionel Sambuc // CHECK-NEXT:        <key>end</key>
38*f4a2713aSLionel Sambuc // CHECK-NEXT:         <array>
39*f4a2713aSLionel Sambuc // CHECK-NEXT:          <dict>
40*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>line</key><integer>7</integer>
41*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>col</key><integer>12</integer>
42*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>file</key><integer>0</integer>
43*f4a2713aSLionel Sambuc // CHECK-NEXT:          </dict>
44*f4a2713aSLionel Sambuc // CHECK-NEXT:          <dict>
45*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>line</key><integer>7</integer>
46*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>col</key><integer>14</integer>
47*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>file</key><integer>0</integer>
48*f4a2713aSLionel Sambuc // CHECK-NEXT:          </dict>
49*f4a2713aSLionel Sambuc // CHECK-NEXT:         </array>
50*f4a2713aSLionel Sambuc // CHECK-NEXT:       </dict>
51*f4a2713aSLionel Sambuc // CHECK-NEXT:      </array>
52*f4a2713aSLionel Sambuc // CHECK-NEXT:    </dict>
53*f4a2713aSLionel Sambuc // CHECK-NEXT:    <dict>
54*f4a2713aSLionel Sambuc // CHECK-NEXT:     <key>kind</key><string>event</string>
55*f4a2713aSLionel Sambuc // CHECK-NEXT:     <key>location</key>
56*f4a2713aSLionel Sambuc // CHECK-NEXT:     <dict>
57*f4a2713aSLionel Sambuc // CHECK-NEXT:      <key>line</key><integer>7</integer>
58*f4a2713aSLionel Sambuc // CHECK-NEXT:      <key>col</key><integer>12</integer>
59*f4a2713aSLionel Sambuc // CHECK-NEXT:      <key>file</key><integer>0</integer>
60*f4a2713aSLionel Sambuc // CHECK-NEXT:     </dict>
61*f4a2713aSLionel Sambuc // CHECK-NEXT:     <key>ranges</key>
62*f4a2713aSLionel Sambuc // CHECK-NEXT:     <array>
63*f4a2713aSLionel Sambuc // CHECK-NEXT:       <array>
64*f4a2713aSLionel Sambuc // CHECK-NEXT:        <dict>
65*f4a2713aSLionel Sambuc // CHECK-NEXT:         <key>line</key><integer>7</integer>
66*f4a2713aSLionel Sambuc // CHECK-NEXT:         <key>col</key><integer>12</integer>
67*f4a2713aSLionel Sambuc // CHECK-NEXT:         <key>file</key><integer>0</integer>
68*f4a2713aSLionel Sambuc // CHECK-NEXT:        </dict>
69*f4a2713aSLionel Sambuc // CHECK-NEXT:        <dict>
70*f4a2713aSLionel Sambuc // CHECK-NEXT:         <key>line</key><integer>7</integer>
71*f4a2713aSLionel Sambuc // CHECK-NEXT:         <key>col</key><integer>21</integer>
72*f4a2713aSLionel Sambuc // CHECK-NEXT:         <key>file</key><integer>0</integer>
73*f4a2713aSLionel Sambuc // CHECK-NEXT:        </dict>
74*f4a2713aSLionel Sambuc // CHECK-NEXT:       </array>
75*f4a2713aSLionel Sambuc // CHECK-NEXT:     </array>
76*f4a2713aSLionel Sambuc // CHECK-NEXT:     <key>depth</key><integer>0</integer>
77*f4a2713aSLionel Sambuc // CHECK-NEXT:     <key>extended_message</key>
78*f4a2713aSLionel Sambuc // CHECK-NEXT:     <string>Memory is allocated</string>
79*f4a2713aSLionel Sambuc // CHECK-NEXT:     <key>message</key>
80*f4a2713aSLionel Sambuc // CHECK-NEXT:     <string>Memory is allocated</string>
81*f4a2713aSLionel Sambuc // CHECK-NEXT:    </dict>
82*f4a2713aSLionel Sambuc // CHECK-NEXT:    <dict>
83*f4a2713aSLionel Sambuc // CHECK-NEXT:     <key>kind</key><string>control</string>
84*f4a2713aSLionel Sambuc // CHECK-NEXT:     <key>edges</key>
85*f4a2713aSLionel Sambuc // CHECK-NEXT:      <array>
86*f4a2713aSLionel Sambuc // CHECK-NEXT:       <dict>
87*f4a2713aSLionel Sambuc // CHECK-NEXT:        <key>start</key>
88*f4a2713aSLionel Sambuc // CHECK-NEXT:         <array>
89*f4a2713aSLionel Sambuc // CHECK-NEXT:          <dict>
90*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>line</key><integer>7</integer>
91*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>col</key><integer>12</integer>
92*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>file</key><integer>0</integer>
93*f4a2713aSLionel Sambuc // CHECK-NEXT:          </dict>
94*f4a2713aSLionel Sambuc // CHECK-NEXT:          <dict>
95*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>line</key><integer>7</integer>
96*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>col</key><integer>14</integer>
97*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>file</key><integer>0</integer>
98*f4a2713aSLionel Sambuc // CHECK-NEXT:          </dict>
99*f4a2713aSLionel Sambuc // CHECK-NEXT:         </array>
100*f4a2713aSLionel Sambuc // CHECK-NEXT:        <key>end</key>
101*f4a2713aSLionel Sambuc // CHECK-NEXT:         <array>
102*f4a2713aSLionel Sambuc // CHECK-NEXT:          <dict>
103*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>line</key><integer>10</integer>
104*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>col</key><integer>3</integer>
105*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>file</key><integer>0</integer>
106*f4a2713aSLionel Sambuc // CHECK-NEXT:          </dict>
107*f4a2713aSLionel Sambuc // CHECK-NEXT:          <dict>
108*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>line</key><integer>10</integer>
109*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>col</key><integer>8</integer>
110*f4a2713aSLionel Sambuc // CHECK-NEXT:           <key>file</key><integer>0</integer>
111*f4a2713aSLionel Sambuc // CHECK-NEXT:          </dict>
112*f4a2713aSLionel Sambuc // CHECK-NEXT:         </array>
113*f4a2713aSLionel Sambuc // CHECK-NEXT:       </dict>
114*f4a2713aSLionel Sambuc // CHECK-NEXT:      </array>
115*f4a2713aSLionel Sambuc // CHECK-NEXT:    </dict>
116*f4a2713aSLionel Sambuc // CHECK-NEXT:    <dict>
117*f4a2713aSLionel Sambuc // CHECK-NEXT:     <key>kind</key><string>event</string>
118*f4a2713aSLionel Sambuc // CHECK-NEXT:     <key>location</key>
119*f4a2713aSLionel Sambuc // CHECK-NEXT:     <dict>
120*f4a2713aSLionel Sambuc // CHECK-NEXT:      <key>line</key><integer>10</integer>
121*f4a2713aSLionel Sambuc // CHECK-NEXT:      <key>col</key><integer>3</integer>
122*f4a2713aSLionel Sambuc // CHECK-NEXT:      <key>file</key><integer>0</integer>
123*f4a2713aSLionel Sambuc // CHECK-NEXT:     </dict>
124*f4a2713aSLionel Sambuc // CHECK-NEXT:     <key>ranges</key>
125*f4a2713aSLionel Sambuc // CHECK-NEXT:     <array>
126*f4a2713aSLionel Sambuc // CHECK-NEXT:       <array>
127*f4a2713aSLionel Sambuc // CHECK-NEXT:        <dict>
128*f4a2713aSLionel Sambuc // CHECK-NEXT:         <key>line</key><integer>10</integer>
129*f4a2713aSLionel Sambuc // CHECK-NEXT:         <key>col</key><integer>10</integer>
130*f4a2713aSLionel Sambuc // CHECK-NEXT:         <key>file</key><integer>0</integer>
131*f4a2713aSLionel Sambuc // CHECK-NEXT:        </dict>
132*f4a2713aSLionel Sambuc // CHECK-NEXT:        <dict>
133*f4a2713aSLionel Sambuc // CHECK-NEXT:         <key>line</key><integer>10</integer>
134*f4a2713aSLionel Sambuc // CHECK-NEXT:         <key>col</key><integer>10</integer>
135*f4a2713aSLionel Sambuc // CHECK-NEXT:         <key>file</key><integer>0</integer>
136*f4a2713aSLionel Sambuc // CHECK-NEXT:        </dict>
137*f4a2713aSLionel Sambuc // CHECK-NEXT:       </array>
138*f4a2713aSLionel Sambuc // CHECK-NEXT:     </array>
139*f4a2713aSLionel Sambuc // CHECK-NEXT:     <key>depth</key><integer>0</integer>
140*f4a2713aSLionel Sambuc // CHECK-NEXT:     <key>extended_message</key>
141*f4a2713aSLionel Sambuc // CHECK-NEXT:     <string>Memory allocated by &apos;new[]&apos; should be deallocated by &apos;delete[]&apos;, not &apos;delete&apos;</string>
142*f4a2713aSLionel Sambuc // CHECK-NEXT:     <key>message</key>
143*f4a2713aSLionel Sambuc // CHECK-NEXT:     <string>Memory allocated by &apos;new[]&apos; should be deallocated by &apos;delete[]&apos;, not &apos;delete&apos;</string>
144*f4a2713aSLionel Sambuc // CHECK-NEXT:    </dict>
145*f4a2713aSLionel Sambuc // CHECK-NEXT:   </array>
146*f4a2713aSLionel Sambuc // CHECK-NEXT:   <key>description</key><string>Memory allocated by &apos;new[]&apos; should be deallocated by &apos;delete[]&apos;, not &apos;delete&apos;</string>
147*f4a2713aSLionel Sambuc // CHECK-NEXT:   <key>category</key><string>Memory Error</string>
148*f4a2713aSLionel Sambuc // CHECK-NEXT:   <key>type</key><string>Bad deallocator</string>
149*f4a2713aSLionel Sambuc // CHECK-NEXT:  <key>issue_context_kind</key><string>function</string>
150*f4a2713aSLionel Sambuc // CHECK-NEXT:  <key>issue_context</key><string>test</string>
151*f4a2713aSLionel Sambuc // CHECK-NEXT:  <key>issue_hash</key><string>4</string>
152*f4a2713aSLionel Sambuc // CHECK-NEXT:  <key>location</key>
153*f4a2713aSLionel Sambuc // CHECK-NEXT:  <dict>
154*f4a2713aSLionel Sambuc // CHECK-NEXT:   <key>line</key><integer>10</integer>
155*f4a2713aSLionel Sambuc // CHECK-NEXT:   <key>col</key><integer>3</integer>
156*f4a2713aSLionel Sambuc // CHECK-NEXT:   <key>file</key><integer>0</integer>
157*f4a2713aSLionel Sambuc // CHECK-NEXT:  </dict>
158*f4a2713aSLionel Sambuc // CHECK-NEXT:  </dict>
159*f4a2713aSLionel Sambuc // CHECK-NEXT: </array>
160