Charusso created this revision.
Charusso added reviewers: NoQ, xazax.hun, ravikandhadai, baloghadamsoftware,
Szelethus.
Charusso added a project: clang.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, mikhail.ramalho,
a.sidorin, rnkovacs, szepet.
After evaluation it would be an Unknown value and tracking would be lost.
Repository:
rC Clang
https://reviews.llvm.org/D63720
Files:
clang/test/Analysis/symbol-escape.cpp
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 <stdint.h>
+
+class C {};
+
+void payload(C *Foo) {
+ C *Bar = new C();
+ Bar = reinterpret_cast<C *>((reinterpret_cast<uintptr_t>(Foo) &
+ ~static_cast<uintptr_t>(0x1)) |
+ (reinterpret_cast<uintptr_t>(Bar) & 0x1));
+ (void)Bar;
+ // expected-warning@-1 {{Potential leak of memory pointed to by 'Bar'}}
+
+ delete Bar;
+}
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 <stdint.h>
+
+class C {};
+
+void payload(C *Foo) {
+ C *Bar = new C();
+ Bar = reinterpret_cast<C *>((reinterpret_cast<uintptr_t>(Foo) &
+ ~static_cast<uintptr_t>(0x1)) |
+ (reinterpret_cast<uintptr_t>(Bar) & 0x1));
+ (void)Bar;
+ // expected-warning@-1 {{Potential leak of memory pointed to by 'Bar'}}
+
+ delete Bar;
+}
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits