From 5adc3dbc96890cbb83d809a874ea1a678c5f4128 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Tue, 27 Jan 2009 23:22:55 +0000 Subject: [PATCH] Add type DIE into appropriate context DIE. llvm-svn: 63154 --- llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp index 19edd9514686..63fb68b5ec75 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp @@ -1687,9 +1687,23 @@ private: ConstructTypeDIE(DW_Unit, Buffer, DICompositeType(Ty.getGV())); } - // Add debug information entry to entity and unit. - DIE *Die = DW_Unit->AddDie(Buffer); - SetDIEntry(Slot, Die); + // Add debug information entry to entity and appropriate context. + DIE *Die = NULL; + DIDescriptor Context = Ty.getContext(); + if (!Context.isNull()) + Die = DW_Unit->getDieMapSlotFor(Context.getGV()); + + if (Die) { + DIE *Child = new DIE(Buffer); + Die->AddChild(Child); + Buffer.Detach(); + SetDIEntry(Slot, Child); + } + else { + Die = DW_Unit->AddDie(Buffer); + SetDIEntry(Slot, Die); + } + Entity->AddValue(DW_AT_type, DW_FORM_ref4, Slot); }