[Lldb-commits] [lldb] [lldb] DWARFDIE: Follow DW_AT_specification when computing CompilerCo… (PR #77157)

Felipe de Azevedo Piovezan via lldb-commits lldb-commits at lists.llvm.org
Mon Jan 8 05:45:27 PST 2024


================
@@ -375,16 +375,21 @@ std::vector<DWARFDIE> DWARFDIE::GetDeclContextDIEs() const {
 
 std::vector<lldb_private::CompilerContext> DWARFDIE::GetDeclContext() const {
   std::vector<lldb_private::CompilerContext> context;
-  const dw_tag_t tag = Tag();
-  if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit)
-    return context;
   DWARFDIE parent = GetParent();
-  if (parent)
+  if (parent) {
+    const dw_tag_t parent_tag = parent.Tag();
+    if (parent_tag == DW_TAG_compile_unit || parent_tag == DW_TAG_partial_unit)
+      // Handle top-level DIEs by following the specification if any.
+      if (DWARFDIE spec = GetReferencedDIE(DW_AT_specification))
+        if (spec != *this)
----------------
felipepiovezan wrote:

Nit, If you feel so inclined:

```
if (DWARFDIE spec = GetReferencedDIE(DW_AT_specification);
     spec && spec != *this)
```

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


More information about the lldb-commits mailing list