[lldb] Update field offset/sizes when encountering artificial members such as vtable pointers
`DWARFASTParserClang::ParseSingleMember` turns DWARF DIEs that describe struct/class members into their respective Clang representation (e.g., clang::FieldDecl). It also updates a record of where the last field started/ended so that we can speculatively fill any holes between a field and a bitfield with unnamed bitfield padding. Right now we are completely ignoring 'artificial' members when parsing the DWARF of a struct/class. The only artificial member that seems to be emitted in practice for C/C++ seems to be the vtable pointer. By completely skipping both the Clang AST node creation and the updating of the last-field record, we essentially leave a hole in our layout with the size of our artificial member. If the next member is a bitfield we then speculatively fill the hole with an unnamed bitfield. During CodeGen Clang inserts an artificial vtable pointer into the layout again which now occupies the same offset as the unnamed bitfield. This later brings down Clang's `CGRecordLowering::insertPadding` when it checks that none of the fields of the generated record layout overlap. Note that this is not a Clang bug. We explicitly set the offset of our fields in LLDB and overwrite whatever Clang makes up. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D112697
Loading
Please sign in to comment