[MC] Fix lexing ordering in assembly label parsing to preserve same line

comment placement.

llvm-svn: 275265
This commit is contained in:
Nirav Dave 2016-07-13 14:03:12 +00:00
parent 2931b21286
commit 8ea792db60
2 changed files with 9 additions and 7 deletions

View File

@ -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;
}

View File

@ -2,6 +2,8 @@
#RUN: diff %s %t
.text
foo: #Comment here
#comment here
nop
#if DIRECTIVE COMMENT
## WHOLE LINE COMMENT