forked from OSchip/llvm-project
[MC] Plumb unique_ptr<MCWinCOFFObjectTargetWriter> through
createWinCOFFObjectWriter to WinCOFFObjectWriter's constructor. Fixes the same ownership issue for COFF that r315245 did for MachO: WinCOFFObjectWriter takes ownership of its MCWinCOFFObjectTargetWriter, so we want to pass this through to the constructor via a unique_ptr, rather than a raw ptr. llvm-svn: 315257
This commit is contained in:
parent
a0b68be6cf
commit
77dff39cb4
|
@ -42,7 +42,8 @@ class raw_pwrite_stream;
|
|||
/// \param MOTW - The target specific WinCOFF writer subclass.
|
||||
/// \param OS - The stream to write to.
|
||||
/// \returns The constructed object writer.
|
||||
MCObjectWriter *createWinCOFFObjectWriter(MCWinCOFFObjectTargetWriter *MOTW,
|
||||
MCObjectWriter *
|
||||
createWinCOFFObjectWriter(std::unique_ptr<MCWinCOFFObjectTargetWriter> MOTW,
|
||||
raw_pwrite_stream &OS);
|
||||
} // end namespace llvm
|
||||
|
||||
|
|
|
@ -145,7 +145,8 @@ public:
|
|||
|
||||
bool UseBigObj;
|
||||
|
||||
WinCOFFObjectWriter(MCWinCOFFObjectTargetWriter *MOTW, raw_pwrite_stream &OS);
|
||||
WinCOFFObjectWriter(std::unique_ptr<MCWinCOFFObjectTargetWriter> MOTW,
|
||||
raw_pwrite_stream &OS);
|
||||
|
||||
void reset() override {
|
||||
memset(&Header, 0, sizeof(Header));
|
||||
|
@ -222,9 +223,9 @@ void COFFSymbol::set_name_offset(uint32_t Offset) {
|
|||
//------------------------------------------------------------------------------
|
||||
// WinCOFFObjectWriter class implementation
|
||||
|
||||
WinCOFFObjectWriter::WinCOFFObjectWriter(MCWinCOFFObjectTargetWriter *MOTW,
|
||||
raw_pwrite_stream &OS)
|
||||
: MCObjectWriter(OS, true), TargetObjectWriter(MOTW) {
|
||||
WinCOFFObjectWriter::WinCOFFObjectWriter(
|
||||
std::unique_ptr<MCWinCOFFObjectTargetWriter> MOTW, raw_pwrite_stream &OS)
|
||||
: MCObjectWriter(OS, true), TargetObjectWriter(std::move(MOTW)) {
|
||||
Header.Machine = TargetObjectWriter->getMachine();
|
||||
}
|
||||
|
||||
|
@ -1084,8 +1085,7 @@ void MCWinCOFFObjectTargetWriter::anchor() {}
|
|||
//------------------------------------------------------------------------------
|
||||
// WinCOFFObjectWriter factory function
|
||||
|
||||
MCObjectWriter *
|
||||
llvm::createWinCOFFObjectWriter(MCWinCOFFObjectTargetWriter *MOTW,
|
||||
raw_pwrite_stream &OS) {
|
||||
return new WinCOFFObjectWriter(MOTW, OS);
|
||||
MCObjectWriter *llvm::createWinCOFFObjectWriter(
|
||||
std::unique_ptr<MCWinCOFFObjectTargetWriter> MOTW, raw_pwrite_stream &OS) {
|
||||
return new WinCOFFObjectWriter(std::move(MOTW), OS);
|
||||
}
|
||||
|
|
|
@ -97,8 +97,8 @@ bool AArch64WinCOFFObjectWriter::recordRelocation(const MCFixup &Fixup) const {
|
|||
namespace llvm {
|
||||
|
||||
MCObjectWriter *createAArch64WinCOFFObjectWriter(raw_pwrite_stream &OS) {
|
||||
MCWinCOFFObjectTargetWriter *MOTW = new AArch64WinCOFFObjectWriter();
|
||||
return createWinCOFFObjectWriter(MOTW, OS);
|
||||
auto MOTW = llvm::make_unique<AArch64WinCOFFObjectWriter>();
|
||||
return createWinCOFFObjectWriter(std::move(MOTW), OS);
|
||||
}
|
||||
|
||||
} // end namespace llvm
|
||||
|
|
|
@ -92,8 +92,8 @@ namespace llvm {
|
|||
|
||||
MCObjectWriter *createARMWinCOFFObjectWriter(raw_pwrite_stream &OS,
|
||||
bool Is64Bit) {
|
||||
MCWinCOFFObjectTargetWriter *MOTW = new ARMWinCOFFObjectWriter(Is64Bit);
|
||||
return createWinCOFFObjectWriter(MOTW, OS);
|
||||
auto MOTW = llvm::make_unique<ARMWinCOFFObjectWriter>(Is64Bit);
|
||||
return createWinCOFFObjectWriter(std::move(MOTW), OS);
|
||||
}
|
||||
|
||||
} // end namespace llvm
|
||||
|
|
|
@ -106,6 +106,6 @@ unsigned X86WinCOFFObjectWriter::getRelocType(MCContext &Ctx,
|
|||
|
||||
MCObjectWriter *llvm::createX86WinCOFFObjectWriter(raw_pwrite_stream &OS,
|
||||
bool Is64Bit) {
|
||||
MCWinCOFFObjectTargetWriter *MOTW = new X86WinCOFFObjectWriter(Is64Bit);
|
||||
return createWinCOFFObjectWriter(MOTW, OS);
|
||||
auto MOTW = llvm::make_unique<X86WinCOFFObjectWriter>(Is64Bit);
|
||||
return createWinCOFFObjectWriter(std::move(MOTW), OS);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue