diff options
Diffstat (limited to 'test/Analysis/NewDelete-custom.cpp')
-rw-r--r-- | test/Analysis/NewDelete-custom.cpp | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/test/Analysis/NewDelete-custom.cpp b/test/Analysis/NewDelete-custom.cpp index 7d7796b..c64bfce 100644 --- a/test/Analysis/NewDelete-custom.cpp +++ b/test/Analysis/NewDelete-custom.cpp @@ -1,6 +1,12 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.cplusplus.NewDelete,unix.Malloc -analyzer-store region -std=c++11 -fblocks -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,unix.Malloc -std=c++11 -fblocks -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -DLEAKS -fblocks -verify %s #include "Inputs/system-header-simulator-cxx.h" +#ifndef LEAKS +// expected-no-diagnostics +#endif + + void *allocator(std::size_t size); void *operator new[](std::size_t size) throw() { return allocator(size); } @@ -19,7 +25,10 @@ void testNewMethod() { C *p2 = new C; // no warn C *c3 = ::new C; -} // expected-warning{{Memory is never released; potential leak}} +} +#ifdef LEAKS +// expected-warning@-2{{Potential leak of memory pointed to by 'c3'}} +#endif void testOpNewArray() { void *p = operator new[](0); // call is inlined, no warn @@ -27,7 +36,11 @@ void testOpNewArray() { void testNewExprArray() { int *p = new int[0]; -} // expected-warning{{Memory is never released; potential leak}} +} +#ifdef LEAKS +// expected-warning@-2{{Potential leak of memory pointed to by 'p'}} +#endif + //----- Custom non-placement operators void testOpNew() { @@ -36,16 +49,26 @@ void testOpNew() { void testNewExpr() { int *p = new int; -} // expected-warning{{Memory is never released; potential leak}} +} +#ifdef LEAKS +// expected-warning@-2{{Potential leak of memory pointed to by 'p'}} +#endif + //----- Custom NoThrow placement operators void testOpNewNoThrow() { void *p = operator new(0, std::nothrow); -} // expected-warning{{Memory is never released; potential leak}} +} +#ifdef LEAKS +// expected-warning@-2{{Potential leak of memory pointed to by 'p'}} +#endif void testNewExprNoThrow() { int *p = new(std::nothrow) int; -} // expected-warning{{Memory is never released; potential leak}} +} +#ifdef LEAKS +// expected-warning@-2{{Potential leak of memory pointed to by 'p'}} +#endif //----- Custom placement operators void testOpNewPlacement() { |