]> granicus.if.org Git - llvm/commitdiff
[MC] Fix lexing ordering in assembly label parsing to preserve same line
authorNirav Dave <niravd@google.com>
Wed, 13 Jul 2016 14:03:12 +0000 (14:03 +0000)
committerNirav Dave <niravd@google.com>
Wed, 13 Jul 2016 14:03:12 +0000 (14:03 +0000)
comment placement.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275265 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCParser/AsmParser.cpp
test/MC/AsmParser/preserve-comments.s

index d16f2452e1316054f8c578ac783b7cb14481aafa..4865807045d426090f89fd33eb7dc0b922764eb6 100644 (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;
   }
index 2ff5b7b98670ba176ae9ee7d165bc77c893f0375..85fbcfd50ab2c00f1e5b9645173969d3affe698e 100644 (file)
@@ -2,6 +2,8 @@
        #RUN: diff %s %t
        .text
 
+foo:   #Comment here
+       #comment here
        nop
        #if DIRECTIVE COMMENT
        ## WHOLE LINE COMMENT