xref: /aosp_15_r20/external/clang/test/CodeGenCXX/sanitize-dtor-tail-call.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // Test -fsanitize-memory-use-after-dtor
2*67e74705SXin Li // 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
3*67e74705SXin Li // 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
4*67e74705SXin Li 
5*67e74705SXin Li struct Simple {
6*67e74705SXin Li   int x_;
SimpleSimple7*67e74705SXin Li   Simple() {
8*67e74705SXin Li     x_ = 5;
9*67e74705SXin Li   }
~SimpleSimple10*67e74705SXin Li   ~Simple() {
11*67e74705SXin Li     x_ += 1;
12*67e74705SXin Li   }
13*67e74705SXin Li };
14*67e74705SXin Li 
15*67e74705SXin Li Simple s;
16*67e74705SXin Li // Simple internal member is poisoned by compiler-generated dtor
17*67e74705SXin Li // CHECK: define {{.*}}SimpleD2Ev{{.*}} [[ATTRIBUTE:#[0-9]+]]
18*67e74705SXin Li // CHECK: {{^ *}}call void @__sanitizer_dtor_callback
19*67e74705SXin Li // CHECK-NOT: call void @__sanitizer_dtor_callback
20*67e74705SXin Li // CHECK: ret void
21*67e74705SXin Li 
22*67e74705SXin Li // Destructor does not emit any tail calls
23*67e74705SXin Li // CHECK: attributes [[ATTRIBUTE]] = {{.*}}"disable-tail-calls"="true"
24