Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / sanitize-dtor-derived-class.cpp
blobe3d83a9d06a598fe907020480de5f193c939e42f
1 // RUN: %clang_cc1 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-passes -std=c++11 -triple=x86_64-pc-linux -emit-llvm -debug-info-kind=line-tables-only -o - %s | FileCheck %s --implicit-check-not="call void @__sanitizer_"
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 -debug-info-kind=line-tables-only -o - %s | FileCheck %s --implicit-check-not="call void @__sanitizer_"
4 // Base dtor poisons members
5 // Complete dtor poisons vtable ptr after destroying members and
6 // virtual bases
8 class Base {
9 public:
10 int x;
11 Base() {
12 x = 5;
14 virtual ~Base() {
15 x += 1;
19 class Derived : public Base {
20 public:
21 int y;
22 Derived() {
23 y = 10;
25 ~Derived() {
26 y += 1;
30 Derived d;
32 // Invoke base destructor. No vtable pointer to poison.
33 // CHECK-LABEL: define {{.*}}DerivedD1Ev
34 // CHECK: call void {{.*}}DerivedD2Ev
35 // CHECK: ret void
37 // CHECK-LABEL: define {{.*}}DerivedD0Ev
38 // CHECK: call void {{.*}}DerivedD1Ev
39 // CHECK: ret void
41 // Invokes base destructor, and poison vtable pointer.
42 // CHECK-LABEL: define {{.*}}BaseD1Ev
43 // CHECK: call void {{.*}}BaseD2Ev
44 // CHECK: ret void
46 // CHECK-LABEL: define {{.*}}BaseD0Ev
47 // CHECK: call void {{.*}}BaseD1Ev
48 // CHECK: ret void
50 // Poison members and vtable ptr.
51 // CHECK-LABEL: define {{.*}}BaseD2Ev
52 // CHECK: call void @__sanitizer_dtor_callback_fields({{.*}}, !dbg ![[DI1:[0-9]+]]
53 // CHECK: call void @__sanitizer_dtor_callback_vptr({{.*}}){{.*}}, !dbg ![[DI2:[0-9]+]]
54 // CHECK: ret void
56 // Poison members and destroy non-virtual base.
57 // CHECK-LABEL: define {{.*}}DerivedD2Ev
58 // CHECK: call void @__sanitizer_dtor_callback_fields({{.*}}, !dbg ![[DI3:[0-9]+]]
59 // CHECK: call void {{.*}}BaseD2Ev
60 // CHECK: call void @__sanitizer_dtor_callback_vptr({{.*}}){{.*}}, !dbg ![[DI4:[0-9]+]]
61 // CHECK: ret void
63 // CHECK-LABEL: !DIFile{{.*}}cpp
65 // CHECK-DAG: ![[DI1]] = {{.*}}line: [[@LINE-55]]
66 // CHECK-DAG: ![[DI2]] = {{.*}}line: [[@LINE-50]]
67 // CHECK-DAG: ![[DI3]] = {{.*}}line: [[@LINE-46]]
68 // CHECK-DAG: ![[DI4]] = {{.*}}line: [[@LINE-41]]