Skip to content

Commit a7c7b22

Browse files
committed
fix(visitor): handle missing import cases in DWARF visitor
Fix #5
1 parent b866f66 commit a7c7b22

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/dwarf2cpp/filters.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ def do_insert_name(tp: str, name: str):
6161
t,
6262
)
6363
if m:
64-
print(t)
6564
ret = m.group("ret").strip()
6665
cls = m.group("cls").strip()
6766
args = m.group("args").strip()

src/dwarf2cpp/visitor.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,12 +532,17 @@ def visit_imported_declaration(self, die: DWARFDie) -> None:
532532

533533
import_die = die.find("DW_AT_import").as_referenced_die()
534534
self.visit(import_die)
535+
if import_die.offset not in self._cache:
536+
return
537+
535538
if import_die.tag == "DW_TAG_namespace":
536539
import_ = self._cache[import_die.offset]
537540
imported_decl = ImportedDeclaration(name=die.short_name, import_=import_)
538541
else:
539542
imported_decl = ImportedDeclaration(name="", import_=get_qualified_type(import_die))
540543

544+
assert imported_decl.import_ is not None, "Expected valid import."
545+
541546
for attribute in die.attributes:
542547
if attribute.name in {
543548
"DW_AT_decl_file",

0 commit comments

Comments
 (0)