summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MIRParser/MIParser.cpp
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2015-08-06 23:17:42 +0000
committerAlex Lorenz <arphaman@gmail.com>2015-08-06 23:17:42 +0000
commit3fb77686c1d63cb3ef0322bed341c67e10d1d88b (patch)
tree959ec194b11c15024e52d4161641e1231ada2c5a /llvm/lib/CodeGen/MIRParser/MIParser.cpp
parenta11903215f0920e790316ed3d0bb71b9a681646c (diff)
downloadbcm5719-llvm-3fb77686c1d63cb3ef0322bed341c67e10d1d88b.tar.gz
bcm5719-llvm-3fb77686c1d63cb3ef0322bed341c67e10d1d88b.zip
MIR Parser: Simplify the token's string value handling.
This commit removes the 'StringOffset' and 'HasStringValue' fields from the MIToken struct and simplifies the 'stringValue' method which now returns the new 'StringValue' field. This commit also adopts a different way of initializing the lexed tokens - instead of constructing a new MIToken instance, the lexer resets the old token using the new 'reset' method and sets its attributes using the new 'setStringValue', 'setOwnedStringValue', and 'setIntegerValue' methods. Reviewers: Sean Silva Differential Revision: http://reviews.llvm.org/D11792 llvm-svn: 244295
Diffstat (limited to 'llvm/lib/CodeGen/MIRParser/MIParser.cpp')
-rw-r--r--llvm/lib/CodeGen/MIRParser/MIParser.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
index f8a6200cc67..e577458f8fc 100644
--- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
@@ -200,7 +200,7 @@ MIParser::MIParser(SourceMgr &SM, MachineFunction &MF, SMDiagnostic &Error,
StringRef Source, const PerFunctionMIParsingState &PFS,
const SlotMapping &IRSlots)
: SM(SM), MF(MF), Error(Error), Source(Source), CurrentSource(Source),
- Token(MIToken::Error, StringRef()), PFS(PFS), IRSlots(IRSlots) {}
+ PFS(PFS), IRSlots(IRSlots) {}
void MIParser::lex() {
CurrentSource = lexMIToken(
@@ -571,7 +571,7 @@ bool MIParser::parseImmediateOperand(MachineOperand &Dest) {
}
bool MIParser::parseIRConstant(StringRef::iterator Loc, const Constant *&C) {
- auto Source = StringRef(Loc, Token.stringValue().end() - Loc).str();
+ auto Source = StringRef(Loc, Token.range().end() - Loc).str();
lex();
SMDiagnostic Err;
C = parseConstantValue(Source.c_str(), Err, *MF.getFunction()->getParent());
@@ -681,8 +681,8 @@ bool MIParser::parseGlobalValue(GlobalValue *&GV) {
const Module *M = MF.getFunction()->getParent();
GV = M->getNamedValue(Token.stringValue());
if (!GV)
- return error(Twine("use of undefined global value '@") +
- Token.rawStringValue() + "'");
+ return error(Twine("use of undefined global value '") + Token.range() +
+ "'");
break;
}
case MIToken::GlobalValue: {
@@ -851,8 +851,7 @@ bool MIParser::parseIRBlock(BasicBlock *&BB, const Function &F) {
BB = dyn_cast_or_null<BasicBlock>(
F.getValueSymbolTable().lookup(Token.stringValue()));
if (!BB)
- return error(Twine("use of undefined IR block '%ir-block.") +
- Token.rawStringValue() + "'");
+ return error(Twine("use of undefined IR block '") + Token.range() + "'");
break;
}
case MIToken::IRBlock: {
@@ -1019,7 +1018,7 @@ bool MIParser::parseMachineOperandAndTargetFlags(MachineOperand &Dest) {
bool MIParser::parseOperandsOffset(MachineOperand &Op) {
if (Token.isNot(MIToken::plus) && Token.isNot(MIToken::minus))
return false;
- StringRef Sign = Token.stringValue();
+ StringRef Sign = Token.range();
bool IsNegative = Token.is(MIToken::minus);
lex();
if (Token.isNot(MIToken::IntegerLiteral))
@@ -1039,8 +1038,7 @@ bool MIParser::parseIRValue(Value *&V) {
case MIToken::NamedIRValue: {
V = MF.getFunction()->getValueSymbolTable().lookup(Token.stringValue());
if (!V)
- return error(Twine("use of undefined IR value '%ir.") +
- Token.rawStringValue() + "'");
+ return error(Twine("use of undefined IR value '") + Token.range() + "'");
break;
}
// TODO: Parse unnamed IR value references.
OpenPOWER on IntegriCloud