forked from OSchip/llvm-project
fix an MCInstPrinter leak that jyasskin pointed out:
createAsmStreamer now takes ownership of the instprinter. llvm-svn: 98939
This commit is contained in:
parent
bb34b4e10f
commit
90a7859ebc
|
@ -291,7 +291,8 @@ class TargetAsmBackend;
|
||||||
/// assembler.
|
/// assembler.
|
||||||
///
|
///
|
||||||
/// \param InstPrint - If given, the instruction printer to use. If not given
|
/// \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
|
/// \param CE - If given, a code emitter to use to show the instruction
|
||||||
/// encoding inline with the assembly.
|
/// encoding inline with the assembly.
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "llvm/MC/MCInstPrinter.h"
|
#include "llvm/MC/MCInstPrinter.h"
|
||||||
#include "llvm/MC/MCSectionMachO.h"
|
#include "llvm/MC/MCSectionMachO.h"
|
||||||
#include "llvm/MC/MCSymbol.h"
|
#include "llvm/MC/MCSymbol.h"
|
||||||
|
#include "llvm/ADT/OwningPtr.h"
|
||||||
#include "llvm/ADT/SmallString.h"
|
#include "llvm/ADT/SmallString.h"
|
||||||
#include "llvm/ADT/Twine.h"
|
#include "llvm/ADT/Twine.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
|
@ -29,7 +30,7 @@ namespace {
|
||||||
class MCAsmStreamer : public MCStreamer {
|
class MCAsmStreamer : public MCStreamer {
|
||||||
formatted_raw_ostream &OS;
|
formatted_raw_ostream &OS;
|
||||||
const MCAsmInfo &MAI;
|
const MCAsmInfo &MAI;
|
||||||
MCInstPrinter *InstPrinter;
|
OwningPtr<MCInstPrinter> InstPrinter;
|
||||||
MCCodeEmitter *Emitter;
|
MCCodeEmitter *Emitter;
|
||||||
|
|
||||||
SmallString<128> CommentToEmit;
|
SmallString<128> CommentToEmit;
|
||||||
|
|
|
@ -278,18 +278,17 @@ static int AssembleInput(const char *ProgName) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
OwningPtr<MCInstPrinter> IP;
|
|
||||||
OwningPtr<MCCodeEmitter> CE;
|
OwningPtr<MCCodeEmitter> CE;
|
||||||
OwningPtr<MCStreamer> Str;
|
OwningPtr<MCStreamer> Str;
|
||||||
OwningPtr<TargetAsmBackend> TAB;
|
OwningPtr<TargetAsmBackend> TAB;
|
||||||
|
|
||||||
if (FileType == OFT_AssemblyFile) {
|
if (FileType == OFT_AssemblyFile) {
|
||||||
IP.reset(TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI, *Out));
|
MCInstPrinter *IP =
|
||||||
|
TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI, *Out);
|
||||||
if (ShowEncoding)
|
if (ShowEncoding)
|
||||||
CE.reset(TheTarget->createCodeEmitter(*TM, Ctx));
|
CE.reset(TheTarget->createCodeEmitter(*TM, Ctx));
|
||||||
Str.reset(createAsmStreamer(Ctx, *Out,TM->getTargetData()->isLittleEndian(),
|
Str.reset(createAsmStreamer(Ctx, *Out,TM->getTargetData()->isLittleEndian(),
|
||||||
/*asmverbose*/true, IP.get(), CE.get(),
|
/*asmverbose*/true, IP, CE.get(), ShowInst));
|
||||||
ShowInst));
|
|
||||||
} else {
|
} else {
|
||||||
assert(FileType == OFT_ObjectFile && "Invalid file type!");
|
assert(FileType == OFT_ObjectFile && "Invalid file type!");
|
||||||
CE.reset(TheTarget->createCodeEmitter(*TM, Ctx));
|
CE.reset(TheTarget->createCodeEmitter(*TM, Ctx));
|
||||||
|
|
Loading…
Reference in New Issue