mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
fix an MCInstPrinter leak that jyasskin pointed out:
createAsmStreamer now takes ownership of the instprinter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98939 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1e50631675
commit
4c42a6de9f
@ -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.
|
||||
|
@ -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<MCInstPrinter> InstPrinter;
|
||||
MCCodeEmitter *Emitter;
|
||||
|
||||
SmallString<128> CommentToEmit;
|
||||
|
@ -278,18 +278,17 @@ static int AssembleInput(const char *ProgName) {
|
||||
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));
|
||||
|
Loading…
Reference in New Issue
Block a user