@@ -1100,17 +1100,18 @@ bool MasmParser::expandMacros() {
11001100const AsmToken &MasmParser::Lex (ExpandKind ExpandNextToken) {
11011101 if (Lexer.getTok ().is (AsmToken::Error))
11021102 Error (Lexer.getErrLoc (), Lexer.getErr ());
1103+ bool StartOfStatement = false ;
11031104
11041105 // if it's a end of statement with a comment in it
11051106 if (getTok ().is (AsmToken::EndOfStatement)) {
11061107 // if this is a line comment output it.
11071108 if (!getTok ().getString ().empty () && getTok ().getString ().front () != ' \n ' &&
11081109 getTok ().getString ().front () != ' \r ' && MAI.preserveAsmComments ())
11091110 Out.addExplicitComment (Twine (getTok ().getString ()));
1111+ StartOfStatement = true ;
11101112 }
11111113
11121114 const AsmToken *tok = &Lexer.Lex ();
1113- bool StartOfStatement = Lexer.isAtStartOfStatement ();
11141115
11151116 while (ExpandNextToken == ExpandMacros && tok->is (AsmToken::Identifier)) {
11161117 if (StartOfStatement) {
@@ -1203,20 +1204,19 @@ bool MasmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
12031204 Lex ();
12041205
12051206 ParseStatementInfo Info (&AsmStrRewrites);
1206- bool Parsed = parseStatement (Info, nullptr );
1207+ bool HasError = parseStatement (Info, nullptr );
12071208
12081209 // If we have a Lexer Error we are on an Error Token. Load in Lexer Error
12091210 // for printing ErrMsg via Lex() only if no (presumably better) parser error
12101211 // exists.
1211- if (Parsed && !hasPendingError () && Lexer.getTok ().is (AsmToken::Error)) {
1212+ if (HasError && !hasPendingError () && Lexer.getTok ().is (AsmToken::Error))
12121213 Lex ();
1213- }
12141214
12151215 // parseStatement returned true so may need to emit an error.
12161216 printPendingErrors ();
12171217
12181218 // Skipping to the next line if needed.
1219- if (Parsed && !getLexer ().isAtStartOfStatement ())
1219+ if (HasError && !getLexer ().justConsumedEOL ())
12201220 eatToEndOfStatement ();
12211221 }
12221222
@@ -2802,25 +2802,24 @@ bool MasmParser::handleMacroInvocation(const MCAsmMacro *M, SMLoc NameLoc) {
28022802 SmallVector<AsmRewrite, 4 > AsmStrRewrites;
28032803 while (Lexer.isNot (AsmToken::Eof)) {
28042804 ParseStatementInfo Info (&AsmStrRewrites);
2805- bool Parsed = parseStatement (Info, nullptr );
2805+ bool HasError = parseStatement (Info, nullptr );
28062806
2807- if (!Parsed && Info.ExitValue ) {
2807+ if (!HasError && Info.ExitValue ) {
28082808 ExitValue = std::move (*Info.ExitValue );
28092809 break ;
28102810 }
28112811
28122812 // If we have a Lexer Error we are on an Error Token. Load in Lexer Error
28132813 // for printing ErrMsg via Lex() only if no (presumably better) parser error
28142814 // exists.
2815- if (Parsed && !hasPendingError () && Lexer.getTok ().is (AsmToken::Error)) {
2815+ if (HasError && !hasPendingError () && Lexer.getTok ().is (AsmToken::Error))
28162816 Lex ();
2817- }
28182817
28192818 // parseStatement returned true so may need to emit an error.
28202819 printPendingErrors ();
28212820
28222821 // Skipping to the next line if needed.
2823- if (Parsed && !getLexer ().isAtStartOfStatement ())
2822+ if (HasError && !getLexer ().justConsumedEOL ())
28242823 eatToEndOfStatement ();
28252824 }
28262825
0 commit comments