llvm.org GIT mirror llvm / 2935bbc
Make RecordKeeper::addClass/addDef take unique_ptrs instead of creating one internally. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222948 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 6 years ago
2 changed file(s) with 10 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
16871687 auto I = Defs.find(Name);
16881688 return I == Defs.end() ? nullptr : I->second.get();
16891689 }
1690 void addClass(Record *_R) {
1691 std::unique_ptr R(_R);
1690 void addClass(std::unique_ptr R) {
16921691 bool Ins = Classes.insert(std::make_pair(R->getName(),
16931692 std::move(R))).second;
16941693 (void)Ins;
16951694 assert(Ins && "Class already exists");
16961695 }
1697 void addDef(Record *_R) {
1698 std::unique_ptr R(_R);
1696 void addDef(std::unique_ptr R) {
16991697 bool Ins = Defs.insert(std::make_pair(R->getName(),
17001698 std::move(R))).second;
17011699 (void)Ins;
370370 }
371371
372372 Record *IterRecSave = IterRec.get(); // Keep a copy before release.
373 Records.addDef(IterRec.release());
373 Records.addDef(std::move(IterRec));
374374 IterRecSave->resolveReferences();
375375 return false;
376376 }
12511251
12521252 if (!CurMultiClass) {
12531253 NewRec->resolveReferences();
1254 Records.addDef(NewRecOwner.release());
1254 Records.addDef(std::move(NewRecOwner));
12551255 } else {
12561256 // This needs to get resolved once the multiclass template arguments are
12571257 // known before any use.
20432043 if (Records.getDef(CurRec->getNameInitAsString()))
20442044 return Error(DefLoc, "def '" + CurRec->getNameInitAsString()+
20452045 "' already defined");
2046 Records.addDef(CurRecOwner.release());
2046 Records.addDef(std::move(CurRecOwner));
20472047
20482048 if (ParseObjectBody(CurRec))
20492049 return true;
21682168 + "' already defined");
21692169 } else {
21702170 // If this is the first reference to this class, create and add it.
2171 CurRec = new Record(Lex.getCurStrVal(), Lex.getLoc(), Records);
2172 Records.addClass(CurRec);
2171 auto NewRec = make_unique(Lex.getCurStrVal(), Lex.getLoc(),
2172 Records);
2173 CurRec = NewRec.get();
2174 Records.addClass(std::move(NewRec));
21732175 }
21742176 Lex.Lex(); // eat the name.
21752177
24412443 }
24422444
24432445 Record *CurRecSave = CurRec.get(); // Keep a copy before we release.
2444 Records.addDef(CurRec.release());
2446 Records.addDef(std::move(CurRec));
24452447 return CurRecSave;
24462448 }
24472449