xref: /llvm-project/clang/test/CodeGenCXX/sanitize-dtor-trivial-base.cpp (revision 1b9a6e58a8b831193c9e5e733f881aabe0d2d06b)
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_"
3 
4 // Base class has trivial dtor => complete dtor poisons base class memory directly.
5 
6 class Base {
7 public:
8   int x[4];
9 };
10 
11 class Derived : public Base {
12 public:
13   int y;
~Derived()14   ~Derived() {
15   }
16 };
17 
18 Derived d;
19 
20 // Poison members, then poison the trivial base class.
21 // CHECK-LABEL: define {{.*}}DerivedD2Ev
22 // CHECK: %[[GEP:[0-9a-z]+]] = getelementptr i8, ptr {{.*}}, i64 16
23 // CHECK: call void @__sanitizer_dtor_callback_fields({{.*}}%[[GEP]], i64 4{{.*}}, !dbg ![[DI1:[0-9]+]]
24 // CHECK: call void @__sanitizer_dtor_callback_fields({{.*}}, i64 16{{.*}}, !dbg ![[DI2:[0-9]+]]
25 // CHECK: ret void
26 
27 // CHECK-LABEL: !DIFile{{.*}}cpp
28 
29 // CHECK-DAG: ![[DI1]] = {{.*}}line: [[@LINE-16]]
30 // CHECK-DAG: ![[DI2]] = {{.*}}line: [[@LINE-24]]
31