f4a2713ac8
Change-Id: Ia40e9ffdf29b5dab2f122f673ff6802a58bc690f
159 lines
7 KiB
C++
159 lines
7 KiB
C++
// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.MismatchedDeallocator -analyzer-output=text -verify %s
|
|
// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.MismatchedDeallocator -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false %s -o %t.plist
|
|
// RUN: FileCheck --input-file=%t.plist %s
|
|
|
|
void changePointee(int *p);
|
|
void test() {
|
|
int *p = new int[1];
|
|
// expected-note@-1 {{Memory is allocated}}
|
|
changePointee(p);
|
|
delete p; // expected-warning {{Memory allocated by 'new[]' should be deallocated by 'delete[]', not 'delete'}}
|
|
// expected-note@-1 {{Memory allocated by 'new[]' should be deallocated by 'delete[]', not 'delete'}}
|
|
}
|
|
|
|
// CHECK: <key>diagnostics</key>
|
|
// CHECK-NEXT: <array>
|
|
// CHECK-NEXT: <dict>
|
|
// CHECK-NEXT: <key>path</key>
|
|
// CHECK-NEXT: <array>
|
|
// CHECK-NEXT: <dict>
|
|
// CHECK-NEXT: <key>kind</key><string>control</string>
|
|
// CHECK-NEXT: <key>edges</key>
|
|
// CHECK-NEXT: <array>
|
|
// CHECK-NEXT: <dict>
|
|
// CHECK-NEXT: <key>start</key>
|
|
// CHECK-NEXT: <array>
|
|
// CHECK-NEXT: <dict>
|
|
// CHECK-NEXT: <key>line</key><integer>7</integer>
|
|
// CHECK-NEXT: <key>col</key><integer>3</integer>
|
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: <dict>
|
|
// CHECK-NEXT: <key>line</key><integer>7</integer>
|
|
// CHECK-NEXT: <key>col</key><integer>5</integer>
|
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: </array>
|
|
// CHECK-NEXT: <key>end</key>
|
|
// CHECK-NEXT: <array>
|
|
// CHECK-NEXT: <dict>
|
|
// CHECK-NEXT: <key>line</key><integer>7</integer>
|
|
// CHECK-NEXT: <key>col</key><integer>12</integer>
|
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: <dict>
|
|
// CHECK-NEXT: <key>line</key><integer>7</integer>
|
|
// CHECK-NEXT: <key>col</key><integer>14</integer>
|
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: </array>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: </array>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: <dict>
|
|
// CHECK-NEXT: <key>kind</key><string>event</string>
|
|
// CHECK-NEXT: <key>location</key>
|
|
// CHECK-NEXT: <dict>
|
|
// CHECK-NEXT: <key>line</key><integer>7</integer>
|
|
// CHECK-NEXT: <key>col</key><integer>12</integer>
|
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: <key>ranges</key>
|
|
// CHECK-NEXT: <array>
|
|
// CHECK-NEXT: <array>
|
|
// CHECK-NEXT: <dict>
|
|
// CHECK-NEXT: <key>line</key><integer>7</integer>
|
|
// CHECK-NEXT: <key>col</key><integer>12</integer>
|
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: <dict>
|
|
// CHECK-NEXT: <key>line</key><integer>7</integer>
|
|
// CHECK-NEXT: <key>col</key><integer>21</integer>
|
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: </array>
|
|
// CHECK-NEXT: </array>
|
|
// CHECK-NEXT: <key>depth</key><integer>0</integer>
|
|
// CHECK-NEXT: <key>extended_message</key>
|
|
// CHECK-NEXT: <string>Memory is allocated</string>
|
|
// CHECK-NEXT: <key>message</key>
|
|
// CHECK-NEXT: <string>Memory is allocated</string>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: <dict>
|
|
// CHECK-NEXT: <key>kind</key><string>control</string>
|
|
// CHECK-NEXT: <key>edges</key>
|
|
// CHECK-NEXT: <array>
|
|
// CHECK-NEXT: <dict>
|
|
// CHECK-NEXT: <key>start</key>
|
|
// CHECK-NEXT: <array>
|
|
// CHECK-NEXT: <dict>
|
|
// CHECK-NEXT: <key>line</key><integer>7</integer>
|
|
// CHECK-NEXT: <key>col</key><integer>12</integer>
|
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: <dict>
|
|
// CHECK-NEXT: <key>line</key><integer>7</integer>
|
|
// CHECK-NEXT: <key>col</key><integer>14</integer>
|
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: </array>
|
|
// CHECK-NEXT: <key>end</key>
|
|
// CHECK-NEXT: <array>
|
|
// CHECK-NEXT: <dict>
|
|
// CHECK-NEXT: <key>line</key><integer>10</integer>
|
|
// CHECK-NEXT: <key>col</key><integer>3</integer>
|
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: <dict>
|
|
// CHECK-NEXT: <key>line</key><integer>10</integer>
|
|
// CHECK-NEXT: <key>col</key><integer>8</integer>
|
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: </array>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: </array>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: <dict>
|
|
// CHECK-NEXT: <key>kind</key><string>event</string>
|
|
// CHECK-NEXT: <key>location</key>
|
|
// CHECK-NEXT: <dict>
|
|
// CHECK-NEXT: <key>line</key><integer>10</integer>
|
|
// CHECK-NEXT: <key>col</key><integer>3</integer>
|
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: <key>ranges</key>
|
|
// CHECK-NEXT: <array>
|
|
// CHECK-NEXT: <array>
|
|
// CHECK-NEXT: <dict>
|
|
// CHECK-NEXT: <key>line</key><integer>10</integer>
|
|
// CHECK-NEXT: <key>col</key><integer>10</integer>
|
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: <dict>
|
|
// CHECK-NEXT: <key>line</key><integer>10</integer>
|
|
// CHECK-NEXT: <key>col</key><integer>10</integer>
|
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: </array>
|
|
// CHECK-NEXT: </array>
|
|
// CHECK-NEXT: <key>depth</key><integer>0</integer>
|
|
// CHECK-NEXT: <key>extended_message</key>
|
|
// CHECK-NEXT: <string>Memory allocated by 'new[]' should be deallocated by 'delete[]', not 'delete'</string>
|
|
// CHECK-NEXT: <key>message</key>
|
|
// CHECK-NEXT: <string>Memory allocated by 'new[]' should be deallocated by 'delete[]', not 'delete'</string>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: </array>
|
|
// CHECK-NEXT: <key>description</key><string>Memory allocated by 'new[]' should be deallocated by 'delete[]', not 'delete'</string>
|
|
// CHECK-NEXT: <key>category</key><string>Memory Error</string>
|
|
// CHECK-NEXT: <key>type</key><string>Bad deallocator</string>
|
|
// CHECK-NEXT: <key>issue_context_kind</key><string>function</string>
|
|
// CHECK-NEXT: <key>issue_context</key><string>test</string>
|
|
// CHECK-NEXT: <key>issue_hash</key><string>4</string>
|
|
// CHECK-NEXT: <key>location</key>
|
|
// CHECK-NEXT: <dict>
|
|
// CHECK-NEXT: <key>line</key><integer>10</integer>
|
|
// CHECK-NEXT: <key>col</key><integer>3</integer>
|
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: </array>
|