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
This commit is contained in:
Duncan P. N. Exon Smith 2015-05-27 22:59:03 +00:00
parent 49e9f44cb1
commit 59be554de4
2 changed files with 3 additions and 3 deletions

View File

@ -543,10 +543,11 @@ public:
/// addChild - Add a child to the DIE. /// addChild - Add a child to the DIE.
/// ///
void addChild(std::unique_ptr<DIE> Child) { DIE &addChild(std::unique_ptr<DIE> Child) {
assert(!Child->getParent()); assert(!Child->getParent());
Child->Parent = this; Child->Parent = this;
Children.push_back(std::move(Child)); Children.push_back(std::move(Child));
return *Children.back();
} }
/// Find a value in the DIE with the attribute given. /// Find a value in the DIE with the attribute given.

View File

@ -290,8 +290,7 @@ void DwarfUnit::addDIEEntry(DIE &Die, dwarf::Attribute Attribute,
DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N) { DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N) {
assert(Tag != dwarf::DW_TAG_auto_variable && assert(Tag != dwarf::DW_TAG_auto_variable &&
Tag != dwarf::DW_TAG_arg_variable); Tag != dwarf::DW_TAG_arg_variable);
Parent.addChild(make_unique<DIE>((dwarf::Tag)Tag)); DIE &Die = Parent.addChild(make_unique<DIE>((dwarf::Tag)Tag));
DIE &Die = *Parent.getChildren().back();
if (N) if (N)
insertDIE(N, &Die); insertDIE(N, &Die);
return Die; return Die;