From a3c924f83aefd4c883ed17a200876d258e0ad1e2 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Tue, 28 Jul 2009 16:56:42 +0000 Subject: [PATCH] Switch AsmLexer::Lex to returning a reference to the current token. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77328 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-mc/AsmLexer.h | 4 ++-- tools/llvm-mc/AsmParser.cpp | 4 ++-- tools/llvm-mc/llvm-mc.cpp | 7 ++----- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/tools/llvm-mc/AsmLexer.h b/tools/llvm-mc/AsmLexer.h index 3bedc6e8e77..2918e43b6e4 100644 --- a/tools/llvm-mc/AsmLexer.h +++ b/tools/llvm-mc/AsmLexer.h @@ -110,8 +110,8 @@ public: AsmLexer(SourceMgr &SrcMgr); ~AsmLexer(); - AsmToken::TokenKind Lex() { - return CurTok = LexToken(), getKind(); + const AsmToken &Lex() { + return CurTok = LexToken(); } AsmToken::TokenKind getKind() const { return CurTok.getKind(); } diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp index 602d696ac79..e4c85a79142 100644 --- a/tools/llvm-mc/AsmParser.cpp +++ b/tools/llvm-mc/AsmParser.cpp @@ -318,7 +318,7 @@ bool AsmParser::ParseStatement() { StringRef IDVal = ID.getString(); // Consume the identifier, see what is after it. - switch (Lexer.Lex()) { + switch (Lexer.Lex().getKind()) { case AsmToken::Colon: { // identifier ':' -> Label. Lexer.Lex(); @@ -609,7 +609,7 @@ bool AsmParser::ParseDirectiveSet() { StringRef Name = Lexer.getTok().getString(); - if (Lexer.Lex() != AsmToken::Comma) + if (Lexer.Lex().isNot(AsmToken::Comma)) return TokError("unexpected token in '.set'"); Lexer.Lex(); diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp index 63cb70d5049..a64c8a65052 100644 --- a/tools/llvm-mc/llvm-mc.cpp +++ b/tools/llvm-mc/llvm-mc.cpp @@ -83,9 +83,8 @@ static int AsLexInput(const char *ProgName) { bool Error = false; - AsmToken::TokenKind Tok = Lexer.Lex(); - while (Tok != AsmToken::Eof) { - switch (Tok) { + while (Lexer.Lex().isNot(AsmToken::Eof)) { + switch (Lexer.getKind()) { default: Lexer.PrintMessage(Lexer.getLoc(), "unknown token", "warning"); Error = true; @@ -136,8 +135,6 @@ static int AsLexInput(const char *ProgName) { case AsmToken::Star: outs() << "Star\n"; break; case AsmToken::Tilde: outs() << "Tilde\n"; break; } - - Tok = Lexer.Lex(); } return Error; -- 2.34.1