[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / lifetime-sanitizer.cpp
blob33a85660925190768a3a7b019acc0e9051f0b46d
1 // RUN: %clang -w -target x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0 \
2 // RUN: -Xclang -disable-llvm-passes %s | FileCheck %s -check-prefixes=CHECK \
3 // RUN: --implicit-check-not=llvm.lifetime
4 // RUN: %clang -w -target x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0 \
5 // RUN: -fsanitize=address -fsanitize-address-use-after-scope \
6 // RUN: -Xclang -disable-llvm-passes %s | FileCheck %s -check-prefixes=CHECK,LIFETIME
7 // RUN: %clang -w -target x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0 \
8 // RUN: -fsanitize=memory -Xclang -disable-llvm-passes %s | \
9 // RUN: FileCheck %s -check-prefixes=CHECK,LIFETIME
10 // RUN: %clang -w -target aarch64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0 \
11 // RUN: -fsanitize=hwaddress -Xclang -disable-llvm-passes %s | \
12 // RUN: FileCheck %s -check-prefixes=CHECK,LIFETIME
14 extern int bar(char *A, int n);
16 struct X {
17 X();
18 ~X();
19 int *p;
21 struct Y {
22 Y();
23 int *p;
26 extern "C" void a(), b(), c(), d();
28 // CHECK: define dso_local void @_Z3fooi(i32 noundef %[[N:[^)]+]])
29 void foo(int n) {
30 // CHECK: store i32 %[[N]], ptr %[[NADDR:[^,]+]]
31 // CHECK-LABEL: call void @a()
32 a();
34 // CHECK-LABEL: call void @b()
35 // CHECK: [[NARG:%[^ ]+]] = load i32, ptr %[[NADDR]]
36 // CHECK: [[BOOL:%[^ ]+]] = icmp ne i32 [[NARG]], 0
37 // CHECK: store i1 false
38 // CHECK: br i1 [[BOOL]], label %[[ONTRUE:[^,]+]], label %[[ONFALSE:[^,]+]]
40 // CHECK: [[ONTRUE]]:
41 // LIFETIME: @llvm.lifetime.start
42 // LIFETIME: store i1 true
43 // LIFETIME: call void @_ZN1XC
44 // CHECK: br label %[[END:[^,]+]]
46 // CHECK: [[ONFALSE]]:
47 // LIFETIME: @llvm.lifetime.start
48 // LIFETIME: store i1 true
49 // LIFETIME: call void @_ZN1YC
50 // CHECK: br label %[[END]]
52 // CHECK: [[END]]:
53 // CHECK: call void @c()
54 // LIFETIME: @llvm.lifetime.end
55 // LIFETIME: @llvm.lifetime.end
56 b(), (n ? X().p : Y().p), c();
58 // CHECK: call void @d()
59 d();