From 929d54b9483a1736665efa03ec27e201f5e8c8ca Mon Sep 17 00:00:00 2001 From: Nirav Dave Date: Wed, 13 Jul 2016 14:03:12 +0000 Subject: [PATCH] [MC] Fix lexing ordering in assembly label parsing to preserve same line comment placement. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275265 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/MCParser/AsmParser.cpp | 14 +++++++------- test/MC/AsmParser/preserve-comments.s | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index d16f2452e13..4865807045d 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -1501,6 +1501,12 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info, if (!Sym->isUndefined() || Sym->isVariable()) return Error(IDLoc, "invalid symbol redefinition"); + // Consume any end of statement token, if present, to avoid spurious + // AddBlankLine calls(). + if (getTok().is(AsmToken::EndOfStatement)) { + Lex(); + } + // Emit the label. if (!ParsingInlineAsm) Out.EmitLabel(Sym); @@ -1513,13 +1519,7 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info, getTargetParser().onLabelParsed(Sym); - // Consume any end of statement token, if present, to avoid spurious - // AddBlankLine calls(). - if (Lexer.is(AsmToken::EndOfStatement)) { - Lex(); - if (Lexer.is(AsmToken::Eof)) - return false; - } + return false; } diff --git a/test/MC/AsmParser/preserve-comments.s b/test/MC/AsmParser/preserve-comments.s index 2ff5b7b9867..85fbcfd50ab 100644 --- a/test/MC/AsmParser/preserve-comments.s +++ b/test/MC/AsmParser/preserve-comments.s @@ -2,6 +2,8 @@ #RUN: diff %s %t .text +foo: #Comment here + #comment here nop #if DIRECTIVE COMMENT ## WHOLE LINE COMMENT -- 2.49.0