[llvm] r315245 - [MC] Plumb unique_ptr<MCMachObjectTargetWriter> through createMachObjectWriter
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 9 15:38:13 PDT 2017
Author: lhames
Date: Mon Oct 9 15:38:13 2017
New Revision: 315245
URL: http://llvm.org/viewvc/llvm-project?rev=315245&view=rev
Log:
[MC] Plumb unique_ptr<MCMachObjectTargetWriter> through createMachObjectWriter
to MCObjectWriter's constructor.
MCObjectWriter takes ownership of its MCMachObjectTargetWriter argument -- this
patch plumbs that ownership relationship through the constructor (which
previously took raw MCMachObjectTargetWriter*) and the createMachObjectWriter
function.
Modified:
llvm/trunk/include/llvm/MC/MCMachObjectWriter.h
llvm/trunk/lib/MC/MachObjectWriter.cpp
llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp
llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMachObjectWriter.cpp
llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
Modified: llvm/trunk/include/llvm/MC/MCMachObjectWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCMachObjectWriter.h?rev=315245&r1=315244&r2=315245&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCMachObjectWriter.h (original)
+++ llvm/trunk/include/llvm/MC/MCMachObjectWriter.h Mon Oct 9 15:38:13 2017
@@ -117,9 +117,10 @@ class MachObjectWriter : public MCObject
MachSymbolData *findSymbolData(const MCSymbol &Sym);
public:
- MachObjectWriter(MCMachObjectTargetWriter *MOTW, raw_pwrite_stream &OS,
- bool IsLittleEndian)
- : MCObjectWriter(OS, IsLittleEndian), TargetObjectWriter(MOTW) {}
+ MachObjectWriter(std::unique_ptr<MCMachObjectTargetWriter> MOTW,
+ raw_pwrite_stream &OS, bool IsLittleEndian)
+ : MCObjectWriter(OS, IsLittleEndian),
+ TargetObjectWriter(std::move(MOTW)) {}
const MCSymbol &findAliasedSymbol(const MCSymbol &Sym) const;
@@ -269,9 +270,9 @@ public:
/// \param MOTW - The target specific Mach-O writer subclass.
/// \param OS - The stream to write to.
/// \returns The constructed object writer.
-MCObjectWriter *createMachObjectWriter(MCMachObjectTargetWriter *MOTW,
- raw_pwrite_stream &OS,
- bool IsLittleEndian);
+MCObjectWriter *
+createMachObjectWriter(std::unique_ptr<MCMachObjectTargetWriter> MOTW,
+ raw_pwrite_stream &OS, bool IsLittleEndian);
} // end namespace llvm
Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=315245&r1=315244&r2=315245&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/MachObjectWriter.cpp Mon Oct 9 15:38:13 2017
@@ -994,8 +994,8 @@ void MachObjectWriter::writeObject(MCAss
}
}
-MCObjectWriter *llvm::createMachObjectWriter(MCMachObjectTargetWriter *MOTW,
- raw_pwrite_stream &OS,
- bool IsLittleEndian) {
- return new MachObjectWriter(MOTW, OS, IsLittleEndian);
+MCObjectWriter *
+llvm::createMachObjectWriter(std::unique_ptr<MCMachObjectTargetWriter> MOTW,
+ raw_pwrite_stream &OS, bool IsLittleEndian) {
+ return new MachObjectWriter(std::move(MOTW), OS, IsLittleEndian);
}
Modified: llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp?rev=315245&r1=315244&r2=315245&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp Mon Oct 9 15:38:13 2017
@@ -434,6 +434,6 @@ MCObjectWriter *llvm::createAArch64MachO
uint32_t CPUType,
uint32_t CPUSubtype) {
return createMachObjectWriter(
- new AArch64MachObjectWriter(CPUType, CPUSubtype), OS,
+ llvm::make_unique<AArch64MachObjectWriter>(CPUType, CPUSubtype), OS,
/*IsLittleEndian=*/true);
}
Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp?rev=315245&r1=315244&r2=315245&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp Mon Oct 9 15:38:13 2017
@@ -487,8 +487,7 @@ void ARMMachObjectWriter::recordRelocati
MCObjectWriter *llvm::createARMMachObjectWriter(raw_pwrite_stream &OS,
bool Is64Bit, uint32_t CPUType,
uint32_t CPUSubtype) {
- return createMachObjectWriter(new ARMMachObjectWriter(Is64Bit,
- CPUType,
- CPUSubtype),
- OS, /*IsLittleEndian=*/true);
+ return createMachObjectWriter(
+ llvm::make_unique<ARMMachObjectWriter>(Is64Bit, CPUType, CPUSubtype), OS,
+ /*IsLittleEndian=*/true);
}
Modified: llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMachObjectWriter.cpp?rev=315245&r1=315244&r2=315245&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMachObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMachObjectWriter.cpp Mon Oct 9 15:38:13 2017
@@ -378,6 +378,6 @@ MCObjectWriter *llvm::createPPCMachObjec
bool Is64Bit, uint32_t CPUType,
uint32_t CPUSubtype) {
return createMachObjectWriter(
- new PPCMachObjectWriter(Is64Bit, CPUType, CPUSubtype), OS,
+ llvm::make_unique<PPCMachObjectWriter>(Is64Bit, CPUType, CPUSubtype), OS,
/*IsLittleEndian=*/false);
}
Modified: llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp?rev=315245&r1=315244&r2=315245&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp Mon Oct 9 15:38:13 2017
@@ -600,8 +600,7 @@ void X86MachObjectWriter::RecordX86Reloc
MCObjectWriter *llvm::createX86MachObjectWriter(raw_pwrite_stream &OS,
bool Is64Bit, uint32_t CPUType,
uint32_t CPUSubtype) {
- return createMachObjectWriter(new X86MachObjectWriter(Is64Bit,
- CPUType,
- CPUSubtype),
- OS, /*IsLittleEndian=*/true);
+ return createMachObjectWriter(
+ llvm::make_unique<X86MachObjectWriter>(Is64Bit, CPUType, CPUSubtype), OS,
+ /*IsLittleEndian=*/true);
}
More information about the llvm-commits
mailing list