2017-03-04 02:02:02 +08:00
|
|
|
// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.MismatchedDeallocator -analyzer-output=text -verify %s
|
2018-06-13 03:07:41 +08:00
|
|
|
// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.MismatchedDeallocator -analyzer-output=plist %s -o %t.plist
|
2019-06-11 22:21:32 +08:00
|
|
|
// RUN: tail -n +11 %t.plist | %normalize_plist | diff -ub %S/copypaste/Inputs/expected-plists/MismatchedDeallocator-path-notes.cpp.plist -
|
2013-04-05 19:25:10 +08:00
|
|
|
|
2013-04-09 08:30:28 +08:00
|
|
|
void changePointee(int *p);
|
2015-05-19 03:59:11 +08:00
|
|
|
int *allocIntArray(unsigned c) {
|
|
|
|
return new int[c]; // expected-note {{Memory is allocated}}
|
|
|
|
}
|
2013-04-05 19:25:10 +08:00
|
|
|
void test() {
|
2015-05-19 03:59:11 +08:00
|
|
|
int *p = allocIntArray(1); // expected-note {{Calling 'allocIntArray'}}
|
|
|
|
// expected-note@-1 {{Returned allocated memory}}
|
2013-04-09 08:30:28 +08:00
|
|
|
changePointee(p);
|
2013-04-05 19:25:10 +08:00
|
|
|
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'}}
|
|
|
|
}
|