[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
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index af5c1a7..02d8bfb 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -227,8 +227,10 @@
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 @@
// 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);
}