Index: clang/test/Analysis/symbol-escape.cpp =================================================================== --- /dev/null +++ clang/test/Analysis/symbol-escape.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_analyze_cc1 \ +// RUN: -analyzer-checker=cplusplus.NewDeleteLeaks \ +// RUN: -verify %s + +#include + +class C {}; + +void payload(C *Foo) { + C *Bar = new C(); + Bar = reinterpret_cast((reinterpret_cast(Foo) & + ~static_cast(0x1)) | + (reinterpret_cast(Bar) & 0x1)); + (void)Bar; + // expected-warning@-1 {{Potential leak of memory pointed to by 'Bar'}} + + delete Bar; +}