diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 47befcaf6b0..4b088a57d74 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -291,7 +291,8 @@ class TargetAsmBackend; /// assembler. /// /// \param InstPrint - If given, the instruction printer to use. If not given - /// the MCInst representation will be printed. + /// the MCInst representation will be printed. This method takes ownership of + /// InstPrint. /// /// \param CE - If given, a code emitter to use to show the instruction /// encoding inline with the assembly. diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp index 7f3947114fe..2025463a80b 100644 --- a/lib/MC/MCAsmStreamer.cpp +++ b/lib/MC/MCAsmStreamer.cpp @@ -16,6 +16,7 @@ #include "llvm/MC/MCInstPrinter.h" #include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCSymbol.h" +#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/ErrorHandling.h" @@ -29,7 +30,7 @@ namespace { class MCAsmStreamer : public MCStreamer { formatted_raw_ostream &OS; const MCAsmInfo &MAI; - MCInstPrinter *InstPrinter; + OwningPtr InstPrinter; MCCodeEmitter *Emitter; SmallString<128> CommentToEmit; diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp index 66e126092db..3778bc9e1d2 100644 --- a/tools/llvm-mc/llvm-mc.cpp +++ b/tools/llvm-mc/llvm-mc.cpp @@ -278,18 +278,17 @@ static int AssembleInput(const char *ProgName) { return 1; } - OwningPtr IP; OwningPtr CE; OwningPtr Str; OwningPtr TAB; if (FileType == OFT_AssemblyFile) { - IP.reset(TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI, *Out)); + MCInstPrinter *IP = + TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI, *Out); if (ShowEncoding) CE.reset(TheTarget->createCodeEmitter(*TM, Ctx)); Str.reset(createAsmStreamer(Ctx, *Out,TM->getTargetData()->isLittleEndian(), - /*asmverbose*/true, IP.get(), CE.get(), - ShowInst)); + /*asmverbose*/true, IP, CE.get(), ShowInst)); } else { assert(FileType == OFT_ObjectFile && "Invalid file type!"); CE.reset(TheTarget->createCodeEmitter(*TM, Ctx));