62 lines · cpp
1// clang-format off2// REQUIRES: lld, x863 4// Test various interesting cases for AST reconstruction.5// RUN: %clang_cl --target=x86_64-windows-msvc -Od -Z7 -c /Fo%t.obj -- %s6// RUN: lld-link -debug:full -nodefaultlib -entry:main %t.obj -out:%t.exe -pdb:%t.pdb7// RUN: %lldb -f %t.exe -s \8// RUN: %p/Inputs/bitfields.lldbinit 2>&1 | FileCheck %s9 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 TheStruct31// CHECK: (const Struct) TheStruct = {32// CHECK: (int:5) A = 633// CHECK: (int:7) B = 834// CHECK: (unsigned int:3) C = 235// CHECK: (unsigned int:15) D = 1234536// 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 ast43// CHECK: Dumping clang ast for 1 modules.44// CHECK: TranslationUnitDecl {{.*}}45// CHECK: |-CXXRecordDecl {{.*}} struct Struct definition46// CHECK: | |-FieldDecl {{.*}} A 'int'47// CHECK: | | `-IntegerLiteral {{.*}} 'int' 548// CHECK: | |-FieldDecl {{.*}} B 'int'49// CHECK: | | `-IntegerLiteral {{.*}} 'int' 750// CHECK: | |-FieldDecl {{.*}} C 'unsigned int'51// CHECK: | | `-IntegerLiteral {{.*}} 'int' 352// CHECK: | |-FieldDecl {{.*}} D 'unsigned int'53// CHECK: | | `-IntegerLiteral {{.*}} 'int' 1554// CHECK: | |-FieldDecl {{.*}} E 'char'55// CHECK: | | `-IntegerLiteral {{.*}} 'int' 156// CHECK: | |-FieldDecl {{.*}} F 'char'57// CHECK: | | `-IntegerLiteral {{.*}} 'int' 258// CHECK: | |-FieldDecl {{.*}} G 'char'59// CHECK: | | `-IntegerLiteral {{.*}} 'int' 360// CHECK: | `-FieldDecl {{.*}} H 'char'61// CHECK: | `-IntegerLiteral {{.*}} 'int' 362