mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-16 08:29:43 +00:00
[PowerPC] Fix memory corruption in AsmParser
As pointed out by Evgeniy Stepanov, assigning a std::string temporary to a StringRef is not a good idea. Rework MatchRegisterName to avoid using the .lower routine. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181192 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5d042c6374
commit
7d55b6bb1a
@ -508,29 +508,29 @@ MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
|
||||
bool PPCAsmParser::
|
||||
MatchRegisterName(const AsmToken &Tok, unsigned &RegNo, int64_t &IntVal) {
|
||||
if (Tok.is(AsmToken::Identifier)) {
|
||||
StringRef Name = Tok.getString().lower();
|
||||
StringRef Name = Tok.getString();
|
||||
|
||||
if (Name == "lr") {
|
||||
if (Name.equals_lower("lr")) {
|
||||
RegNo = isPPC64()? PPC::LR8 : PPC::LR;
|
||||
IntVal = 8;
|
||||
return false;
|
||||
} else if (Name == "ctr") {
|
||||
} else if (Name.equals_lower("ctr")) {
|
||||
RegNo = isPPC64()? PPC::CTR8 : PPC::CTR;
|
||||
IntVal = 9;
|
||||
return false;
|
||||
} else if (Name.startswith("r") &&
|
||||
} else if (Name.substr(0, 1).equals_lower("r") &&
|
||||
!Name.substr(1).getAsInteger(10, IntVal) && IntVal < 32) {
|
||||
RegNo = isPPC64()? XRegs[IntVal] : RRegs[IntVal];
|
||||
return false;
|
||||
} else if (Name.startswith("f") &&
|
||||
} else if (Name.substr(0, 1).equals_lower("f") &&
|
||||
!Name.substr(1).getAsInteger(10, IntVal) && IntVal < 32) {
|
||||
RegNo = FRegs[IntVal];
|
||||
return false;
|
||||
} else if (Name.startswith("v") &&
|
||||
} else if (Name.substr(0, 1).equals_lower("v") &&
|
||||
!Name.substr(1).getAsInteger(10, IntVal) && IntVal < 32) {
|
||||
RegNo = VRegs[IntVal];
|
||||
return false;
|
||||
} else if (Name.startswith("cr") &&
|
||||
} else if (Name.substr(0, 2).equals_lower("cr") &&
|
||||
!Name.substr(2).getAsInteger(10, IntVal) && IntVal < 8) {
|
||||
RegNo = CRRegs[IntVal];
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user