From 0c83952c2e75a70f802728ed893f3d9cb77d03fc Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Fri, 28 Nov 2014 20:30:37 +0000 Subject: [PATCH] Use unique_ptr to simplify deletion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222929 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/CodeGenTarget.cpp | 8 +++----- utils/TableGen/CodeGenTarget.h | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/utils/TableGen/CodeGenTarget.cpp b/utils/TableGen/CodeGenTarget.cpp index f4f5e2b2346..b871e067794 100644 --- a/utils/TableGen/CodeGenTarget.cpp +++ b/utils/TableGen/CodeGenTarget.cpp @@ -133,7 +133,7 @@ std::string llvm::getQualifiedName(const Record *R) { /// getTarget - Return the current instance of the Target class. /// CodeGenTarget::CodeGenTarget(RecordKeeper &records) - : Records(records), RegBank(nullptr), SchedModels(nullptr) { + : Records(records) { std::vector Targets = Records.getAllDerivedDefinitions("Target"); if (Targets.size() == 0) PrintFatalError("ERROR: No 'Target' subclasses defined!"); @@ -144,8 +144,6 @@ CodeGenTarget::CodeGenTarget(RecordKeeper &records) CodeGenTarget::~CodeGenTarget() { DeleteContainerSeconds(Instructions); - delete RegBank; - delete SchedModels; } const std::string &CodeGenTarget::getName() const { @@ -211,7 +209,7 @@ Record *CodeGenTarget::getAsmWriter() const { CodeGenRegBank &CodeGenTarget::getRegBank() const { if (!RegBank) - RegBank = new CodeGenRegBank(Records); + RegBank = llvm::make_unique(Records); return *RegBank; } @@ -265,7 +263,7 @@ void CodeGenTarget::ReadLegalValueTypes() const { CodeGenSchedModels &CodeGenTarget::getSchedModels() const { if (!SchedModels) - SchedModels = new CodeGenSchedModels(Records, *this); + SchedModels = llvm::make_unique(Records, *this); return *SchedModels; } diff --git a/utils/TableGen/CodeGenTarget.h b/utils/TableGen/CodeGenTarget.h index f4e1b6ad6d5..a46c9a6ffff 100644 --- a/utils/TableGen/CodeGenTarget.h +++ b/utils/TableGen/CodeGenTarget.h @@ -66,14 +66,14 @@ class CodeGenTarget { Record *TargetRec; mutable DenseMap Instructions; - mutable CodeGenRegBank *RegBank; + mutable std::unique_ptr RegBank; mutable std::vector RegAltNameIndices; mutable SmallVector LegalValueTypes; void ReadRegAltNameIndices() const; void ReadInstructions() const; void ReadLegalValueTypes() const; - mutable CodeGenSchedModels *SchedModels; + mutable std::unique_ptr SchedModels; mutable std::vector InstrsByEnum; public: