mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-09 16:45:03 +00:00
MipsAsmParser.cpp: Fix vg_leak in MipsOperand::CreateMem(). Mem.Base is managed by k_Memory itself.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206293 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9bf9a794df
commit
9bc7c0707d
@ -756,6 +756,20 @@ public:
|
||||
/// getEndLoc - Get the location of the last token of this operand.
|
||||
SMLoc getEndLoc() const { return EndLoc; }
|
||||
|
||||
virtual ~MipsOperand() {
|
||||
switch (Kind) {
|
||||
case k_Immediate:
|
||||
break;
|
||||
case k_Memory:
|
||||
delete Mem.Base;
|
||||
break;
|
||||
case k_PhysRegister:
|
||||
case k_RegisterIndex:
|
||||
case k_Token:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void print(raw_ostream &OS) const {
|
||||
switch (Kind) {
|
||||
case k_Immediate:
|
||||
@ -1628,6 +1642,7 @@ MipsAsmParser::OperandMatchResultTy MipsAsmParser::parseMemOperand(
|
||||
SMLoc::getFromPointer(Parser.getTok().getLoc().getPointer() - 1);
|
||||
|
||||
// Zero register assumed, add a memory operand with ZERO as its base.
|
||||
// "Base" will be managed by k_Memory.
|
||||
MipsOperand *Base = MipsOperand::CreateGPRReg(
|
||||
0, getContext().getRegisterInfo(), S, E, *this);
|
||||
Operands.push_back(MipsOperand::CreateMem(Base, IdVal, S, E, *this));
|
||||
@ -1659,6 +1674,7 @@ MipsAsmParser::OperandMatchResultTy MipsAsmParser::parseMemOperand(
|
||||
// Replace the register operand with the memory operand.
|
||||
MipsOperand *op = static_cast<MipsOperand *>(Operands.back());
|
||||
// Remove the register from the operands.
|
||||
// "op" will be managed by k_Memory.
|
||||
Operands.pop_back();
|
||||
// Add the memory operand.
|
||||
if (const MCBinaryExpr *BE = dyn_cast<MCBinaryExpr>(IdVal)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user