[all-commits] [llvm/llvm-project] e2ede1: [lldb] Update field offset/sizes when encountering...

Raphael Isemann via All-commits all-commits at lists.llvm.org
Sat Oct 30 04:22:43 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e2ede1715d4141279bb76d8850e0494b85d1eee8
      https://github.com/llvm/llvm-project/commit/e2ede1715d4141279bb76d8850e0494b85d1eee8
  Author: Raphael Isemann <teemperor at gmail.com>
  Date:   2021-10-30 (Sat, 30 Oct 2021)

  Changed paths:
    M lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
    M lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
    M lldb/test/API/lang/cpp/bitfields/main.cpp

  Log Message:
  -----------
  [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




More information about the All-commits mailing list