1// clang-format off
2// REQUIRES: lld, x86
3
4// Test various interesting cases for AST reconstruction.
5// RUN: %clang_cl --target=x86_64-windows-msvc -Od -Z7 -c /Fo%t.obj -- %s
6// RUN: lld-link -debug:full -nodefaultlib -entry:main %t.obj -out:%t.exe -pdb:%t.pdb
7// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
8// RUN: %p/Inputs/bitfields.lldbinit 2>&1 | FileCheck %s
9
10// Test trivial versions of each tag type.
11struct Struct {
12 int A : 5 = 6;
13 int B : 7 = 8;
14 unsigned C : 3 = 2;
15 unsigned D : 15 = 12345;
16 char E : 1 = 0;
17 char F : 2 = 1;
18 char G : 3 = 2;
19 // H should be at offset 0 of a new byte.
20 char H : 3 = 3;
21};
22
23constexpr Struct TheStruct;
24
25
26int main(int argc, char **argv) {
27 return TheStruct.A;
28}
29
30// CHECK: (lldb) target variable -T TheStruct
31// CHECK: (const Struct) TheStruct = {
32// CHECK: (int:5) A = 6
33// CHECK: (int:7) B = 8
34// CHECK: (unsigned int:3) C = 2
35// CHECK: (unsigned int:15) D = 12345
36// CHECK: (char:1) E = '\0'
37// CHECK: (char:2) F = '\x01'
38// CHECK: (char:3) G = '\x02'
39// CHECK: (char:3) H = '\x03'
40// CHECK: }
41//
42// CHECK: target modules dump ast
43// CHECK: Dumping clang ast for 1 modules.
44// CHECK: TranslationUnitDecl {{.*}}
45// CHECK: |-CXXRecordDecl {{.*}} struct Struct definition
46// CHECK: | |-FieldDecl {{.*}} A 'int'
47// CHECK: | | `-IntegerLiteral {{.*}} 'int' 5
48// CHECK: | |-FieldDecl {{.*}} B 'int'
49// CHECK: | | `-IntegerLiteral {{.*}} 'int' 7
50// CHECK: | |-FieldDecl {{.*}} C 'unsigned int'
51// CHECK: | | `-IntegerLiteral {{.*}} 'int' 3
52// CHECK: | |-FieldDecl {{.*}} D 'unsigned int'
53// CHECK: | | `-IntegerLiteral {{.*}} 'int' 15
54// CHECK: | |-FieldDecl {{.*}} E 'char'
55// CHECK: | | `-IntegerLiteral {{.*}} 'int' 1
56// CHECK: | |-FieldDecl {{.*}} F 'char'
57// CHECK: | | `-IntegerLiteral {{.*}} 'int' 2
58// CHECK: | |-FieldDecl {{.*}} G 'char'
59// CHECK: | | `-IntegerLiteral {{.*}} 'int' 3
60// CHECK: | `-FieldDecl {{.*}} H 'char'
61// CHECK: | `-IntegerLiteral {{.*}} 'int' 3
62

source code of lldb/test/Shell/SymbolFile/NativePDB/bitfields.cpp