[clang] [clang][DebugInfo] DWARFv5: static data members declarations are DW_TAG_variable (PR #72235)

Michael Buch via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 4 08:55:21 PST 2024


Michael137 wrote:

Ah looks like in `GetClangDeclForDIE`, when trying to parse the `DW_AT_specification` that the CU-level `DW_TAG_variable` points to, we now try to `CreateVariableDeclaration`, because the static member is a `DW_TAG_variable` too. Whereas previously we would just fall-through [this switch-statement](https://github.com/llvm/llvm-project/blob/640ef55bbbc081b72a87f71cab1bce08762e48b0/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp#L3324), i.e., it was a no-op. Adding `VarDecl`s to `RecordDecl`s for static data members should always be done in `CreateStaticMemberVariable`.

In your reproducer it looks like we only ever emit a forward declaration for the containing structure `t1`. So it seems like for DWARFv4, we just never end up trying to call `CreateStaticMemberVariable` on a `CXXRecordDecl` without a definition.

Maybe the solution is to add a check inside `GetClangDeclForDIE` whether we're referring to a static data member, and if we do, restore previous behaviour where we don't try to create a `VarDecl` at that point.

https://github.com/llvm/llvm-project/pull/72235


More information about the cfe-commits mailing list