forked from OSchip/llvm-project
[MC] Plumb unique_ptr<MCWasmObjectTargetWriter> through createWasmObjectWriter
to WasmObjectWriter's constructor. Fixes the same ownership issue for COFF that r315245 did for MachO: WasmObjectWriter takes ownership of its MCWasmObjectTargetWriter, so we want to pass this through to the constructor via a unique_ptr, rather than a raw ptr. llvm-svn: 315260
This commit is contained in:
parent
ab23dace56
commit
1301a878f1
|
@ -44,8 +44,9 @@ public:
|
|||
/// \param MOTW - The target specific Wasm writer subclass.
|
||||
/// \param OS - The stream to write to.
|
||||
/// \returns The constructed object writer.
|
||||
MCObjectWriter *createWasmObjectWriter(MCWasmObjectTargetWriter *MOTW,
|
||||
raw_pwrite_stream &OS);
|
||||
MCObjectWriter *
|
||||
createWasmObjectWriter(std::unique_ptr<MCWasmObjectTargetWriter> MOTW,
|
||||
raw_pwrite_stream &OS);
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
|
|
|
@ -227,8 +227,10 @@ class WasmObjectWriter : public MCObjectWriter {
|
|||
void endSection(SectionBookkeeping &Section);
|
||||
|
||||
public:
|
||||
WasmObjectWriter(MCWasmObjectTargetWriter *MOTW, raw_pwrite_stream &OS)
|
||||
: MCObjectWriter(OS, /*IsLittleEndian=*/true), TargetObjectWriter(MOTW) {}
|
||||
WasmObjectWriter(std::unique_ptr<MCWasmObjectTargetWriter> MOTW,
|
||||
raw_pwrite_stream &OS)
|
||||
: MCObjectWriter(OS, /*IsLittleEndian=*/true),
|
||||
TargetObjectWriter(std::move(MOTW)) {}
|
||||
|
||||
private:
|
||||
~WasmObjectWriter() override;
|
||||
|
@ -1315,7 +1317,8 @@ void WasmObjectWriter::writeObject(MCAssembler &Asm,
|
|||
// TODO: Translate debug sections to the output.
|
||||
}
|
||||
|
||||
MCObjectWriter *llvm::createWasmObjectWriter(MCWasmObjectTargetWriter *MOTW,
|
||||
raw_pwrite_stream &OS) {
|
||||
return new WasmObjectWriter(MOTW, OS);
|
||||
MCObjectWriter *
|
||||
llvm::createWasmObjectWriter(std::unique_ptr<MCWasmObjectTargetWriter> MOTW,
|
||||
raw_pwrite_stream &OS) {
|
||||
return new WasmObjectWriter(std::move(MOTW), OS);
|
||||
}
|
||||
|
|
|
@ -95,6 +95,6 @@ WebAssemblyWasmObjectWriter::getRelocType(const MCValue &Target,
|
|||
|
||||
MCObjectWriter *llvm::createWebAssemblyWasmObjectWriter(raw_pwrite_stream &OS,
|
||||
bool Is64Bit) {
|
||||
MCWasmObjectTargetWriter *MOTW = new WebAssemblyWasmObjectWriter(Is64Bit);
|
||||
return createWasmObjectWriter(MOTW, OS);
|
||||
auto MOTW = llvm::make_unique<WebAssemblyWasmObjectWriter>(Is64Bit);
|
||||
return createWasmObjectWriter(std::move(MOTW), OS);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue