Skip to content

Commit

Permalink
[DWARF] Emit D classes as DW_TAG_class_type
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuclaw committed Jun 5, 2015
1 parent df5a047 commit 4d1c830
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/backend/dwarf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,17 @@ void TypeInfo_Atype::swap(void *p1, void *p2)
assert(0);
}

unsigned char dwarf_classify_struct(unsigned long sflags)
{
if (sflags & STRclass)
return DW_TAG_class_type;

if (sflags & STRunion)
return DW_TAG_union_type;

return DW_TAG_structure_type;
}

/* ======================= Type Index ============================== */

unsigned dwarf_typidx(type *t)
Expand Down Expand Up @@ -2220,8 +2231,7 @@ unsigned dwarf_typidx(type *t)

if (t->Tflags & (TFsizeunknown | TFforward))
{
abbrevTypeStruct1[0] = (st->Sflags & STRunion)
? DW_TAG_union_type : DW_TAG_structure_type;
abbrevTypeStruct1[0] = dwarf_classify_struct(st->Sflags);
code = dwarf_abbrev_code(abbrevTypeStruct1, sizeof(abbrevTypeStruct1));
idx = infobuf->size();
infobuf->writeuLEB128(code);
Expand Down Expand Up @@ -2250,8 +2260,7 @@ unsigned dwarf_typidx(type *t)
t->Tflags &= ~TFforward;
if (nfields == 0)
{
abbrevTypeStruct0[0] = (st->Sflags & STRunion)
? DW_TAG_union_type : DW_TAG_structure_type;
abbrevTypeStruct0[0] = dwarf_classify_struct(st->Sflags);
abbrevTypeStruct0[1] = 0; // no children
abbrevTypeStruct0[5] = DW_FORM_data1; // DW_AT_byte_size
code = dwarf_abbrev_code(abbrevTypeStruct0, sizeof(abbrevTypeStruct0));
Expand All @@ -2263,8 +2272,7 @@ unsigned dwarf_typidx(type *t)
else
{
Outbuffer abuf; // for abbrev
abuf.writeByte((st->Sflags & STRunion)
? DW_TAG_union_type : DW_TAG_structure_type);
abuf.writeByte(dwarf_classify_struct(st->Sflags));
abuf.writeByte(1); // children
abuf.writeByte(DW_AT_name); abuf.writeByte(DW_FORM_string);
abuf.writeByte(DW_AT_byte_size);
Expand Down

0 comments on commit 4d1c830

Please sign in to comment.