[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Analysis / malloc-free-after-return.cpp
blobcebd79a1a15e034f6710d7f2bfe6668befb6b6bd
1 // RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.NewDelete -verify %s
3 #include "Inputs/system-header-simulator-cxx.h"
5 struct S {
6 S() : Data(new int) {}
7 ~S() { delete Data; }
8 int *getData() { return Data; }
10 private:
11 int *Data;
14 int *freeAfterReturnTemp() {
15 return S().getData(); // expected-warning {{Use of memory after it is freed}}
18 int *freeAfterReturnLocal() {
19 S X;
20 return X.getData(); // expected-warning {{Use of memory after it is freed}}