diff options
author | Evan Cheng <evan.cheng@apple.com> | 2008-12-10 00:15:44 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2008-12-10 00:15:44 +0000 |
commit | 94ea5be39fe379cda3ff144a99b6a1a69a9fe2e2 (patch) | |
tree | ed64507396551b399c479df97b737c56ad1cabb6 /lib/CodeGen/AsmPrinter/DwarfWriter.cpp | |
parent | aedc637c966b6eaa3ca33e9220efe5ec34517de7 (diff) |
Fix a couple of Dwarf bugs.
- Emit DW_AT_byte_size for struct and union of size zero.
- Emit DW_AT_declaration for forward type declaration.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60812 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfWriter.cpp')
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfWriter.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp index 9ca9e28010..4476be3bb3 100644 --- a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp @@ -1774,14 +1774,25 @@ private: } } - // Add size if non-zero (derived types don't have a size.) - if (Size) AddUInt(&Buffer, DW_AT_byte_size, 0, Size); - // Add name if not anonymous or intermediate type. if (!Name.empty()) AddString(&Buffer, DW_AT_name, DW_FORM_string, Name); - // Add source line info if available. - AddSourceLine(&Buffer, TyDesc->getFile(), TyDesc->getLine()); + // Add size if non-zero (derived types might be zero-sized.) + if (Size) + AddUInt(&Buffer, DW_AT_byte_size, 0, Size); + else if (isa<CompositeTypeDesc>(TyDesc)) { + // If TyDesc is a composite type, then add size even if it's zero unless + // it's a forward declaration. + if (TyDesc->isForwardDecl()) + AddUInt(&Buffer, DW_AT_declaration, DW_FORM_flag, 1); + else + AddUInt(&Buffer, DW_AT_byte_size, 0, 0); + } + + // Add source line info if available and TyDesc is not a forward + // declaration. + if (!TyDesc->isForwardDecl()) + AddSourceLine(&Buffer, TyDesc->getFile(), TyDesc->getLine()); } /// NewCompileUnit - Create new compile unit and it's debug information entry. |