diff options
author | David Blaikie <dblaikie@gmail.com> | 2014-04-25 20:00:34 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2014-04-25 20:00:34 +0000 |
commit | 914046e1e7756aad8273f26302d39677648a3acf (patch) | |
tree | e78ee06f3935785439a15301c7ef4f161c702683 /llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | |
parent | e68b847fdb347f386e23ebd286dec115996440ee (diff) | |
download | bcm5719-llvm-914046e1e7756aad8273f26302d39677648a3acf.tar.gz bcm5719-llvm-914046e1e7756aad8273f26302d39677648a3acf.zip |
DIE: Pass ownership of children via std::unique_ptr rather than raw pointer.
This should reduce the chance of memory leaks like those fixed in
r207240.
There's still some unclear ownership of DIEs happening in DwarfDebug.
Pushing unique_ptr and references through more APIs should help expose
the cases where ownership is a bit fuzzy.
llvm-svn: 207263
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index 874e0c051ab..c7d22724ce3 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -383,7 +383,7 @@ void DwarfUnit::addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, DIDescriptor N) { assert(Tag != dwarf::DW_TAG_auto_variable && Tag != dwarf::DW_TAG_arg_variable); - Parent.addChild(new DIE((dwarf::Tag)Tag)); + Parent.addChild(make_unique<DIE>((dwarf::Tag)Tag)); DIE &Die = *Parent.getChildren().back(); if (N) insertDIE(N, &Die); @@ -1793,18 +1793,19 @@ void DwarfUnit::constructContainingTypeDIEs() { } /// constructVariableDIE - Construct a DIE for the given DbgVariable. -DIE *DwarfUnit::constructVariableDIE(DbgVariable &DV, bool isScopeAbstract) { +std::unique_ptr<DIE> DwarfUnit::constructVariableDIE(DbgVariable &DV, + bool isScopeAbstract) { auto D = constructVariableDIEImpl(DV, isScopeAbstract); DV.setDIE(*D); return D; } -DIE *DwarfUnit::constructVariableDIEImpl(const DbgVariable &DV, - bool isScopeAbstract) { +std::unique_ptr<DIE> DwarfUnit::constructVariableDIEImpl(const DbgVariable &DV, + bool isScopeAbstract) { StringRef Name = DV.getName(); // Define variable debug information entry. - DIE *VariableDie = new DIE(DV.getTag()); + auto VariableDie = make_unique<DIE>(DV.getTag()); DbgVariable *AbsVar = DV.getAbstractVariable(); DIE *AbsDIE = AbsVar ? AbsVar->getDIE() : nullptr; if (AbsDIE) |