From: Daniel Sanders Date: Mon, 9 May 2016 13:10:57 +0000 (+0000) Subject: [mips] Fix use after free and an unnecessary copy introduced in r268896. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b2292f8443ae88e7789b0e75d4d4b15b03ce049c;p=llvm [mips] Fix use after free and an unnecessary copy introduced in r268896. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268913 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/lib/Target/Mips/AsmParser/MipsAsmParser.cpp index 1b61535c75a..bff46886dc7 100644 --- a/lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ b/lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -1322,8 +1322,9 @@ public: return Op; } - static std::unique_ptr - CreateRegPair(MipsOperand MOP, SMLoc S, SMLoc E, MipsAsmParser &Parser) { + static std::unique_ptr CreateRegPair(const MipsOperand &MOP, + SMLoc S, SMLoc E, + MipsAsmParser &Parser) { auto Op = make_unique(k_RegPair, Parser); Op->RegIdx.Index = MOP.RegIdx.Index; Op->StartLoc = S; @@ -4691,7 +4692,7 @@ MipsAsmParser::parseRegisterPair(OperandVector &Operands) { return MatchOperand_ParseFail; SMLoc E = Parser.getTok().getLoc(); - MipsOperand &Op = static_cast(*Operands.back()); + MipsOperand Op = static_cast(*Operands.back()); Operands.pop_back(); Operands.push_back(MipsOperand::CreateRegPair(Op, S, E, *this));