[llvm] r238372 - AsmPrinter: Return added DIE from DIE::addChild()

Duncan P. N. Exon Smith dexonsmith at apple.com
Wed May 27 15:59:03 PDT 2015


Author: dexonsmith
Date: Wed May 27 17:59:03 2015
New Revision: 238372

URL: http://llvm.org/viewvc/llvm-project?rev=238372&view=rev
Log:
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`.

Modified:
    llvm/trunk/include/llvm/CodeGen/DIE.h
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp

Modified: llvm/trunk/include/llvm/CodeGen/DIE.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DIE.h?rev=238372&r1=238371&r2=238372&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/DIE.h (original)
+++ llvm/trunk/include/llvm/CodeGen/DIE.h Wed May 27 17:59:03 2015
@@ -543,10 +543,11 @@ public:
 
   /// addChild - Add a child to the DIE.
   ///
-  void addChild(std::unique_ptr<DIE> Child) {
+  DIE &addChild(std::unique_ptr<DIE> 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.

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=238372&r1=238371&r2=238372&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Wed May 27 17:59:03 2015
@@ -290,8 +290,7 @@ void DwarfUnit::addDIEEntry(DIE &Die, dw
 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<DIE>((dwarf::Tag)Tag));
-  DIE &Die = *Parent.getChildren().back();
+  DIE &Die = Parent.addChild(make_unique<DIE>((dwarf::Tag)Tag));
   if (N)
     insertDIE(N, &Die);
   return Die;





More information about the llvm-commits mailing list