[llvm] r275265 - [MC] Fix lexing ordering in assembly label parsing to preserve same line
Nirav Dave via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 13 07:03:13 PDT 2016
Author: niravd
Date: Wed Jul 13 09:03:12 2016
New Revision: 275265
URL: http://llvm.org/viewvc/llvm-project?rev=275265&view=rev
Log:
[MC] Fix lexing ordering in assembly label parsing to preserve same line
comment placement.
Modified:
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
llvm/trunk/test/MC/AsmParser/preserve-comments.s
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=275265&r1=275264&r2=275265&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Wed Jul 13 09:03:12 2016
@@ -1501,6 +1501,12 @@ bool AsmParser::parseStatement(ParseStat
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(ParseStat
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;
}
Modified: llvm/trunk/test/MC/AsmParser/preserve-comments.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/preserve-comments.s?rev=275265&r1=275264&r2=275265&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/preserve-comments.s (original)
+++ llvm/trunk/test/MC/AsmParser/preserve-comments.s Wed Jul 13 09:03:12 2016
@@ -2,6 +2,8 @@
#RUN: diff %s %t
.text
+foo: #Comment here
+ #comment here
nop
#if DIRECTIVE COMMENT
## WHOLE LINE COMMENT
More information about the llvm-commits
mailing list