diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Analysis/NewDeleteLeaks-checker-test.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/Analysis/NewDeleteLeaks-checker-test.cpp b/test/Analysis/NewDeleteLeaks-checker-test.cpp new file mode 100644 index 0000000000..93707ec190 --- /dev/null +++ b/test/Analysis/NewDeleteLeaks-checker-test.cpp @@ -0,0 +1,28 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.cplusplus.NewDeleteLeaks -std=c++11 -fblocks -verify %s +#include "Inputs/system-header-simulator-cxx.h" + +//----- Standard non-placement operators +void testGlobalOpNew() { + void *p = operator new(0); +} // expected-warning{{Potential leak of memory pointed to by 'p'}} + +void testGlobalOpNewArray() { + void *p = operator new[](0); +} // expected-warning{{Potential leak of memory pointed to by 'p'}} + +void testGlobalNewExpr() { + int *p = new int; +} // expected-warning{{Potential leak of memory pointed to by 'p'}} + +void testGlobalNewExprArray() { + int *p = new int[0]; +} // expected-warning{{Potential leak of memory pointed to by 'p'}} + +//----- Standard nothrow placement operators +void testGlobalNoThrowPlacementOpNewBeforeOverload() { + void *p = operator new(0, std::nothrow); +} // expected-warning{{Potential leak of memory pointed to by 'p'}} + +void testGlobalNoThrowPlacementExprNewBeforeOverload() { + int *p = new(std::nothrow) int; +} // expected-warning{{Potential leak of memory pointed to by 'p'}} |