<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Nov 29, 2014 at 4:19 PM, Craig Topper <span dir="ltr"><<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ctopper<br>
Date: Sat Nov 29 18:19:28 2014<br>
New Revision: 222965<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=222965&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=222965&view=rev</a><br>
Log:<br>
Make MultiClass::DefPrototypes own their Records to fix memory leaks.<br>
<br>
Modified:<br>
llvm/trunk/include/llvm/TableGen/Record.h<br>
llvm/trunk/lib/TableGen/TGParser.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/TableGen/Record.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/TableGen/Record.h?rev=222965&r1=222964&r2=222965&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/TableGen/Record.h?rev=222965&r1=222964&r2=222965&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/TableGen/Record.h (original)<br>
+++ llvm/trunk/include/llvm/TableGen/Record.h Sat Nov 29 18:19:28 2014<br>
@@ -1663,7 +1663,7 @@ raw_ostream &operator<<(raw_ostream &OS,<br>
<br>
struct MultiClass {<br>
Record Rec; // Placeholder for template args and Name.<br>
- typedef std::vector<Record*> RecordVector;<br>
+ typedef std::vector<std::unique_ptr<Record>> RecordVector;<br></blockquote><div><br>Any chance of deque<Record> (or forward_list<Record> or list<Record>) here?<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
RecordVector DefPrototypes;<br>
<br>
void dump() const;<br>
<br>
Modified: llvm/trunk/lib/TableGen/TGParser.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.cpp?rev=222965&r1=222964&r2=222965&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.cpp?rev=222965&r1=222964&r2=222965&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/TableGen/TGParser.cpp (original)<br>
+++ llvm/trunk/lib/TableGen/TGParser.cpp Sat Nov 29 18:19:28 2014<br>
@@ -239,7 +239,7 @@ bool TGParser::AddSubMultiClass(MultiCla<br>
if (AddValue(NewDef.get(), SubMultiClass.RefRange.Start, MCVals[i]))<br>
return true;<br>
<br>
- CurMC->DefPrototypes.push_back(NewDef.release());<br>
+ CurMC->DefPrototypes.push_back(std::move(NewDef));<br>
}<br>
<br>
const std::vector<Init *> &SMCTArgs = SMC->Rec.getTemplateArgs();<br>
@@ -274,7 +274,7 @@ bool TGParser::AddSubMultiClass(MultiCla<br>
jend = CurMC->DefPrototypes.end();<br>
j != jend;<br>
++j) {<br>
- Record *Def = *j;<br>
+ Record *Def = j->get();<br>
<br>
if (SetValue(Def, SubMultiClass.RefRange.Start, SMCTArgs[i],<br>
std::vector<unsigned>(),<br>
@@ -1258,7 +1258,7 @@ Init *TGParser::ParseSimpleValue(Record<br>
// known before any use.<br>
NewRec->setResolveFirst(true);<br>
// Otherwise, we're inside a multiclass, add it to the multiclass.<br>
- CurMultiClass->DefPrototypes.push_back(NewRecOwner.release());<br>
+ CurMultiClass->DefPrototypes.push_back(std::move(NewRecOwner));<br>
<br>
// Copy the template arguments for the multiclass into the def.<br>
const std::vector<Init *> &TArgs =<br>
@@ -2063,7 +2063,7 @@ bool TGParser::ParseDef(MultiClass *CurM<br>
== CurRec->getNameInit())<br>
return Error(DefLoc, "def '" + CurRec->getNameInitAsString() +<br>
"' already defined in this multiclass!");<br>
- CurMultiClass->DefPrototypes.push_back(CurRecOwner.release());<br>
+ CurMultiClass->DefPrototypes.push_back(std::move(CurRecOwner));<br>
} else if (ParseObjectBody(CurRec)) {<br>
return true;<br>
}<br>
@@ -2507,7 +2507,7 @@ bool TGParser::ResolveMulticlassDef(Mult<br>
== CurRec->getNameInit())<br>
return Error(DefmPrefixLoc, "defm '" + CurRec->getNameInitAsString() +<br>
"' already defined in this multiclass!");<br>
- CurMultiClass->DefPrototypes.push_back(CurRec);<br>
+ CurMultiClass->DefPrototypes.push_back(std::unique_ptr<Record>(CurRec));<br>
<br>
// Copy the template arguments for the multiclass into the new def.<br>
const std::vector<Init *> &TA =<br>
@@ -2570,7 +2570,7 @@ bool TGParser::ParseDefm(MultiClass *Cur<br>
<br>
// Loop over all the def's in the multiclass, instantiating each one.<br>
for (unsigned i = 0, e = MC->DefPrototypes.size(); i != e; ++i) {<br>
- Record *DefProto = MC->DefPrototypes[i];<br>
+ Record *DefProto = MC->DefPrototypes[i].get();<br>
<br>
Record *CurRec = InstantiateMulticlassDef(*MC, DefProto, DefmPrefix,<br>
SMRange(DefmLoc,<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>