llvm-project/lldb/lit/SymbolFile/NativePDB/bitfields.cpp

61 lines
1.8 KiB
C++

// clang-format off
// REQUIRES: lld
// Test various interesting cases for AST reconstruction.
// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
// RUN: %p/Inputs/bitfields.lldbinit 2>&1 | FileCheck %s
// Test trivial versions of each tag type.
struct Struct {
int A : 5 = 6;
int B : 7 = 8;
unsigned C : 3 = 2;
unsigned D : 15 = 12345;
char E : 1 = 0;
char F : 2 = 1;
char G : 3 = 2;
// H should be at offset 0 of a new byte.
char H : 3 = 3;
};
constexpr Struct TheStruct;
int main(int argc, char **argv) {
return TheStruct.A;
}
// CHECK: (lldb) target variable -T TheStruct
// CHECK: (const Struct) TheStruct = {
// CHECK: (int:5) A = 6
// CHECK: (int:7) B = 8
// CHECK: (unsigned int:3) C = 2
// CHECK: (unsigned int:15) D = 12345
// CHECK: (char:1) E = '\0'
// CHECK: (char:2) F = '\x01'
// CHECK: (char:3) G = '\x02'
// CHECK: (char:3) H = '\x03'
// CHECK: }
//
// CHECK: target modules dump ast
// CHECK: Dumping clang ast for 1 modules.
// CHECK: TranslationUnitDecl {{.*}}
// CHECK: |-CXXRecordDecl {{.*}} struct Struct definition
// CHECK: | |-FieldDecl {{.*}} A 'int'
// CHECK: | | `-IntegerLiteral {{.*}} 'int' 5
// CHECK: | |-FieldDecl {{.*}} B 'int'
// CHECK: | | `-IntegerLiteral {{.*}} 'int' 7
// CHECK: | |-FieldDecl {{.*}} C 'unsigned int'
// CHECK: | | `-IntegerLiteral {{.*}} 'int' 3
// CHECK: | |-FieldDecl {{.*}} D 'unsigned int'
// CHECK: | | `-IntegerLiteral {{.*}} 'int' 15
// CHECK: | |-FieldDecl {{.*}} E 'char'
// CHECK: | | `-IntegerLiteral {{.*}} 'int' 1
// CHECK: | |-FieldDecl {{.*}} F 'char'
// CHECK: | | `-IntegerLiteral {{.*}} 'int' 2
// CHECK: | |-FieldDecl {{.*}} G 'char'
// CHECK: | | `-IntegerLiteral {{.*}} 'int' 3
// CHECK: | `-FieldDecl {{.*}} H 'char'
// CHECK: | `-IntegerLiteral {{.*}} 'int' 3