1 // RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.NewDelete -verify %s 2 3 #include "Inputs/system-header-simulator-cxx.h" 4 5 struct S { SS6 S() : Data(new int) {} ~SS7 ~S() { delete Data; } getDataS8 int *getData() { return Data; } 9 10 private: 11 int *Data; 12 }; 13 freeAfterReturnTemp()14int *freeAfterReturnTemp() { 15 return S().getData(); // expected-warning {{Use of memory after it is freed}} 16 } 17 freeAfterReturnLocal()18int *freeAfterReturnLocal() { 19 S X; 20 return X.getData(); // expected-warning {{Use of memory after it is freed}} 21 } 22