summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/sanitize-dtor-callback.cpp
diff options
context:
space:
mode:
authorNaomi Musgrave <nmusgrave@google.com>2015-07-15 22:57:10 +0000
committerNaomi Musgrave <nmusgrave@google.com>2015-07-15 22:57:10 +0000
commit483d84650a0276d0c755671c19817f389d1e83e7 (patch)
treeb3b4e510c724f4bc80cce93d70db5647c84fab1b /test/CodeGenCXX/sanitize-dtor-callback.cpp
parent72f70c7fd13ddc8572e895d5f41453fddbc9683f (diff)
adding tests for various dtor decl types
Reviewers: eugenis, kcc Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D11189 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242351 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/sanitize-dtor-callback.cpp')
-rw-r--r--test/CodeGenCXX/sanitize-dtor-callback.cpp63
1 files changed, 59 insertions, 4 deletions
diff --git a/test/CodeGenCXX/sanitize-dtor-callback.cpp b/test/CodeGenCXX/sanitize-dtor-callback.cpp
index 4912a27229..233561e4e0 100644
--- a/test/CodeGenCXX/sanitize-dtor-callback.cpp
+++ b/test/CodeGenCXX/sanitize-dtor-callback.cpp
@@ -1,6 +1,9 @@
// 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 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s -check-prefix=NO-DTOR-CHECK
+
+// RUN: %clang_cc1 -std=c++11 -fsanitize=memory -fsanitize-memory-use-after-dtor -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s -check-prefix=STD11
+// RUN: %clang_cc1 -std=c++11 -fsanitize=memory -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s -check-prefix=NO-DTOR-STD11-CHECK
struct Simple {
~Simple() {}
@@ -12,6 +15,58 @@ Simple s;
// 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;
+};
+int main() {
+ 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. However, it must still poison this memory.
+// STD11-CHECK-LABEL: alloca %struct.Defaulted_Trivial
+// STD11: call void @__sanitizer_dtor_callback
+// STD11: ret void
+
+// Compiling without the flag does not generate member-poisoning dtor
+// NO-DTOR-STD11-CHECK-LABEL: alloca %struct.Defaulted_Trivial
+// NO-DTOR-STD11-CHECK-NOT: call void @__sanitizer_dtor_callback
+// NO-DTOR-STD11-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..
+// STD11-CHECK-LABEL: @_ZN21Defaulted_Non_TrivialD2Ev
+// STD11: call void @__sanitizer_dtor_callback
+// STD11: ret void
+
+// Compiling without the flag does not generate member-poisoning dtor
+// NO-DTOR-STD11-CHECK-LABEL: @_ZN21Defaulted_Non_TrivialD2Ev
+// NO-DTOR-STD11-CHECK-NOT: call void @__sanitizer_dtor_callback
+// NO-DTOR-STD11-CHECK: ret void