Index: lib/MC/MCDisassembler/Disassembler.h =================================================================== --- lib/MC/MCDisassembler/Disassembler.h +++ lib/MC/MCDisassembler/Disassembler.h @@ -82,24 +82,22 @@ SmallString<128> CommentsToEmit; raw_svector_ostream CommentStream; - LLVMDisasmContext(std::string tripleName, void *disInfo, int tagType, - LLVMOpInfoCallback getOpInfo, - LLVMSymbolLookupCallback symbolLookUp, - const Target *theTarget, const MCAsmInfo *mAI, - const MCRegisterInfo *mRI, const MCSubtargetInfo *mSI, - const MCInstrInfo *mII, llvm::MCContext *ctx, - const MCDisassembler *disAsm, MCInstPrinter *iP) - : TripleName(std::move(tripleName)), DisInfo(disInfo), TagType(tagType), - GetOpInfo(getOpInfo), SymbolLookUp(symbolLookUp), TheTarget(theTarget), - Options(0), CommentStream(CommentsToEmit) { - MAI.reset(mAI); - MRI.reset(mRI); - MSI.reset(mSI); - MII.reset(mII); - Ctx.reset(ctx); - DisAsm.reset(disAsm); - IP.reset(iP); - } + LLVMDisasmContext(std::string TripleName, void *DisInfo, int TagType, + LLVMOpInfoCallback GetOpInfo, + LLVMSymbolLookupCallback SymbolLookUp, + const Target *TheTarget, + std::unique_ptr &&MAI, + std::unique_ptr &&MRI, + std::unique_ptr &&MSI, + std::unique_ptr &&MII, + std::unique_ptr &&Ctx, + std::unique_ptr &&DisAsm, + std::unique_ptr &&IP) + : TripleName(std::move(TripleName)), DisInfo(DisInfo), TagType(TagType), + GetOpInfo(GetOpInfo), SymbolLookUp(SymbolLookUp), TheTarget(TheTarget), + MAI(std::move(MAI)), MRI(std::move(MRI)), MSI(std::move(MSI)), + MII(std::move(MII)), Ctx(std::move(Ctx)), DisAsm(std::move(DisAsm)), + IP(std::move(IP)), Options(0), CommentStream(CommentsToEmit) {} const std::string &getTripleName() const { return TripleName; } void *getDisInfo() const { return DisInfo; } int getTagType() const { return TagType; } Index: lib/MC/MCDisassembler/Disassembler.cpp =================================================================== --- lib/MC/MCDisassembler/Disassembler.cpp +++ lib/MC/MCDisassembler/Disassembler.cpp @@ -52,31 +52,32 @@ if (!TheTarget) return nullptr; - const MCRegisterInfo *MRI = TheTarget->createMCRegInfo(TT); + std::unique_ptr MRI(TheTarget->createMCRegInfo(TT)); if (!MRI) return nullptr; // Get the assembler info needed to setup the MCContext. - const MCAsmInfo *MAI = TheTarget->createMCAsmInfo(*MRI, TT); + std::unique_ptr MAI(TheTarget->createMCAsmInfo(*MRI, TT)); if (!MAI) return nullptr; - const MCInstrInfo *MII = TheTarget->createMCInstrInfo(); + std::unique_ptr MII(TheTarget->createMCInstrInfo()); if (!MII) return nullptr; - const MCSubtargetInfo *STI = - TheTarget->createMCSubtargetInfo(TT, CPU, Features); + std::unique_ptr STI( + TheTarget->createMCSubtargetInfo(TT, CPU, Features)); if (!STI) return nullptr; // Set up the MCContext for creating symbols and MCExpr's. - MCContext *Ctx = new MCContext(MAI, MRI, nullptr); + std::unique_ptr Ctx(new MCContext(MAI.get(), MRI.get(), nullptr)); if (!Ctx) return nullptr; // Set up disassembler. - MCDisassembler *DisAsm = TheTarget->createMCDisassembler(*STI, *Ctx); + std::unique_ptr DisAsm( + TheTarget->createMCDisassembler(*STI, *Ctx)); if (!DisAsm) return nullptr; @@ -86,19 +87,20 @@ return nullptr; std::unique_ptr Symbolizer(TheTarget->createMCSymbolizer( - TT, GetOpInfo, SymbolLookUp, DisInfo, Ctx, std::move(RelInfo))); + TT, GetOpInfo, SymbolLookUp, DisInfo, Ctx.get(), std::move(RelInfo))); DisAsm->setSymbolizer(std::move(Symbolizer)); // Set up the instruction printer. int AsmPrinterVariant = MAI->getAssemblerDialect(); - MCInstPrinter *IP = TheTarget->createMCInstPrinter( - Triple(TT), AsmPrinterVariant, *MAI, *MII, *MRI); + std::unique_ptr IP(TheTarget->createMCInstPrinter( + Triple(TT), AsmPrinterVariant, *MAI, *MII, *MRI)); if (!IP) return nullptr; - LLVMDisasmContext *DC = - new LLVMDisasmContext(TT, DisInfo, TagType, GetOpInfo, SymbolLookUp, - TheTarget, MAI, MRI, STI, MII, Ctx, DisAsm, IP); + LLVMDisasmContext *DC = new LLVMDisasmContext( + TT, DisInfo, TagType, GetOpInfo, SymbolLookUp, TheTarget, std::move(MAI), + std::move(MRI), std::move(STI), std::move(MII), std::move(Ctx), + std::move(DisAsm), std::move(IP)); if (!DC) return nullptr;