diff options
author | Artem Dergachev <artem.dergachev@gmail.com> | 2018-01-17 23:46:13 +0000 |
---|---|---|
committer | Artem Dergachev <artem.dergachev@gmail.com> | 2018-01-17 23:46:13 +0000 |
commit | 13b2026ba46eb2b439cb8074e2f8ccc5473ec51d (patch) | |
tree | 2df7455d003dd3868bac74fb075a87313a391971 /clang/test/Analysis/NewDelete-custom.cpp | |
parent | edae5a6e11308852af43115da0a81533ca7ef3a6 (diff) | |
download | bcm5719-llvm-13b2026ba46eb2b439cb8074e2f8ccc5473ec51d.tar.gz bcm5719-llvm-13b2026ba46eb2b439cb8074e2f8ccc5473ec51d.zip |
[analyzer] operator new: Add a new checker callback, check::NewAllocator.
The callback runs after operator new() and before the construction and allows
the checker to access the casted return value of operator new() (in the
sense of r322780) which is not available in the PostCall callback for the
allocator call.
Update MallocChecker to use the new callback instead of PostStmt<CXXNewExpr>,
which gets called after the constructor.
Differential Revision: https://reviews.llvm.org/D41406
rdar://problem/12180598
llvm-svn: 322787
Diffstat (limited to 'clang/test/Analysis/NewDelete-custom.cpp')
-rw-r--r-- | clang/test/Analysis/NewDelete-custom.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/clang/test/Analysis/NewDelete-custom.cpp b/clang/test/Analysis/NewDelete-custom.cpp index f06ff4a858e..4600f80576b 100644 --- a/clang/test/Analysis/NewDelete-custom.cpp +++ b/clang/test/Analysis/NewDelete-custom.cpp @@ -1,8 +1,10 @@ // RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,unix.Malloc -std=c++11 -fblocks -verify %s -// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -DLEAKS -fblocks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -DLEAKS=1 -fblocks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,unix.Malloc -std=c++11 -analyzer-config c++-allocator-inlining=true -DALLOCATOR_INLINING=1 -fblocks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -analyzer-config c++-allocator-inlining=true -DLEAKS=1 -DALLOCATOR_INLINING=1 -fblocks -verify %s #include "Inputs/system-header-simulator-cxx.h" -#ifndef LEAKS +#if !LEAKS // expected-no-diagnostics #endif @@ -26,7 +28,7 @@ void testNewMethod() { C *c3 = ::new C; } -#ifdef LEAKS +#if LEAKS && !ALLOCATOR_INLINING // expected-warning@-2{{Potential leak of memory pointed to by 'c3'}} #endif @@ -37,7 +39,7 @@ void testOpNewArray() { void testNewExprArray() { int *p = new int[0]; } -#ifdef LEAKS +#if LEAKS && !ALLOCATOR_INLINING // expected-warning@-2{{Potential leak of memory pointed to by 'p'}} #endif @@ -50,7 +52,7 @@ void testOpNew() { void testNewExpr() { int *p = new int; } -#ifdef LEAKS +#if LEAKS && !ALLOCATOR_INLINING // expected-warning@-2{{Potential leak of memory pointed to by 'p'}} #endif @@ -59,21 +61,21 @@ void testNewExpr() { void testOpNewNoThrow() { void *p = operator new(0, std::nothrow); } -#ifdef LEAKS +#if LEAKS // expected-warning@-2{{Potential leak of memory pointed to by 'p'}} #endif void testNewExprNoThrow() { int *p = new(std::nothrow) int; } -#ifdef LEAKS +#if LEAKS // expected-warning@-2{{Potential leak of memory pointed to by 'p'}} #endif //----- Custom placement operators void testOpNewPlacement() { void *p = operator new(0, 0.1); // no warn -} +} void testNewExprPlacement() { int *p = new(0.1) int; // no warn |