summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/Mips/AsmParser
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
commite1f3583b960964bb0ca142ad2ca974a4739e7fca (patch)
treec1b56e95984f916fe6a6d75d681a04b06aed9613 /llvm/lib/Target/Mips/AsmParser
parentbd524ef1297112e252033ffb882a5dce52da1bad (diff)
downloadbcm5719-llvm-e1f3583b960964bb0ca142ad2ca974a4739e7fca.tar.gz
bcm5719-llvm-e1f3583b960964bb0ca142ad2ca974a4739e7fca.zip
MipsAsmParser.cpp: Fix vg_leak in MipsOperand::CreateMem(). Mem.Base is managed by k_Memory itself.
llvm-svn: 206293
Diffstat (limited to 'llvm/lib/Target/Mips/AsmParser')
-rw-r--r--llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
index d65ae11c03e..e1ebd7661c1 100644
--- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
+++ b/llvm/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)) {
OpenPOWER on IntegriCloud