llvm-capstone/lldb/test
Michael Buch f74aaca632
[lldb][DWARFASTParserClang] Check DW_AT_declaration to determine static data members (#68300)
**Background**

Prior to DWARFv4, there was no clear normative text on how to handle
static data members. Non-normative text suggested that compilers should
use `DW_AT_external` to mark static data members of structrues/unions.
Clang does this consistently. However, GCC doesn't, e.g., when the
structure/union is in an anonymous namespace (which is C++ standard
conformant). Additionally, GCC never emits `DW_AT_data_member_location`s
for union members (regardless of storage linkage and storage duration).

Since DWARFv5 (issue 161118.1), static data members get emitted as
`DW_TAG_variable`.

LLDB used to differentiate between static and non-static members by
checking the `DW_AT_external` flag and the absence of
`DW_AT_data_member_location`. With
[D18008](https://reviews.llvm.org/D18008) LLDB started to pretend that
union members always have a `0` `DW_AT_data_member_location` by default
(because GCC never emits these locations).

In [D124409](https://reviews.llvm.org/D124409) LLDB stopped checking the
`DW_AT_external` flag to account for the case where GCC doesn't emit the
flag for types in anonymous namespaces; instead we only check for
presence of `DW_AT_data_member_location`s.

The combination of these changes then meant that LLDB would never
correctly detect that a union has static data members.

**Solution**

Instead of unconditionally initializing the `member_byte_offset` to `0`
specifically for union members, this patch proposes to check for both
the absence of `DW_AT_data_member_location` and `DW_AT_declaration`,
which consistently gets emitted for static data members on GCC and
Clang.

We initialize the `member_byte_offset` to `0` anyway if we determine it
wasn't a static. So removing the special case for unions makes this code
simpler to reason about.

Long-term, we should just use DWARFv5's new representation for static
data members.

Fixes #68135
2023-10-06 09:07:20 +01:00
..
API [lldb][DWARFASTParserClang] Check DW_AT_declaration to determine static data members (#68300) 2023-10-06 09:07:20 +01:00
Shell [lldb][AArch64] Re-enable clone follow tests on AArch64 Linux 2023-09-08 14:10:08 +00:00
Unit [lldb] Make TSan errors fatal when running the test suite 2023-08-07 13:20:38 -07:00
CMakeLists.txt [lldb] Remove reproducer test suite (NFC) 2023-05-26 09:33:40 -07:00
lit.cfg.py [NFC][Py Reformat] Reformat python files in lldb 2023-05-25 12:54:09 -07:00
lit.site.cfg.py.in