summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2014-04-15 14:13:21 +0000
committerNAKAMURA Takumi <geek4civic@gmail.com>2014-04-15 14:13:21 +0000
commit9bc7c0707d12cd92fa1d7b44476d70c547c6291b (patch)
tree514382b9f8e2b54a867e2028ced4517d14d7ed6c
parent9bf9a794dfe9ef0ae059024b4826577140e1135e (diff)
downloadllvm-9bc7c0707d12cd92fa1d7b44476d70c547c6291b.tar.gz
llvm-9bc7c0707d12cd92fa1d7b44476d70c547c6291b.tar.bz2
llvm-9bc7c0707d12cd92fa1d7b44476d70c547c6291b.tar.xz
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
-rw-r--r--lib/Target/Mips/AsmParser/MipsAsmParser.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
index d65ae11c03..e1ebd7661c 100644
--- a/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
+++ b/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
@@ -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)) {