From f492c9e61282bbbc3d87ad453480c12239594869 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Wed, 10 Dec 2014 06:18:57 +0000 Subject: [PATCH] Use unique_ptr instead of DeleteContainerSeconds. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223918 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/CodeGenTarget.cpp | 15 +++++++-------- utils/TableGen/CodeGenTarget.h | 9 +++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/utils/TableGen/CodeGenTarget.cpp b/utils/TableGen/CodeGenTarget.cpp index 1cb66a86d52..1f13a20c8d9 100644 --- a/utils/TableGen/CodeGenTarget.cpp +++ b/utils/TableGen/CodeGenTarget.cpp @@ -143,7 +143,6 @@ CodeGenTarget::CodeGenTarget(RecordKeeper &records) } CodeGenTarget::~CodeGenTarget() { - DeleteContainerSeconds(Instructions); } const std::string &CodeGenTarget::getName() const { @@ -270,20 +269,20 @@ void CodeGenTarget::ReadInstructions() const { // Parse the instructions defined in the .td file. for (unsigned i = 0, e = Insts.size(); i != e; ++i) - Instructions[Insts[i]] = new CodeGenInstruction(Insts[i]); + Instructions[Insts[i]] = llvm::make_unique(Insts[i]); } static const CodeGenInstruction * GetInstByName(const char *Name, - const DenseMap &Insts, + const DenseMap> &Insts, RecordKeeper &Records) { const Record *Rec = Records.getDef(Name); - DenseMap::const_iterator - I = Insts.find(Rec); + const auto I = Insts.find(Rec); if (!Rec || I == Insts.end()) PrintFatalError(Twine("Could not find '") + Name + "' instruction!"); - return I->second; + return I->second.get(); } /// \brief Return all of the instructions defined by the target, ordered by @@ -298,7 +297,7 @@ void CodeGenTarget::ComputeInstrsByEnum() const { "LIFETIME_END", "STACKMAP", "PATCHPOINT", "LOAD_STACK_GUARD", "STATEPOINT", nullptr}; - const DenseMap &Insts = getInstructions(); + const auto &Insts = getInstructions(); for (const char *const *p = FixedInstrs; *p; ++p) { const CodeGenInstruction *Instr = GetInstByName(*p, Insts, Records); assert(Instr && "Missing target independent instruction"); @@ -308,7 +307,7 @@ void CodeGenTarget::ComputeInstrsByEnum() const { unsigned EndOfPredefines = InstrsByEnum.size(); for (const auto &I : Insts) { - const CodeGenInstruction *CGI = I.second; + const CodeGenInstruction *CGI = I.second.get(); if (CGI->Namespace != "TargetOpcode") InstrsByEnum.push_back(CGI); } diff --git a/utils/TableGen/CodeGenTarget.h b/utils/TableGen/CodeGenTarget.h index a46c9a6ffff..24b38514260 100644 --- a/utils/TableGen/CodeGenTarget.h +++ b/utils/TableGen/CodeGenTarget.h @@ -65,7 +65,8 @@ class CodeGenTarget { RecordKeeper &Records; Record *TargetRec; - mutable DenseMap Instructions; + mutable DenseMap> Instructions; mutable std::unique_ptr RegBank; mutable std::vector RegAltNameIndices; mutable SmallVector LegalValueTypes; @@ -146,7 +147,8 @@ public: CodeGenSchedModels &getSchedModels() const; private: - DenseMap &getInstructions() const { + DenseMap> & + getInstructions() const { if (Instructions.empty()) ReadInstructions(); return Instructions; } @@ -154,8 +156,7 @@ public: CodeGenInstruction &getInstruction(const Record *InstRec) const { if (Instructions.empty()) ReadInstructions(); - DenseMap::iterator I = - Instructions.find(InstRec); + auto I = Instructions.find(InstRec); assert(I != Instructions.end() && "Not an instruction"); return *I->second; }