Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Analysis / symbol-escape.cpp
blobbe5dfbcd9ef588366983124a16ade0625fd2bc41
1 // RUN: %clang_analyze_cc1 \
2 // RUN: -analyzer-checker=core,cplusplus.NewDeleteLeaks \
3 // RUN: -verify %s
5 // expected-no-diagnostics: Whenever we cannot evaluate an operation we escape
6 // the operands. After the evaluation it would be an
7 // Unknown value and the tracking would be lost.
9 typedef unsigned __INTPTR_TYPE__ uintptr_t;
11 class C {};
13 C *simple_escape_in_bitwise_op(C *Foo) {
14 C *Bar = new C();
15 Bar = reinterpret_cast<C *>(reinterpret_cast<uintptr_t>(Bar) & 0x1);
16 (void)Bar;
17 // no-warning: "Potential leak of memory pointed to by 'Bar'" was here.
19 return Bar;
22 C **indirect_escape_in_bitwise_op() {
23 C *Qux = new C();
24 C **Baz = &Qux;
25 Baz = reinterpret_cast<C **>(reinterpret_cast<uintptr_t>(Baz) | 0x1);
26 Baz = reinterpret_cast<C **>(reinterpret_cast<uintptr_t>(Baz) &
27 ~static_cast<uintptr_t>(0x1));
28 // no-warning: "Potential leak of memory pointed to by 'Qux'" was here.
30 delete *Baz;
31 return Baz;