[llvm-commits] [llvm] r99196 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DIE.cpp DIE.h DwarfDebug.cpp
Jeffrey Yasskin
jyasskin at google.com
Mon Mar 22 11:47:14 PDT 2010
Author: jyasskin
Date: Mon Mar 22 13:47:14 2010
New Revision: 99196
URL: http://llvm.org/viewvc/llvm-project?rev=99196&view=rev
Log:
Fix a memory leak from DIE::addSiblingOffset() by adding the DIEValue
it allocates to DwarfDebug::DIEValues.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp?rev=99196&r1=99195&r2=99196&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp Mon Mar 22 13:47:14 2010
@@ -114,10 +114,11 @@
/// addSiblingOffset - Add a sibling offset field to the front of the DIE.
///
-void DIE::addSiblingOffset() {
+DIEValue *DIE::addSiblingOffset() {
DIEInteger *DI = new DIEInteger(0);
Values.insert(Values.begin(), DI);
Abbrev.AddFirstAttribute(dwarf::DW_AT_sibling, dwarf::DW_FORM_ref4);
+ return DI;
}
#ifndef NDEBUG
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h?rev=99196&r1=99195&r2=99196&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h Mon Mar 22 13:47:14 2010
@@ -153,7 +153,7 @@
unsigned getOffset() const { return Offset; }
unsigned getSize() const { return Size; }
const std::vector<DIE *> &getChildren() const { return Children; }
- SmallVector<DIEValue*, 32> &getValues() { return Values; }
+ const SmallVector<DIEValue*, 32> &getValues() const { return Values; }
DIE *getParent() const { return Parent; }
void setTag(unsigned Tag) { Abbrev.setTag(Tag); }
void setOffset(unsigned O) { Offset = O; }
@@ -171,8 +171,10 @@
unsigned getSiblingOffset() const { return Offset + Size; }
/// addSiblingOffset - Add a sibling offset field to the front of the DIE.
+ /// The caller is responsible for deleting the return value at or after the
+ /// same time it destroys this DIE.
///
- void addSiblingOffset();
+ DIEValue *addSiblingOffset();
/// addChild - Add a child to the DIE.
///
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=99196&r1=99195&r2=99196&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Mar 22 13:47:14 2010
@@ -2351,7 +2351,8 @@
const std::vector<DIE *> &Children = Die->getChildren();
// If not last sibling and has children then add sibling offset attribute.
- if (!Last && !Children.empty()) Die->addSiblingOffset();
+ if (!Last && !Children.empty())
+ DIEValues.push_back(Die->addSiblingOffset());
// Record the abbreviation.
assignAbbrevNumber(Die->getAbbrev());
@@ -2465,7 +2466,7 @@
dwarf::TagString(Abbrev->getTag()));
EmitULEB128(AbbrevNumber);
- SmallVector<DIEValue*, 32> &Values = Die->getValues();
+ const SmallVector<DIEValue*, 32> &Values = Die->getValues();
const SmallVector<DIEAbbrevData, 8> &AbbrevData = Abbrev->getData();
// Emit the DIE attribute values.
More information about the llvm-commits
mailing list