From: Duncan P. N. Exon Smith Date: Wed, 27 May 2015 22:59:03 +0000 (+0000) Subject: AsmPrinter: Return added DIE from DIE::addChild() X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=59be554de468b5ce92e74618c6bb741b5cf671fd;p=oota-llvm.git AsmPrinter: Return added DIE from DIE::addChild() Change `DIE::addChild()` to return a reference to the just-added node, and update consumers to use it directly. An upcoming commit will abstract away (and eventually change) the underlying storage of `DIE::Children`. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238372 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/CodeGen/DIE.h b/include/llvm/CodeGen/DIE.h index 5a8f4915f5e..c843f3fd1a6 100644 --- a/include/llvm/CodeGen/DIE.h +++ b/include/llvm/CodeGen/DIE.h @@ -543,10 +543,11 @@ public: /// addChild - Add a child to the DIE. /// - void addChild(std::unique_ptr Child) { + DIE &addChild(std::unique_ptr Child) { assert(!Child->getParent()); Child->Parent = this; Children.push_back(std::move(Child)); + return *Children.back(); } /// Find a value in the DIE with the attribute given. diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index fc57f261188..907f6706bc6 100644 --- a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -290,8 +290,7 @@ void DwarfUnit::addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N) { assert(Tag != dwarf::DW_TAG_auto_variable && Tag != dwarf::DW_TAG_arg_variable); - Parent.addChild(make_unique((dwarf::Tag)Tag)); - DIE &Die = *Parent.getChildren().back(); + DIE &Die = Parent.addChild(make_unique((dwarf::Tag)Tag)); if (N) insertDIE(N, &Die); return Die;