llvm.org GIT mirror llvm / 7bd541a
TableGen: unique_ptr-ify RecordKeeper git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216350 91177308-0d34-0410-b5e6-96231b3b80d8 Dylan Noblesmith 6 years ago
4 changed file(s) with 23 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
16491649 };
16501650
16511651 class RecordKeeper {
1652 std::map Classes, Defs;
1653
1654 public:
1655 ~RecordKeeper() {
1656 for (std::map::iterator I = Classes.begin(),
1657 E = Classes.end(); I != E; ++I)
1658 delete I->second;
1659 for (std::map::iterator I = Defs.begin(),
1660 E = Defs.end(); I != E; ++I)
1661 delete I->second;
1662 }
1663
1664 const std::map &getClasses() const { return Classes; }
1665 const std::map &getDefs() const { return Defs; }
1652 typedef std::map> RecordMap;
1653 RecordMap Classes, Defs;
1654
1655 public:
1656 const RecordMap &getClasses() const { return Classes; }
1657 const RecordMap &getDefs() const { return Defs; }
16661658
16671659 Record *getClass(const std::string &Name) const {
1668 std::map::const_iterator I = Classes.find(Name);
1669 return I == Classes.end() ? nullptr : I->second;
1660 auto I = Classes.find(Name);
1661 return I == Classes.end() ? nullptr : I->second.get();
16701662 }
16711663 Record *getDef(const std::string &Name) const {
1672 std::map::const_iterator I = Defs.find(Name);
1673 return I == Defs.end() ? nullptr : I->second;
1674 }
1675 void addClass(Record *R) {
1676 bool Ins = Classes.insert(std::make_pair(R->getName(), R)).second;
1664 auto I = Defs.find(Name);
1665 return I == Defs.end() ? nullptr : I->second.get();
1666 }
1667 void addClass(Record *_R) {
1668 std::unique_ptr R(_R);
1669 bool Ins = Classes.insert(std::make_pair(R->getName(),
1670 std::move(R))).second;
16771671 (void)Ins;
16781672 assert(Ins && "Class already exists");
16791673 }
1680 void addDef(Record *R) {
1681 bool Ins = Defs.insert(std::make_pair(R->getName(), R)).second;
1674 void addDef(Record *_R) {
1675 std::unique_ptr R(_R);
1676 bool Ins = Defs.insert(std::make_pair(R->getName(),
1677 std::move(R))).second;
16821678 (void)Ins;
16831679 assert(Ins && "Record already exists");
16841680 }
20302030 std::vector Defs;
20312031 for (const auto &D : getDefs())
20322032 if (D.second->isSubClassOf(Class))
2033 Defs.push_back(D.second);
2033 Defs.push_back(D.second.get());
20342034
20352035 return Defs;
20362036 }
7474 // Collect tags.
7575 Tags.reserve(Classes.size() + Defs.size());
7676 for (const auto &C : Classes)
77 Tags.push_back(Tag(C.first, locate(C.second)));
77 Tags.push_back(Tag(C.first, locate(C.second.get())));
7878 for (const auto &D : Defs)
79 Tags.push_back(Tag(D.first, locate(D.second)));
79 Tags.push_back(Tag(D.first, locate(D.second.get())));
8080 // Emit tags.
8181 std::sort(Tags.begin(), Tags.end());
8282 OS << "!_TAG_FILE_FORMAT\t1\t/original ctags format/\n";
279279 for (const auto &D : Records.getDefs()) {
280280 if (D.second->isSubClassOf(ExpansionClass) &&
281281 D.second->isSubClassOf(InstructionClass))
282 Insts.push_back(D.second);
282 Insts.push_back(D.second.get());
283283 }
284284
285285 // Process the pseudo expansion definitions, validating them as we do so.