[Lldb-commits] [lldb] [lldb] Lookup static const members in FindGlobalVariables (PR #111859)
Michael Buch via lldb-commits
lldb-commits at lists.llvm.org
Fri Oct 25 02:01:29 PDT 2024
================
@@ -362,6 +369,23 @@ void ManualDWARFIndex::IndexUnitImpl(DWARFUnit &unit,
set.namespaces.Insert(ConstString(name), ref);
break;
+ case DW_TAG_member: {
+ // In DWARF 4 and earlier `static const` members of a struct, a class or a
+ // union have an entry tag `DW_TAG_member`, and are also tagged as
+ // `DW_AT_external` and `DW_AT_declaration`, but otherwise follow the
+ // same rules as `DW_TAG_variable`.
+ if (unit.GetVersion() >= 5)
+ break;
+ bool parent_is_class_type = false;
+ if (auto parent = die.GetParent()) {
+ parent_is_class_type = parent->Tag() == DW_TAG_structure_type ||
+ parent->Tag() == DW_TAG_class_type ||
+ parent->Tag() == DW_TAG_union_type;
+ }
+ if (!parent_is_class_type || !is_external || !is_declaration)
----------------
Michael137 wrote:
Wanted to note that we have this block here in `DWARFASTParserClang.cpp`:
https://github.com/llvm/llvm-project/blob/d2e7ee77d33e8b3be3b1d4e9bc5bc4c60b62b554/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp#L2824-L2839
Which describes an edge-case with how GCC emits static data members (i.e., it doesn't consistently emit the `DW_AT_external` flag). Not sure we want to account for that, but also, it would be nice if we had a single place where we did the "isPreDWARFv5StaticDataMember` check. But feel free to ignore
https://github.com/llvm/llvm-project/pull/111859
More information about the lldb-commits
mailing list