Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / lang / cpp / bitfields / main.cpp
blob6e1d4ba63bf6d7ebdda6af642d0216c47629d258
1 #include <stdint.h>
3 struct LargeBitsA {
4 unsigned int : 30, a : 20;
5 } lba;
7 struct LargeBitsB {
8 unsigned int a : 1, : 11, : 12, b : 20;
9 } lbb;
11 struct LargeBitsC {
12 unsigned int : 13, : 9, a : 1, b : 1, c : 5, d : 1, e : 20;
13 } lbc;
15 struct LargeBitsD {
16 char arr[3];
17 unsigned int : 30, a : 20;
18 } lbd;
20 struct BitfieldsInStructInUnion {
21 class fields {
22 uint64_t : 13;
23 uint64_t : 9;
25 uint64_t a : 1;
26 uint64_t b : 1;
27 uint64_t c : 1;
28 uint64_t d : 1;
29 uint64_t e : 1;
30 uint64_t f : 1;
31 uint64_t g : 1;
32 uint64_t h : 1;
33 uint64_t i : 1;
34 uint64_t j : 1;
35 uint64_t k : 1;
37 // In order to reproduce the crash for this case we need the
38 // members of fields to stay private :-(
39 friend struct BitfieldsInStructInUnion;
42 union {
43 struct fields f;
46 BitfieldsInStructInUnion() {
47 f.a = 1;
48 f.b = 0;
49 f.c = 1;
50 f.d = 0;
51 f.e = 1;
52 f.f = 0;
53 f.g = 1;
54 f.h = 0;
55 f.i = 1;
56 f.j = 0;
57 f.k = 1;
59 } bitfields_in_struct_in_union;
61 class Base {
62 public:
63 uint32_t b_a;
66 class Derived : public Base {
67 public:
68 uint32_t d_a : 1;
69 } derived;
71 union UnionWithBitfields {
72 unsigned int a : 8;
73 unsigned int b : 16;
74 unsigned int c : 32;
75 unsigned int x;
76 } uwbf;
78 union UnionWithUnnamedBitfield {
79 unsigned int : 16, a : 24;
80 unsigned int x;
81 } uwubf;
83 struct BoolBits {
84 bool a : 1;
85 bool b : 1;
86 bool c : 2;
87 bool d : 2;
90 struct WithVTable {
91 virtual ~WithVTable() {}
92 unsigned a : 4;
93 unsigned b : 4;
94 unsigned c : 4;
96 WithVTable with_vtable;
98 struct WithVTableAndUnnamed {
99 virtual ~WithVTableAndUnnamed() {}
100 unsigned : 4;
101 unsigned b : 4;
102 unsigned c : 4;
104 WithVTableAndUnnamed with_vtable_and_unnamed;
106 struct BaseWithVTable {
107 virtual ~BaseWithVTable() {}
109 struct HasBaseWithVTable : BaseWithVTable {
110 unsigned a : 4;
111 unsigned b : 4;
112 unsigned c : 4;
114 HasBaseWithVTable base_with_vtable;
116 struct DerivedWithVTable : public Base {
117 virtual ~DerivedWithVTable() {}
118 unsigned a : 1;
120 DerivedWithVTable derived_with_vtable;
122 int main(int argc, char const *argv[]) {
123 lba.a = 2;
125 lbb.a = 1;
126 lbb.b = 3;
128 lbc.a = 1;
129 lbc.b = 0;
130 lbc.c = 4;
131 lbc.d = 1;
132 lbc.e = 20;
134 lbd.arr[0] = 'a';
135 lbd.arr[1] = 'b';
136 lbd.arr[2] = '\0';
137 lbd.a = 5;
139 derived.b_a = 2;
140 derived.d_a = 1;
142 uwbf.x = 0xFFFFFFFF;
143 uwubf.x = 0xFFFFFFFF;
145 BoolBits bb;
146 bb.a = 0b1;
147 bb.b = 0b0;
148 bb.c = 0b11;
149 bb.d = 0b01;
151 with_vtable.a = 5;
152 with_vtable.b = 0;
153 with_vtable.c = 5;
155 with_vtable_and_unnamed.b = 0;
156 with_vtable_and_unnamed.c = 5;
158 base_with_vtable.a = 5;
159 base_with_vtable.b = 0;
160 base_with_vtable.c = 5;
162 derived_with_vtable.b_a = 2;
163 derived_with_vtable.a = 1;
165 return 0; // break here