[llvm] r315254 - [MC] Plumb unique_ptr<MCELFObjectTargetWriter> through createELFObjectWriter to
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 9 16:53:15 PDT 2017
Author: lhames
Date: Mon Oct 9 16:53:15 2017
New Revision: 315254
URL: http://llvm.org/viewvc/llvm-project?rev=315254&view=rev
Log:
[MC] Plumb unique_ptr<MCELFObjectTargetWriter> through createELFObjectWriter to
ELFObjectWriter's constructor.
Fixes the same ownership issue for ELF that r315245 did for MachO:
ELFObjectWriter takes ownership of its MCELFObjectTargetWriter, so we want to
pass this through to the constructor via a unique_ptr, rather than a raw ptr.
Modified:
llvm/trunk/include/llvm/MC/MCELFObjectWriter.h
llvm/trunk/lib/MC/ELFObjectWriter.cpp
llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp
llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp
llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp
llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFELFObjectWriter.cpp
llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonELFObjectWriter.cpp
llvm/trunk/lib/Target/Lanai/MCTargetDesc/LanaiELFObjectWriter.cpp
llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcELFObjectWriter.cpp
llvm/trunk/lib/Target/SystemZ/MCTargetDesc/SystemZMCObjectWriter.cpp
llvm/trunk/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
Modified: llvm/trunk/include/llvm/MC/MCELFObjectWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCELFObjectWriter.h?rev=315254&r1=315253&r2=315254&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCELFObjectWriter.h (original)
+++ llvm/trunk/include/llvm/MC/MCELFObjectWriter.h Mon Oct 9 16:53:15 2017
@@ -137,9 +137,9 @@ public:
/// \param MOTW - The target specific ELF writer subclass.
/// \param OS - The stream to write to.
/// \returns The constructed object writer.
-MCObjectWriter *createELFObjectWriter(MCELFObjectTargetWriter *MOTW,
- raw_pwrite_stream &OS,
- bool IsLittleEndian);
+MCObjectWriter *
+createELFObjectWriter(std::unique_ptr<MCELFObjectTargetWriter> MOTW,
+ raw_pwrite_stream &OS, bool IsLittleEndian);
} // end namespace llvm
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=315254&r1=315253&r2=315254&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Mon Oct 9 16:53:15 2017
@@ -162,9 +162,10 @@ class ELFObjectWriter : public MCObjectW
bool ZLibStyle, unsigned Alignment);
public:
- ELFObjectWriter(MCELFObjectTargetWriter *MOTW, raw_pwrite_stream &OS,
- bool IsLittleEndian)
- : MCObjectWriter(OS, IsLittleEndian), TargetObjectWriter(MOTW) {}
+ ELFObjectWriter(std::unique_ptr<MCELFObjectTargetWriter> MOTW,
+ raw_pwrite_stream &OS, bool IsLittleEndian)
+ : MCObjectWriter(OS, IsLittleEndian),
+ TargetObjectWriter(std::move(MOTW)) {}
~ELFObjectWriter() override = default;
@@ -1386,8 +1387,8 @@ bool ELFObjectWriter::isSymbolRefDiffere
InSet, IsPCRel);
}
-MCObjectWriter *llvm::createELFObjectWriter(MCELFObjectTargetWriter *MOTW,
- raw_pwrite_stream &OS,
- bool IsLittleEndian) {
- return new ELFObjectWriter(MOTW, OS, IsLittleEndian);
+MCObjectWriter *
+llvm::createELFObjectWriter(std::unique_ptr<MCELFObjectTargetWriter> MOTW,
+ raw_pwrite_stream &OS, bool IsLittleEndian) {
+ return new ELFObjectWriter(std::move(MOTW), OS, IsLittleEndian);
}
Modified: llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp?rev=315254&r1=315253&r2=315254&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp Mon Oct 9 16:53:15 2017
@@ -432,7 +432,7 @@ MCObjectWriter *llvm::createAArch64ELFOb
uint8_t OSABI,
bool IsLittleEndian,
bool IsILP32) {
- MCELFObjectTargetWriter *MOTW =
- new AArch64ELFObjectWriter(OSABI, IsLittleEndian, IsILP32);
- return createELFObjectWriter(MOTW, OS, IsLittleEndian);
+ auto MOTW =
+ llvm::make_unique<AArch64ELFObjectWriter>(OSABI, IsLittleEndian, IsILP32);
+ return createELFObjectWriter(std::move(MOTW), OS, IsLittleEndian);
}
Modified: llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp?rev=315254&r1=315253&r2=315254&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp Mon Oct 9 16:53:15 2017
@@ -85,7 +85,7 @@ MCObjectWriter *llvm::createAMDGPUELFObj
uint8_t OSABI,
bool HasRelocationAddend,
raw_pwrite_stream &OS) {
- MCELFObjectTargetWriter *MOTW =
- new AMDGPUELFObjectWriter(Is64Bit, OSABI, HasRelocationAddend);
- return createELFObjectWriter(MOTW, OS, true);
+ auto MOTW = llvm::make_unique<AMDGPUELFObjectWriter>(Is64Bit, OSABI,
+ HasRelocationAddend);
+ return createELFObjectWriter(std::move(MOTW), OS, true);
}
Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp?rev=315254&r1=315253&r2=315254&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp Mon Oct 9 16:53:15 2017
@@ -238,6 +238,6 @@ unsigned ARMELFObjectWriter::GetRelocTyp
MCObjectWriter *llvm::createARMELFObjectWriter(raw_pwrite_stream &OS,
uint8_t OSABI,
bool IsLittleEndian) {
- MCELFObjectTargetWriter *MOTW = new ARMELFObjectWriter(OSABI);
- return createELFObjectWriter(MOTW, OS, IsLittleEndian);
+ return createELFObjectWriter(llvm::make_unique<ARMELFObjectWriter>(OSABI), OS,
+ IsLittleEndian);
}
Modified: llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFELFObjectWriter.cpp?rev=315254&r1=315253&r2=315254&view=diff
==============================================================================
--- llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFELFObjectWriter.cpp Mon Oct 9 16:53:15 2017
@@ -54,6 +54,6 @@ unsigned BPFELFObjectWriter::getRelocTyp
MCObjectWriter *llvm::createBPFELFObjectWriter(raw_pwrite_stream &OS,
uint8_t OSABI, bool IsLittleEndian) {
- MCELFObjectTargetWriter *MOTW = new BPFELFObjectWriter(OSABI);
- return createELFObjectWriter(MOTW, OS, IsLittleEndian);
+ return createELFObjectWriter(llvm::make_unique<BPFELFObjectWriter>(OSABI), OS,
+ IsLittleEndian);
}
Modified: llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonELFObjectWriter.cpp?rev=315254&r1=315253&r2=315254&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonELFObjectWriter.cpp Mon Oct 9 16:53:15 2017
@@ -300,6 +300,6 @@ unsigned HexagonELFObjectWriter::getRelo
MCObjectWriter *llvm::createHexagonELFObjectWriter(raw_pwrite_stream &OS,
uint8_t OSABI,
StringRef CPU) {
- MCELFObjectTargetWriter *MOTW = new HexagonELFObjectWriter(OSABI, CPU);
- return createELFObjectWriter(MOTW, OS, /*IsLittleEndian*/ true);
+ auto MOTW = llvm::make_unique<HexagonELFObjectWriter>(OSABI, CPU);
+ return createELFObjectWriter(std::move(MOTW), OS, /*IsLittleEndian*/ true);
}
Modified: llvm/trunk/lib/Target/Lanai/MCTargetDesc/LanaiELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Lanai/MCTargetDesc/LanaiELFObjectWriter.cpp?rev=315254&r1=315253&r2=315254&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Lanai/MCTargetDesc/LanaiELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/Lanai/MCTargetDesc/LanaiELFObjectWriter.cpp Mon Oct 9 16:53:15 2017
@@ -88,6 +88,6 @@ bool LanaiELFObjectWriter::needsRelocate
MCObjectWriter *llvm::createLanaiELFObjectWriter(raw_pwrite_stream &OS,
uint8_t OSABI) {
- MCELFObjectTargetWriter *MOTW = new LanaiELFObjectWriter(OSABI);
- return createELFObjectWriter(MOTW, OS, /*IsLittleEndian=*/false);
+ return createELFObjectWriter(llvm::make_unique<LanaiELFObjectWriter>(OSABI),
+ OS, /*IsLittleEndian=*/false);
}
Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp?rev=315254&r1=315253&r2=315254&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp Mon Oct 9 16:53:15 2017
@@ -660,7 +660,7 @@ MCObjectWriter *llvm::createMipsELFObjec
uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TT.getOS());
bool IsN64 = TT.isArch64Bit() && !IsN32;
bool HasRelocationAddend = TT.isArch64Bit();
- auto *MOTW = new MipsELFObjectWriter(OSABI, HasRelocationAddend, IsN64,
- TT.isLittleEndian());
- return createELFObjectWriter(MOTW, OS, TT.isLittleEndian());
+ auto MOTW = llvm::make_unique<MipsELFObjectWriter>(
+ OSABI, HasRelocationAddend, IsN64, TT.isLittleEndian());
+ return createELFObjectWriter(std::move(MOTW), OS, TT.isLittleEndian());
}
Modified: llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp?rev=315254&r1=315253&r2=315254&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp Mon Oct 9 16:53:15 2017
@@ -420,6 +420,6 @@ MCObjectWriter *llvm::createPPCELFObject
bool Is64Bit,
bool IsLittleEndian,
uint8_t OSABI) {
- MCELFObjectTargetWriter *MOTW = new PPCELFObjectWriter(Is64Bit, OSABI);
- return createELFObjectWriter(MOTW, OS, IsLittleEndian);
+ auto MOTW = llvm::make_unique<PPCELFObjectWriter>(Is64Bit, OSABI);
+ return createELFObjectWriter(std::move(MOTW), OS, IsLittleEndian);
}
Modified: llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcELFObjectWriter.cpp?rev=315254&r1=315253&r2=315254&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcELFObjectWriter.cpp Mon Oct 9 16:53:15 2017
@@ -135,6 +135,6 @@ MCObjectWriter *llvm::createSparcELFObje
bool Is64Bit,
bool IsLittleEndian,
uint8_t OSABI) {
- MCELFObjectTargetWriter *MOTW = new SparcELFObjectWriter(Is64Bit, OSABI);
- return createELFObjectWriter(MOTW, OS, IsLittleEndian);
+ auto MOTW = llvm::make_unique<SparcELFObjectWriter>(Is64Bit, OSABI);
+ return createELFObjectWriter(std::move(MOTW), OS, IsLittleEndian);
}
Modified: llvm/trunk/lib/Target/SystemZ/MCTargetDesc/SystemZMCObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/MCTargetDesc/SystemZMCObjectWriter.cpp?rev=315254&r1=315253&r2=315254&view=diff
==============================================================================
--- llvm/trunk/lib/Target/SystemZ/MCTargetDesc/SystemZMCObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/SystemZ/MCTargetDesc/SystemZMCObjectWriter.cpp Mon Oct 9 16:53:15 2017
@@ -162,6 +162,6 @@ unsigned SystemZObjectWriter::getRelocTy
MCObjectWriter *llvm::createSystemZObjectWriter(raw_pwrite_stream &OS,
uint8_t OSABI) {
- MCELFObjectTargetWriter *MOTW = new SystemZObjectWriter(OSABI);
- return createELFObjectWriter(MOTW, OS, /*IsLittleEndian=*/false);
+ return createELFObjectWriter(llvm::make_unique<SystemZObjectWriter>(OSABI),
+ OS, /*IsLittleEndian=*/false);
}
Modified: llvm/trunk/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp?rev=315254&r1=315253&r2=315254&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp Mon Oct 9 16:53:15 2017
@@ -300,7 +300,6 @@ unsigned X86ELFObjectWriter::getRelocTyp
MCObjectWriter *llvm::createX86ELFObjectWriter(raw_pwrite_stream &OS,
bool IsELF64, uint8_t OSABI,
uint16_t EMachine) {
- MCELFObjectTargetWriter *MOTW =
- new X86ELFObjectWriter(IsELF64, OSABI, EMachine);
- return createELFObjectWriter(MOTW, OS, /*IsLittleEndian=*/true);
+ auto MOTW = llvm::make_unique<X86ELFObjectWriter>(IsELF64, OSABI, EMachine);
+ return createELFObjectWriter(std::move(MOTW), OS, /*IsLittleEndian=*/true);
}
More information about the llvm-commits
mailing list