1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

Plug a leak by giving the AsmParser ownership of the MCSubtargetInfo.

Found by valgrind.

llvm-svn: 134738
This commit is contained in:
Benjamin Kramer 2011-07-08 21:06:23 +00:00
parent 611219a00c
commit 85b2770a1c
2 changed files with 8 additions and 6 deletions

View File

@ -25,6 +25,7 @@
#include "llvm/Target/TargetAsmParser.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
@ -41,7 +42,7 @@ class ARMOperand;
class ARMAsmParser : public TargetAsmParser {
MCAsmParser &Parser;
const MCSubtargetInfo *STI;
OwningPtr<const MCSubtargetInfo> STI;
MCAsmParser &getParser() const { return Parser; }
MCAsmLexer &getLexer() const { return Parser.getLexer(); }
@ -128,8 +129,8 @@ class ARMAsmParser : public TargetAsmParser {
public:
ARMAsmParser(StringRef TT, StringRef CPU, StringRef FS, MCAsmParser &_Parser)
: TargetAsmParser(), Parser(_Parser) {
STI = ARM_MC::createARMMCSubtargetInfo(TT, CPU, FS);
: TargetAsmParser(), Parser(_Parser),
STI(ARM_MC::createARMMCSubtargetInfo(TT, CPU, FS)) {
MCAsmParserExtension::Initialize(_Parser);
// Initialize the set of available features.

View File

@ -19,6 +19,7 @@
#include "llvm/MC/MCParser/MCAsmLexer.h"
#include "llvm/MC/MCParser/MCAsmParser.h"
#include "llvm/MC/MCParser/MCParsedAsmOperand.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
@ -37,7 +38,7 @@ struct X86Operand;
class X86ATTAsmParser : public TargetAsmParser {
MCAsmParser &Parser;
const MCSubtargetInfo *STI;
OwningPtr<const MCSubtargetInfo> STI;
private:
MCAsmParser &getParser() const { return Parser; }
@ -79,8 +80,8 @@ private:
public:
X86ATTAsmParser(StringRef TT, StringRef CPU, StringRef FS,
MCAsmParser &parser)
: TargetAsmParser(), Parser(parser) {
STI = X86_MC::createX86MCSubtargetInfo(TT, CPU, FS);
: TargetAsmParser(), Parser(parser),
STI(X86_MC::createX86MCSubtargetInfo(TT, CPU, FS)) {
// Initialize the set of available features.
setAvailableFeatures(ComputeAvailableFeatures(STI->getFeatureBits()));