]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Analysis/MismatchedDeallocator-path-notes.cpp
Vendor import of clang trunk r351319 (just before the release_80 branch
[FreeBSD/FreeBSD.git] / test / Analysis / MismatchedDeallocator-path-notes.cpp
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.MismatchedDeallocator -analyzer-output=text -verify %s
2 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.MismatchedDeallocator -analyzer-output=plist %s -o %t.plist
3 // RUN: tail -n +11 %t.plist | diff -u -w -I "<string>/" -I "<string>.:" -I "version" - %S/copypaste/Inputs/expected-plists/MismatchedDeallocator-path-notes.cpp.plist
4
5 void changePointee(int *p);
6 int *allocIntArray(unsigned c) {
7   return new int[c]; // expected-note {{Memory is allocated}}
8 }
9 void test() {
10   int *p = allocIntArray(1); // expected-note {{Calling 'allocIntArray'}}
11   // expected-note@-1 {{Returned allocated memory}}
12   changePointee(p);
13   delete p; // expected-warning {{Memory allocated by 'new[]' should be deallocated by 'delete[]', not 'delete'}}
14   // expected-note@-1 {{Memory allocated by 'new[]' should be deallocated by 'delete[]', not 'delete'}}
15 }