summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2008-12-10 00:15:44 +0000
committerEvan Cheng <evan.cheng@apple.com>2008-12-10 00:15:44 +0000
commit288fbd2133d3243e4c29496d0f738540a0b0305e (patch)
tree628b2ae1b2c8ac1af8a849d480e8b7e6b4996dc9 /llvm/lib
parenta2495508cd71583c6d4352c1ed247b4dd4fb7916 (diff)
downloadbcm5719-llvm-288fbd2133d3243e4c29496d0f738540a0b0305e.tar.gz
bcm5719-llvm-288fbd2133d3243e4c29496d0f738540a0b0305e.zip
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. llvm-svn: 60812
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp21
-rw-r--r--llvm/lib/CodeGen/MachineModuleInfo.cpp9
2 files changed, 22 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
index 9ca9e28010a..4476be3bb3f 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
+++ b/llvm/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.
diff --git a/llvm/lib/CodeGen/MachineModuleInfo.cpp b/llvm/lib/CodeGen/MachineModuleInfo.cpp
index 9e0e9025a4b..f93f27c934d 100644
--- a/llvm/lib/CodeGen/MachineModuleInfo.cpp
+++ b/llvm/lib/CodeGen/MachineModuleInfo.cpp
@@ -906,7 +906,8 @@ void BasicTypeDesc::dump() {
<< "Context(" << getContext() << "), "
<< "Name(\"" << getName() << "\"), "
<< "Size(" << getSize() << "), "
- << "Encoding(" << Encoding << ")\n";
+ << "Encoding(" << Encoding << "),"
+ << "Flags(" << Flags << ")\n";
}
#endif
@@ -965,7 +966,8 @@ void DerivedTypeDesc::dump() {
<< "Size(" << getSize() << "), "
<< "File(" << getFile() << "), "
<< "Line(" << getLine() << "), "
- << "FromType(" << FromType << ")\n";
+ << "FromType(" << FromType << "),"
+ << "Flags(" << Flags << ")\n";
}
#endif
@@ -1023,7 +1025,8 @@ void CompositeTypeDesc::dump() {
<< "File(" << getFile() << "), "
<< "Line(" << getLine() << "), "
<< "FromType(" << getFromType() << "), "
- << "Elements.size(" << Elements.size() << ")\n";
+ << "Elements.size(" << Elements.size() << "),"
+ << "Flags(" << Flags << ")\n";
}
#endif
OpenPOWER on IntegriCloud