llvm.org GIT mirror llvm / a1fa859
Make MultiClass::DefPrototypes own their Records to fix memory leaks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222965 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 6 years ago
2 changed file(s) with 7 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
16621662
16631663 struct MultiClass {
16641664 Record Rec; // Placeholder for template args and Name.
1665 typedef std::vector<Record*> RecordVector;
1665 typedef std::vector<std::unique_ptr> RecordVector;
16661666 RecordVector DefPrototypes;
16671667
16681668 void dump() const;
238238 if (AddValue(NewDef.get(), SubMultiClass.RefRange.Start, MCVals[i]))
239239 return true;
240240
241 CurMC->DefPrototypes.push_back(NewDef.release());
241 CurMC->DefPrototypes.push_back(std::move(NewDef));
242242 }
243243
244244 const std::vector &SMCTArgs = SMC->Rec.getTemplateArgs();
273273 jend = CurMC->DefPrototypes.end();
274274 j != jend;
275275 ++j) {
276 Record *Def = *j;
276 Record *Def = j->get();
277277
278278 if (SetValue(Def, SubMultiClass.RefRange.Start, SMCTArgs[i],
279279 std::vector(),
12571257 // known before any use.
12581258 NewRec->setResolveFirst(true);
12591259 // Otherwise, we're inside a multiclass, add it to the multiclass.
1260 CurMultiClass->DefPrototypes.push_back(NewRecOwner.release());
1260 CurMultiClass->DefPrototypes.push_back(std::move(NewRecOwner));
12611261
12621262 // Copy the template arguments for the multiclass into the def.
12631263 const std::vector &TArgs =
20622062 == CurRec->getNameInit())
20632063 return Error(DefLoc, "def '" + CurRec->getNameInitAsString() +
20642064 "' already defined in this multiclass!");
2065 CurMultiClass->DefPrototypes.push_back(CurRecOwner.release());
2065 CurMultiClass->DefPrototypes.push_back(std::move(CurRecOwner));
20662066 } else if (ParseObjectBody(CurRec)) {
20672067 return true;
20682068 }
25062506 == CurRec->getNameInit())
25072507 return Error(DefmPrefixLoc, "defm '" + CurRec->getNameInitAsString() +
25082508 "' already defined in this multiclass!");
2509 CurMultiClass->DefPrototypes.push_back(CurRec);
2509 CurMultiClass->DefPrototypes.push_back(std::unique_ptr(CurRec));
25102510
25112511 // Copy the template arguments for the multiclass into the new def.
25122512 const std::vector &TA =
25692569
25702570 // Loop over all the def's in the multiclass, instantiating each one.
25712571 for (unsigned i = 0, e = MC->DefPrototypes.size(); i != e; ++i) {
2572 Record *DefProto = MC->DefPrototypes[i];
2572 Record *DefProto = MC->DefPrototypes[i].get();
25732573
25742574 Record *CurRec = InstantiateMulticlassDef(*MC, DefProto, DefmPrefix,
25752575 SMRange(DefmLoc,