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