[llvm] r343027 - [MCAsmParser] Move AltMacroMode tracking out of MCAsmLexer
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 25 13:55:55 PDT 2018
Author: ctopper
Date: Tue Sep 25 13:55:55 2018
New Revision: 343027
URL: http://llvm.org/viewvc/llvm-project?rev=343027&view=rev
Log:
[MCAsmParser] Move AltMacroMode tracking out of MCAsmLexer
The Lexer doesn't use this state itself. It is only set and used by AsmParser so it seems like it should just be part of AsmParser.
Differential Revision: https://reviews.llvm.org/D52515
Modified:
llvm/trunk/include/llvm/MC/MCParser/MCAsmLexer.h
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
llvm/trunk/lib/MC/MCParser/MCAsmLexer.cpp
Modified: llvm/trunk/include/llvm/MC/MCParser/MCAsmLexer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCParser/MCAsmLexer.h?rev=343027&r1=343026&r2=343027&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCParser/MCAsmLexer.h (original)
+++ llvm/trunk/include/llvm/MC/MCParser/MCAsmLexer.h Tue Sep 25 13:55:55 2018
@@ -52,7 +52,6 @@ protected: // Can only create subclasses
bool IsAtStartOfStatement = true;
AsmCommentConsumer *CommentConsumer = nullptr;
- bool AltMacroMode;
MCAsmLexer();
virtual AsmToken LexToken() = 0;
@@ -67,14 +66,6 @@ public:
MCAsmLexer &operator=(const MCAsmLexer &) = delete;
virtual ~MCAsmLexer();
- bool IsaAltMacroMode() {
- return AltMacroMode;
- }
-
- void SetAltMacroMode(bool AltMacroSet) {
- AltMacroMode = AltMacroSet;
- }
-
/// Consume the next token from the input stream and return it.
///
/// The lexer will continuously return the end-of-file token once the end of
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=343027&r1=343026&r2=343027&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Tue Sep 25 13:55:55 2018
@@ -180,6 +180,9 @@ private:
/// Did we already inform the user about inconsistent MD5 usage?
bool ReportedInconsistentMD5 = false;
+ // Is alt macro mode enabled.
+ bool AltMacroMode = false;
+
public:
AsmParser(SourceMgr &SM, MCContext &Ctx, MCStreamer &Out,
const MCAsmInfo &MAI, unsigned CB);
@@ -2443,14 +2446,13 @@ bool AsmParser::expandMacro(raw_svector_
// Here, we identify the integer token which is the result of the
// absolute expression evaluation and replace it with its string
// representation.
- if (Lexer.IsaAltMacroMode() && Token.getString().front() == '%' &&
+ if (AltMacroMode && Token.getString().front() == '%' &&
Token.is(AsmToken::Integer))
// Emit an integer value to the buffer.
OS << Token.getIntVal();
// Only Token that was validated as a string and begins with '<'
// is considered altMacroString!!!
- else if (Lexer.IsaAltMacroMode() &&
- Token.getString().front() == '<' &&
+ else if (AltMacroMode && Token.getString().front() == '<' &&
Token.is(AsmToken::String)) {
OS << altMacroString(Token.getStringContents());
}
@@ -2634,7 +2636,7 @@ bool AsmParser::parseMacroArguments(cons
SMLoc StrLoc = Lexer.getLoc();
SMLoc EndLoc;
- if (Lexer.IsaAltMacroMode() && Lexer.is(AsmToken::Percent)) {
+ if (AltMacroMode && Lexer.is(AsmToken::Percent)) {
const MCExpr *AbsoluteExp;
int64_t Value;
/// Eat '%'
@@ -2649,7 +2651,7 @@ bool AsmParser::parseMacroArguments(cons
AsmToken newToken(AsmToken::Integer,
StringRef(StrChar, EndChar - StrChar), Value);
FA.Value.push_back(newToken);
- } else if (Lexer.IsaAltMacroMode() && Lexer.is(AsmToken::Less) &&
+ } else if (AltMacroMode && Lexer.is(AsmToken::Less) &&
isAltmacroString(StrLoc, EndLoc)) {
const char *StrChar = StrLoc.getPointer();
const char *EndChar = EndLoc.getPointer();
@@ -4186,10 +4188,7 @@ bool AsmParser::parseDirectiveCFIUndefin
bool AsmParser::parseDirectiveAltmacro(StringRef Directive) {
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '" + Directive + "' directive");
- if (Directive == ".altmacro")
- getLexer().SetAltMacroMode(true);
- else
- getLexer().SetAltMacroMode(false);
+ AltMacroMode = (Directive == ".altmacro");
return false;
}
Modified: llvm/trunk/lib/MC/MCParser/MCAsmLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/MCAsmLexer.cpp?rev=343027&r1=343026&r2=343027&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/MCAsmLexer.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/MCAsmLexer.cpp Tue Sep 25 13:55:55 2018
@@ -15,7 +15,7 @@
using namespace llvm;
-MCAsmLexer::MCAsmLexer() : AltMacroMode(false) {
+MCAsmLexer::MCAsmLexer() {
CurTok.emplace_back(AsmToken::Space, StringRef());
}
More information about the llvm-commits
mailing list