From 42a68443a15d74ada014ad2c8a2349fe134a44f3 Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Mon, 4 Feb 2013 15:44:38 +0000 Subject: [PATCH] Fix some abuses of StringRef We were taking a StringRef to a temporary result, which can go horribly wrong. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174328 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index 34026344b09..49bec595e61 100644 --- a/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -1207,8 +1207,8 @@ AArch64AsmParser::ParseRelocPrefix(AArch64MCExpr::VariantKind &RefKind) { return MatchOperand_ParseFail; } - StringRef lowerCase = Parser.getTok().getIdentifier().lower(); - RefKind = StringSwitch(lowerCase) + std::string LowerCase = Parser.getTok().getIdentifier().lower(); + RefKind = StringSwitch(LowerCase) .Case("got", AArch64MCExpr::VK_AARCH64_GOT) .Case("got_lo12", AArch64MCExpr::VK_AARCH64_GOT_LO12) .Case("lo12", AArch64MCExpr::VK_AARCH64_LO12) @@ -1343,7 +1343,8 @@ AArch64AsmParser::ParseCRxOperand( return MatchOperand_ParseFail; } - StringRef Tok = Parser.getTok().getIdentifier().lower(); + std::string LowerTok = Parser.getTok().getIdentifier().lower(); + StringRef Tok(LowerTok); if (Tok[0] != 'c') { Error(S, "Expected cN operand where 0 <= N <= 15"); return MatchOperand_ParseFail;