Skip to content

Commit 7f72fe4

Browse files
committed
fix(visitor): support DW_TAG_variable for static members in classes/structs
1 parent 9486e0d commit 7f72fe4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/dwarf2cpp/visitor.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,9 @@ def _handle_attribute(self, die: DWARFDie) -> None:
782782

783783
if spec := die.find("DW_AT_specification"):
784784
spec = spec.as_referenced_die()
785-
assert spec.tag == "DW_TAG_member", "Expected DW_TAG_member"
785+
assert spec.tag in {"DW_TAG_member", "DW_TAG_variable"}, (
786+
f"Expected DW_TAG_member or DW_TAG_variable, got {spec.tag}"
787+
)
786788
return
787789

788790
variable = Attribute(name=die.short_name)
@@ -918,6 +920,7 @@ def _handle_struct(self, die: DWARFDie, ty: typing.Type[Class | Struct | Union])
918920
"DW_TAG_union_type",
919921
"DW_TAG_structure_type",
920922
"DW_TAG_member",
923+
"DW_TAG_variable",
921924
"DW_TAG_subprogram",
922925
"DW_TAG_imported_module",
923926
"DW_TAG_imported_declaration",
@@ -937,6 +940,10 @@ def _handle_struct(self, die: DWARFDie, ty: typing.Type[Class | Struct | Union])
937940
member = self._get(child)
938941
member.parent = struct
939942

943+
# DW_TAG_variable as a child of a class/struct is a static data member
944+
if child.tag == "DW_TAG_variable":
945+
member.is_static = True
946+
940947
# If no accessibility attribute is present, private access is assumed for members of a
941948
# class and public access is assumed for members of a structure, union, or interface
942949
if member.access is None:

0 commit comments

Comments
 (0)