150
|
1 // RUN: %clang_cc1 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-passes -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
|
|
2 // RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-passes -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
|
|
3
|
|
4 // Base dtor poisons members
|
|
5 // Complete dtor poisons vtable ptr after destroying members and
|
|
6 // virtual bases
|
|
7
|
|
8 class Base {
|
|
9 public:
|
|
10 int x;
|
|
11 Base() {
|
|
12 x = 5;
|
|
13 }
|
|
14 virtual ~Base() {
|
|
15 x += 1;
|
|
16 }
|
|
17 };
|
|
18
|
|
19 class Derived : public Base {
|
|
20 public:
|
|
21 int y;
|
|
22 Derived() {
|
|
23 y = 10;
|
|
24 }
|
|
25 ~Derived() {
|
|
26 y += 1;
|
|
27 }
|
|
28 };
|
|
29
|
|
30 Derived d;
|
|
31
|
|
32 // Invoke base destructor. No vtable pointer to poison.
|
|
33 // CHECK-LABEL: define {{.*}}DerivedD1Ev
|
|
34 // CHECK-NOT: call void @__sanitizer_dtor_callback
|
|
35 // CHECK: call void {{.*}}DerivedD2Ev
|
|
36 // CHECK-NOT: call void @__sanitizer_dtor_callback
|
|
37 // CHECK: ret void
|
|
38
|
|
39 // CHECK-LABEL: define {{.*}}DerivedD0Ev
|
|
40 // CHECK-NOT: call void @__sanitizer_dtor_callback
|
|
41 // CHECK: call void {{.*}}DerivedD1Ev
|
|
42 // CHECK-NOT: call void @__sanitizer_dtor_callback
|
|
43 // CHECK: ret void
|
|
44
|
|
45 // Invokes base destructor, and poison vtable pointer.
|
|
46 // CHECK-LABEL: define {{.*}}BaseD1Ev
|
|
47 // CHECK-NOT: call void @__sanitizer_dtor_callback
|
|
48 // CHECK: call void {{.*}}BaseD2Ev
|
|
49 // CHECK-NOT: call void @__sanitizer_dtor_callback
|
|
50 // CHECK: ret void
|
|
51
|
|
52 // CHECK-LABEL: define {{.*}}BaseD0Ev
|
|
53 // CHECK-NOT: call void @__sanitizer_dtor_callback
|
|
54 // CHECK: call void {{.*}}BaseD1Ev
|
|
55 // CHECK-NOT: call void @__sanitizer_dtor_callback
|
|
56 // CHECK: ret void
|
|
57
|
|
58 // Poison members and vtable ptr.
|
|
59 // CHECK-LABEL: define {{.*}}BaseD2Ev
|
|
60 // CHECK: call void @__sanitizer_dtor_callback
|
|
61 // CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8
|
|
62 // CHECK-NOT: call void @__sanitizer_dtor_callback
|
|
63 // CHECK: ret void
|
|
64
|
|
65 // Poison members and destroy non-virtual base.
|
|
66 // CHECK-LABEL: define {{.*}}DerivedD2Ev
|
|
67 // CHECK: call void @__sanitizer_dtor_callback
|
|
68 // CHECK-NOT: call void @__sanitizer_dtor_callback
|
|
69 // CHECK: call void {{.*}}BaseD2Ev
|
|
70 // CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8
|
|
71 // CHECK: ret void
|