From 9c84db6ba390f4e6ac1d6ce94fa9a6428e0b3007 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Tue, 10 Jun 2014 23:26:47 +0000 Subject: [PATCH] Use unique_ptr for X86Subtarget pointer members. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210606 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86Subtarget.cpp | 19 ++++++------------- lib/Target/X86/X86Subtarget.h | 19 ++++++++++--------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/lib/Target/X86/X86Subtarget.cpp b/lib/Target/X86/X86Subtarget.cpp index 29c44adaa29..f0c939c47d8 100644 --- a/lib/Target/X86/X86Subtarget.cpp +++ b/lib/Target/X86/X86Subtarget.cpp @@ -351,19 +351,12 @@ X86Subtarget::X86Subtarget(const std::string &TT, const std::string &CPU, resetSubtargetFeatures(CPU, FS); // Ordering here is important. X86InstrInfo initializes X86RegisterInfo which // X86TargetLowering needs. - InstrInfo = new X86InstrInfo(*this); - TLInfo = new X86TargetLowering(TM); - FrameLowering = new X86FrameLowering(TargetFrameLowering::StackGrowsDown, - getStackAlignment(), - is64Bit() ? -8 : -4); - JITInfo = new X86JITInfo(hasSSE1()); -} - -X86Subtarget::~X86Subtarget() { - delete TLInfo; - delete InstrInfo; - delete FrameLowering; - delete JITInfo; + InstrInfo = make_unique(*this); + TLInfo = make_unique(TM); + FrameLowering = + make_unique(TargetFrameLowering::StackGrowsDown, + getStackAlignment(), is64Bit() ? -8 : -4); + JITInfo = make_unique(hasSSE1()); } bool diff --git a/lib/Target/X86/X86Subtarget.h b/lib/Target/X86/X86Subtarget.h index 9e4200c110a..85da720cbc2 100644 --- a/lib/Target/X86/X86Subtarget.h +++ b/lib/Target/X86/X86Subtarget.h @@ -229,10 +229,10 @@ private: // Calculates type size & alignment const DataLayout DL; X86SelectionDAGInfo TSInfo; - X86TargetLowering *TLInfo; - X86InstrInfo *InstrInfo; - X86FrameLowering *FrameLowering; - X86JITInfo *JITInfo; + std::unique_ptr TLInfo; + std::unique_ptr InstrInfo; + std::unique_ptr FrameLowering; + std::unique_ptr JITInfo; public: /// This constructor initializes the data members to match that @@ -241,14 +241,15 @@ public: X86Subtarget(const std::string &TT, const std::string &CPU, const std::string &FS, X86TargetMachine &TM, unsigned StackAlignOverride); - ~X86Subtarget(); - const X86TargetLowering *getTargetLowering() const { return TLInfo; } - const X86InstrInfo *getInstrInfo() const { return InstrInfo; } + const X86TargetLowering *getTargetLowering() const { return TLInfo.get(); } + const X86InstrInfo *getInstrInfo() const { return InstrInfo.get(); } const DataLayout *getDataLayout() const { return &DL; } - const X86FrameLowering *getFrameLowering() const { return FrameLowering; } + const X86FrameLowering *getFrameLowering() const { + return FrameLowering.get(); + } const X86SelectionDAGInfo *getSelectionDAGInfo() const { return &TSInfo; } - X86JITInfo *getJITInfo() { return JITInfo; } + X86JITInfo *getJITInfo() { return JITInfo.get(); } /// getStackAlignment - Returns the minimum alignment known to hold of the /// stack frame on entry to the function and which must be maintained by every -- 2.34.1