Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / sanitize-dtor-bit-field.cpp
blob5bb48ac102eec02c5dad044270ac52fa59ce0ca7
1 // Test -fsanitize-memory-use-after-dtor
2 // RUN: %clang_cc1 -O0 -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 // 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_"
5 // 24 bytes total
6 struct Packed {
7 // Packed into 4 bytes
8 unsigned int a : 1;
9 unsigned int b : 1;
10 //unsigned int c : 1;
11 // Force alignment to next 4 bytes
12 unsigned int : 0;
13 unsigned int d : 1;
14 // Force alignment, 8 more bytes
15 double e = 5.0;
16 // 4 bytes
17 unsigned int f : 1;
18 ~Packed() {}
20 Packed p;
23 // 1 byte total
24 struct Empty {
25 unsigned int : 0;
26 ~Empty() {}
28 Empty e;
31 // 4 byte total
32 struct Simple {
33 unsigned int a : 1;
34 ~Simple() {}
36 Simple s;
39 // 8 bytes total
40 struct Anon {
41 // 1 byte
42 unsigned int a : 1;
43 unsigned int b : 2;
44 // Force alignment to next byte
45 unsigned int : 0;
46 unsigned int c : 1;
47 ~Anon() {}
49 Anon an;
52 struct CharStruct {
53 char c;
54 ~CharStruct();
57 struct Adjacent {
58 CharStruct a;
59 int b : 1;
60 CharStruct c;
61 ~Adjacent() {}
63 Adjacent ad;
65 // CHECK-LABEL: define {{.*}}PackedD2Ev
66 // CHECK: call void @__sanitizer_dtor_callback_fields({{.*}}i64 17{{.*}}, !dbg ![[DI1:[0-9]+]]
67 // CHECK: ret void
69 // CHECK-LABEL: define {{.*}}EmptyD2Ev
70 // CHECK: ret void
72 // CHECK-LABEL: define {{.*}}SimpleD2Ev
73 // CHECK: call void @__sanitizer_dtor_callback_fields({{.*}}i64 1{{.*}}, !dbg ![[DI2:[0-9]+]]
74 // CHECK: ret void
76 // CHECK-LABEL: define {{.*}}AnonD2Ev
77 // CHECK: call void @__sanitizer_dtor_callback_fields({{.*}}i64 5{{.*}}, !dbg ![[DI3:[0-9]+]]
78 // CHECK: ret void
80 // CHECK-LABEL: define {{.*}}AdjacentD2Ev
81 // CHECK: call void @__sanitizer_dtor_callback_fields({{.*}}i64 1{{.*}}, !dbg ![[DI4:[0-9]+]]
82 // CHECK: ret void
84 // CHECK-LABEL: !DIFile{{.*}}cpp
86 // CHECK-DAG: ![[DI1]] = {{.*}}line: [[@LINE-78]]
87 // CHECK-DAG: ![[DI2]] = {{.*}}line: [[@LINE-54]]
88 // CHECK-DAG: ![[DI3]] = {{.*}}line: [[@LINE-46]]
89 // CHECK-DAG: ![[DI4]] = {{.*}}line: [[@LINE-30]]