/// 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.
#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"
class MCAsmStreamer : public MCStreamer {
formatted_raw_ostream &OS;
const MCAsmInfo &MAI;
- MCInstPrinter *InstPrinter;
+ OwningPtr<MCInstPrinter> InstPrinter;
MCCodeEmitter *Emitter;
SmallString<128> CommentToEmit;
return 1;
}
- OwningPtr<MCInstPrinter> IP;
OwningPtr<MCCodeEmitter> CE;
OwningPtr<MCStreamer> Str;
OwningPtr<TargetAsmBackend> 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));