brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 852632f Raw
36 lines · cpp
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 %s5// 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.plist9// RUN: %normalize_plist <%t.plist | diff -ub \10// RUN:   %S/Inputs/expected-plists/NewDelete-path-notes.cpp.plist -11 12void 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 release already released memory}}20  // expected-note@-1 {{Attempt to release already released memory}}21}22 23struct Odd {24	void kill() {25		delete this; // expected-note {{Memory is released}}26	}27};28 29void 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 release already released memory}}33              // expected-note@-1 {{Attempt to release already released memory}}34}35 36