
Changed the warning message: - **From**: 'Attempt to free released memory' **To**: 'Attempt to release already released memory' - **From**: 'Attempt to free non-owned memory' **To**: 'Attempt to release non-owned memory' - **From**: 'Use of memory after it is freed' **To**: 'Use of memory after it is released' All connected tests and their expectations have been changed accordingly. Inspired by [this PR](https://github.com/llvm/llvm-project/pull/147542#discussion_r2195197922)
22 lines
482 B
C++
22 lines
482 B
C++
// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.NewDelete -verify %s
|
|
|
|
#include "Inputs/system-header-simulator-cxx.h"
|
|
|
|
struct S {
|
|
S() : Data(new int) {}
|
|
~S() { delete Data; }
|
|
int *getData() { return Data; }
|
|
|
|
private:
|
|
int *Data;
|
|
};
|
|
|
|
int *freeAfterReturnTemp() {
|
|
return S().getData(); // expected-warning {{Use of memory after it is released}}
|
|
}
|
|
|
|
int *freeAfterReturnLocal() {
|
|
S X;
|
|
return X.getData(); // expected-warning {{Use of memory after it is released}}
|
|
}
|