diff options
author | Alex Lorenz <arphaman@gmail.com> | 2015-08-05 17:35:55 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2015-08-05 17:35:55 +0000 |
commit | 970c12eade40bd721e365e14285b97188cba9d8c (patch) | |
tree | 43b8629caf00c3d39f47b776611220c9427d38c1 /llvm/lib/CodeGen/MIRParser/MILexer.h | |
parent | 69e3eb3c79f5013fd7a602c5c06423f70faf44b6 (diff) | |
download | bcm5719-llvm-970c12eade40bd721e365e14285b97188cba9d8c.tar.gz bcm5719-llvm-970c12eade40bd721e365e14285b97188cba9d8c.zip |
MIR Parser: Simplify the handling of quoted tokens. NFC.
The machine instructions lexer should not expose the difference between quoted
and unquoted tokens to the parser.
llvm-svn: 244068
Diffstat (limited to 'llvm/lib/CodeGen/MIRParser/MILexer.h')
-rw-r--r-- | llvm/lib/CodeGen/MIRParser/MILexer.h | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MILexer.h b/llvm/lib/CodeGen/MIRParser/MILexer.h index ccf8ffe15e5..f72897a5217 100644 --- a/llvm/lib/CodeGen/MIRParser/MILexer.h +++ b/llvm/lib/CodeGen/MIRParser/MILexer.h @@ -70,10 +70,8 @@ struct MIToken { StackObject, FixedStackObject, NamedGlobalValue, - QuotedNamedGlobalValue, GlobalValue, ExternalSymbol, - QuotedExternalSymbol, // Other tokens IntegerLiteral, @@ -82,25 +80,32 @@ struct MIToken { ConstantPoolItem, JumpTableIndex, NamedIRBlock, - QuotedNamedIRBlock, IRBlock, NamedIRValue, - QuotedNamedIRValue, }; private: TokenKind Kind; unsigned StringOffset; + bool HasStringValue; StringRef Range; + std::string StringValue; APSInt IntVal; public: MIToken(TokenKind Kind, StringRef Range, unsigned StringOffset = 0) - : Kind(Kind), StringOffset(StringOffset), Range(Range) {} + : Kind(Kind), StringOffset(StringOffset), HasStringValue(false), + Range(Range) {} + + MIToken(TokenKind Kind, StringRef Range, std::string StringValue, + unsigned StringOffset = 0) + : Kind(Kind), StringOffset(StringOffset), HasStringValue(true), + Range(Range), StringValue(std::move(StringValue)) {} MIToken(TokenKind Kind, StringRef Range, const APSInt &IntVal, unsigned StringOffset = 0) - : Kind(Kind), StringOffset(StringOffset), Range(Range), IntVal(IntVal) {} + : Kind(Kind), StringOffset(StringOffset), HasStringValue(false), + Range(Range), IntVal(IntVal) {} TokenKind kind() const { return Kind; } @@ -124,30 +129,18 @@ public: StringRef::iterator location() const { return Range.begin(); } - bool isStringValueQuoted() const { - return Kind == QuotedNamedGlobalValue || Kind == QuotedExternalSymbol || - Kind == QuotedNamedIRBlock || Kind == QuotedNamedIRValue; - } - /// Return the token's raw string value. /// /// If the string value is quoted, this method returns that quoted string as /// it is, without unescaping the string value. StringRef rawStringValue() const { return Range.drop_front(StringOffset); } - /// Return token's string value. - /// - /// Expects the string value to be unquoted. + /// Return the token's string value. StringRef stringValue() const { - assert(!isStringValueQuoted() && "String value is quoted"); - return Range.drop_front(StringOffset); + return HasStringValue ? StringRef(StringValue) + : Range.drop_front(StringOffset); } - /// Unescapes the token's string value. - /// - /// Expects the string value to be quoted. - void unescapeQuotedStringValue(std::string &Str) const; - const APSInt &integerValue() const { return IntVal; } bool hasIntegerValue() const { |