[PATCH] D11189: adding tests for various dtor decl types
Naomi Musgrave
nmusgrave at google.com
Tue Jul 14 18:04:04 PDT 2015
nmusgrave updated this revision to Diff 29739.
nmusgrave added a comment.
- refactored to cope with llvm language ordering issues
http://reviews.llvm.org/D11189
Files:
test/CodeGenCXX/sanitize-default-dtor-callback.cpp
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,17 +1,32 @@
// 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() {}
};
Simple s;
// Simple internal member is poisoned by compiler-generated dtor
-// CHECK-LABEL: @_ZN6SimpleD2Ev
+// CHECK-LABEL: define {{.*}}SimpleD2Ev
// CHECK: call void @__sanitizer_dtor_callback
// 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: define {{.*}}SimpleD2Ev
+// 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: define {{.*}}InlinedD2Ev
+// CHECK: call void @__sanitizer_dtor_callback
+// CHECK: ret void
+
+// Compiling without the flag does not generate member-poisoning dtor
+// NO-DTOR-CHECK-LABEL: define {{.*}}InlinedD2Ev
+// NO-DTOR-CHECK-NOT: call void @__sanitizer_dtor_callback
+// NO-DTOR-CHECK: ret void
Index: test/CodeGenCXX/sanitize-default-dtor-callback.cpp
===================================================================
--- /dev/null
+++ test/CodeGenCXX/sanitize-default-dtor-callback.cpp
@@ -0,0 +1,49 @@
+// Test -fsanitize-memory-use-after-dtor
+// 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 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 {{.*}}create_def_trivial
+// 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 {{.*}}create_def_trivial
+// NO-DTOR-CHECK-NOT: call void @__sanitizer_dtor_callback
+// NO-DTOR-CHECK: ret void
+
+
+struct Simple {
+ ~Simple() {}
+};
+struct Defaulted_Non_Trivial {
+ Simple s;
+ ~Defaulted_Non_Trivial() = default;
+};
+void create_def_non_trivial() {
+ 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. Members at this level
+// should be poisoned before base class members.
+// CHECK-LABEL: define {{.*}}Defaulted_Non_TrivialD2Ev
+// CHECK: call void @__sanitizer_dtor_callback
+// CHECK: call void {{.*}}SimpleD2Ev
+// CHECK: ret void
+
+// Compiling without the flag does not generate member-poisoning dtor
+// NO-DTOR-CHECK-LABEL: define {{.*}}Defaulted_Non_TrivialD2Ev
+// NO-DTOR-CHECK: call {{.*}}SimpleD2Ev
+// NO-DTOR-CHECK-NOT: call void @__sanitizer_dtor_callback
+// NO-DTOR-CHECK: ret void
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11189.29739.patch
Type: text/x-patch
Size: 3933 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150715/d4baa7b0/attachment.bin>
More information about the cfe-commits
mailing list