llvm-project
3c162ba2 - [LLDB][NativePDB] Add non-overlapping fields in root struct (#166243)

Commit
1 day ago
[LLDB][NativePDB] Add non-overlapping fields in root struct (#166243) When anonymous unions are used in a struct or vice versa, their fields are merged into the parent record when using PDB. LLDB tries to recreate the original definition of the record _with_ the anonymous unions/structs. For tagged unions (like `std::optional`) where the tag followed the anonymous union, the result was suboptimal: ```cpp // input: struct Foo { union { Bar b; char c; }; bool tag; }; // reconstructed: struct Foo { union { Bar b; struct { char c; bool tag; }; }; }; ``` Once the algorithm is in some nested union, it can't get out. In the above case, we can get to the correct reconstructed record if we always add fields that don't overlap others in the root struct. So when we see `tag`, we'll see that it comes after all other fields, so it's possible to add it in the root `Foo`.
Author
Parents
Loading