[Lldb-commits] [PATCH] D112147: [lldb] Fix lookup for global constants in namespaces

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 22 10:15:11 PDT 2021


clayborg requested changes to this revision.
clayborg added inline comments.
This revision now requires changes to proceed.


================
Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:3281-3282
     if ((parent_tag == DW_TAG_compile_unit ||
-         parent_tag == DW_TAG_partial_unit) &&
+         parent_tag == DW_TAG_partial_unit ||
+         parent_tag == DW_TAG_namespace) &&
         Language::LanguageIsCPlusPlus(GetLanguage(*die.GetCU())))
----------------
I think we should just always call this function in regardless of what the parent variable tag is since what happens if the parent tag is another value decl context like DW_TAG_class_type, DW_TAG_structure_type? 

The call to GetDWARFDeclContext(die) below will calculate the DWARFDeclContext for a DIE and then construct an appropriate qualified name, so we can just always do this so I would suggest just making this:

```
if (Language::LanguageIsCPlusPlus(GetLanguage(*die.GetCU())))
  mangled = GetDWARFDeclContext(die).GetQualifiedNameAsConstString().GetCString();
```
Then we should always get this right all the time. It doesn't actually make sense to call this if the parent is the DW_TAG_compile_unit or DW_TAG_partial_unit because then there is no decl context to add to the variable name.


================
Comment at: lldb/test/API/lang/cpp/global_variables/main.cpp:5
+int g_file_global_int = 42;
+const int g_file_global_const_int = 1337;
 }
----------------
might be nice to see if we can create constants inside of a class or struct as well as mentioned in the above inline comment


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112147/new/

https://reviews.llvm.org/D112147



More information about the lldb-commits mailing list