[clang] [lldb] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70639)

Michael Buch via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 31 18:32:51 PDT 2023


Michael137 wrote:

> The DWARFASTParserClang.cpp will try to create the class from the DWARF for the class definition. You will need to find the DW_TAG_variable when we are creating the static field if there is no DW_AT_const_value in the DW_TAG_member. But we also need to support the DW_AT_const_value being in the DW_TAG_member since older DWARF will be emitted like this.

That's 100% correct. I was thinking, before [this block](https://github.com/llvm/llvm-project/blob/8b91de5d6a3f98dcc00bbd286e339e512f7e3682/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp#L2909-L2919) where we check for the existence of a `const_value_form`. With this patch such constant won't exist on the declaration. So I was thinking we would try to look for the definition. What's interesting is that with this patch, the expression evaluator successfully finds the DW_TAG_variable which have a location attribute but not if they have a constant instead of a location. It's probably some logic that assumes statics always have a location

> Are we going to emit a DW_AT_const_expr now in the DW_TAG_member? If so, then we will know that we need to look for the DW_TAG_variable. I don't think clang emitted the DW_AT_const_expr attribute before.

That wasn't part of this patch. But would make sense to add (i've noticed GCC adds that attribute)

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


More information about the cfe-commits mailing list