[PATCH] D11189: adding tests for various dtor decl types

Naomi Musgrave nmusgrave at google.com
Tue Jul 14 15:01:49 PDT 2015


nmusgrave updated this revision to Diff 29719.
nmusgrave marked an inline comment as done.
nmusgrave added a comment.

- modified tests for instr ordering flexibility


http://reviews.llvm.org/D11189

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

Index: test/CodeGenCXX/sanitize-dtor-callback.cpp
===================================================================
--- test/CodeGenCXX/sanitize-dtor-callback.cpp
+++ test/CodeGenCXX/sanitize-dtor-callback.cpp
@@ -1,6 +1,6 @@
 // Test -fsanitize-memory-use-after-dtor
-// RUN: %clang_cc1 -fsanitize=memory -fsanitize-memory-use-after-dtor -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -fsanitize=memory -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s -check-prefix=NO_DTOR_CHECK
+// RUN: %clang_cc1 -fsanitize=memory -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=memory -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s -check-prefix=NO-DTOR-CHECK
 
 struct Simple {
   ~Simple() {}
@@ -12,6 +12,61 @@
 // CHECK: ret void
 
 // Compiling without the flag does not generate member-poisoning dtor
-// NO_DTOR_CHECK-LABEL: @_ZN6SimpleD2Ev
-// NO_DTOR_CHECK-NOT: call void @sanitizer_dtor_callback
-// NO_DTOR_CHECK: ret void
+// NO-DTOR-CHECK-LABEL: @_ZN6SimpleD2Ev
+// NO-DTOR-CHECK-NOT: call void @__sanitizer_dtor_callback
+// NO-DTOR-CHECK: ret void
+
+
+struct Inlined {
+  inline ~Inlined() {}
+};
+Inlined in;
+// Dtor that is inlined where invoked poisons object
+// CHECK-LABEL: @_ZN7InlinedD2Ev
+// CHECK: call void @__sanitizer_dtor_callback
+// CHECK: ret void
+
+// Compiling without the flag does not generate member-poisoning dtor
+// NO-DTOR-CHECK-LABEL: @_ZN7InlinedD2Ev
+// NO-DTOR-CHECK-NOT: call void @__sanitizer_dtor_callback
+// NO-DTOR-CHECK: ret void
+
+struct Defaulted_Trivial {
+  ~Defaulted_Trivial() = default;
+};
+void create_def_trivial() {
+  Defaulted_Trivial def_trivial;
+}
+// The compiler is explicitly signalled to handle object cleanup.
+// No complex member attributes ensures that the compiler destroys
+// the memory inline.
+// The destructor poisoning does not handle defaulted dtors.
+// CHECK-LABEL: define void @_Z18create_def_trivialv()
+// CHECK-NOT: call void @_[A-Z]+[0-9]+(Defaulted_TrivialD2Ev)
+// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: ret void
+
+// Compiling without the flag does not generate member-poisoning dtor
+// NO-DTOR-CHECK-LABEL: define void @_Z18create_def_trivialv()
+// NO-DTOR-CHECK-NOT: call void @__sanitizer_dtor_callback
+// NO-DTOR-CHECK: ret void
+
+
+struct Defaulted_Non_Trivial {
+  Simple s;
+  ~Defaulted_Non_Trivial() = default;
+};
+Defaulted_Non_Trivial def_non_trivial;
+// Explicitly compiler-generated dtor poisons object.
+// By including a Simple member in the struct, the compiler is
+// forced to generate a non-trivial destructor..
+// CHECK-LABEL: define linkonce_odr void @_ZN21Defaulted_Non_TrivialD2Ev
+// CHECK-DAG: call void @_ZN6SimpleD1Ev
+// CHECK-DAG: call void @__sanitizer_dtor_callback
+// CHECK: ret void
+
+// Compiling without the flag does not generate member-poisoning dtor
+// NO-DTOR-CHECK-LABEL: define linkonce_odr void @_ZN21Defaulted_Non_TrivialD2Ev
+// NO-DTOR-CHECK-DAG: call void @_ZN6SimpleD1Ev
+// NO-DTOR-CHECK-NOT: call void @__sanitizer_dtor_callback
+// NO-DTOR-CHECK: ret void


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11189.29719.patch
Type: text/x-patch
Size: 3174 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150714/45164be7/attachment.bin>


More information about the cfe-commits mailing list