diff options
author | Naomi Musgrave <nmusgrave@google.com> | 2015-09-16 00:38:22 +0000 |
---|---|---|
committer | Naomi Musgrave <nmusgrave@google.com> | 2015-09-16 00:38:22 +0000 |
commit | de170619af325aae89f95762ac512feff798d396 (patch) | |
tree | d81bd3c320813e815df6ab7057d520bf82d04b8f /test/CodeGenCXX/sanitize-dtor-derived-class.cpp | |
parent | 45a70593b1a6ce551549ea0d6f3dc9babf4be9b9 (diff) |
Implementation and testing for poisoning vtable
ptr in dtor.
Summary:
After destruction, invocation of virtual functions prevented
by poisoning vtable pointer.
Reviewers: eugenis, kcc
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D12712
Fixed testing callback emission order to account for vptr.
Poison vtable in either complete or base dtor, depending on
if virtual bases exist. If virtual bases exist, poison in
complete dtor. Otherwise, poison in base.
Remove commented-out block.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247762 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/sanitize-dtor-derived-class.cpp')
-rw-r--r-- | test/CodeGenCXX/sanitize-dtor-derived-class.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/test/CodeGenCXX/sanitize-dtor-derived-class.cpp b/test/CodeGenCXX/sanitize-dtor-derived-class.cpp index 723a504dd7..f313471182 100644 --- a/test/CodeGenCXX/sanitize-dtor-derived-class.cpp +++ b/test/CodeGenCXX/sanitize-dtor-derived-class.cpp @@ -1,8 +1,9 @@ // RUN: %clang_cc1 -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 -// Only the last dtor of a class invokes the sanitizing callback -// Sanitizing callback emited prior to base class dtor invocations +// Base dtor poisons members +// Complete dtor poisons vtable ptr after destroying members and +// virtual bases class Base { public: @@ -28,6 +29,7 @@ class Derived : public Base { Derived d; +// Invoke base destructor. No vtable pointer to poison. // CHECK-LABEL: define {{.*}}DerivedD1Ev // CHECK-NOT: call void @__sanitizer_dtor_callback // CHECK: call void {{.*}}DerivedD2Ev @@ -40,6 +42,7 @@ Derived d; // CHECK-NOT: call void @__sanitizer_dtor_callback // CHECK: ret void +// Invokes base destructor, and poison vtable pointer. // CHECK-LABEL: define {{.*}}BaseD1Ev // CHECK-NOT: call void @__sanitizer_dtor_callback // CHECK: call void {{.*}}BaseD2Ev @@ -52,14 +55,17 @@ Derived d; // CHECK-NOT: call void @__sanitizer_dtor_callback // CHECK: ret void +// Poison members and vtable ptr. // CHECK-LABEL: define {{.*}}BaseD2Ev // CHECK: call void @__sanitizer_dtor_callback +// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8 // CHECK-NOT: call void @__sanitizer_dtor_callback // CHECK: ret void +// Poison members and destroy non-virtual base. // CHECK-LABEL: define {{.*}}DerivedD2Ev // CHECK: call void @__sanitizer_dtor_callback // CHECK-NOT: call void @__sanitizer_dtor_callback // CHECK: call void {{.*}}BaseD2Ev -// CHECK-NOT: call void @__sanitizer_dtor_callback +// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8 // CHECK: ret void |