1 // RUN: %clang_analyze_cc1 \ 2 // RUN: -analyzer-checker=cplusplus.NewDelete,unix.Malloc \ 3 // RUN: -analyzer-config add-pop-up-notes=false \ 4 // RUN: -analyzer-output=text -verify %s 5 // RUN: %clang_analyze_cc1 \ 6 // RUN: -analyzer-checker=cplusplus.NewDelete,unix.Malloc \ 7 // RUN: -analyzer-config add-pop-up-notes=false \ 8 // RUN: -analyzer-output=plist %s -o %t.plist 9 // RUN: %normalize_plist <%t.plist | diff -ub \ 10 // RUN: %S/Inputs/expected-plists/NewDelete-path-notes.cpp.plist - 11 12 void test() { 13 int *p = new int; 14 // expected-note@-1 {{Memory is allocated}} 15 if (p) // expected-note {{Taking true branch}} 16 delete p; 17 // expected-note@-1 {{Memory is released}} 18 19 delete p; // expected-warning {{Attempt to free released memory}} 20 // expected-note@-1 {{Attempt to free released memory}} 21 } 22 23 struct Odd { 24 void kill() { 25 delete this; // expected-note {{Memory is released}} 26 } 27 }; 28 29 void test(Odd *odd) { 30 odd->kill(); // expected-note{{Calling 'Odd::kill'}} 31 // expected-note@-1 {{Returning; memory was released}} 32 delete odd; // expected-warning {{Attempt to free released memory}} 33 // expected-note@-1 {{Attempt to free released memory}} 34 } 35 36