[PATCH] D12616: Failing test highlighting no poisoning if dtor undeclared.

Naomi Musgrave via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 3 16:43:55 PDT 2015


nmusgrave created this revision.
nmusgrave added reviewers: eugenis, kcc.
nmusgrave added a subscriber: cfe-commits.

If class or struct has not declared a destructor,
no destsructor is emitted, and members are not poisoned
after destruction. This case highlights bug in current
implementation of use-after-dtor poisoning.

http://reviews.llvm.org/D12616

Files:
  test/CodeGenCXX/sanitize-dtor-generated.cpp

Index: test/CodeGenCXX/sanitize-dtor-generated.cpp
===================================================================
--- /dev/null
+++ test/CodeGenCXX/sanitize-dtor-generated.cpp
@@ -0,0 +1,32 @@
+// Test -fsanitize-memory-use-after-dtor
+// RUN: %clang_cc1 -O0 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-optzns -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-optzns -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+
+// TODO Success pending on resolution of issue 596
+// XFAIL: *
+
+template <class T> class Vector {
+ public:
+  int size;
+  ~Vector() {}
+};
+
+struct NonTrivial {
+  int a;
+  Vector<int> v;
+};
+NonTrivial nt;
+
+struct Trivial {
+  int a;
+  int b;
+};
+Trivial t;
+
+// CHECK-LABEL: define {{.*}}NonTrivialD2Ev
+// CHECK: call void @__sanitizer_dtor_callback
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.*}}TrivialD2Ev
+// CHECK: call void @__sanitizer_dtor_callback
+// CHECK: ret void


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12616.33989.patch
Type: text/x-patch
Size: 1071 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150903/8f98de73/attachment.bin>


More information about the cfe-commits mailing list