From: Kevin Enderby Date: Fri, 24 Dec 2010 00:12:02 +0000 (+0000) Subject: In llvm-mc parse a Hash token as a full line comment. Allows handling of X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d82ed5b7347173a827969966db740c2b34d605b9;p=oota-llvm.git In llvm-mc parse a Hash token as a full line comment. Allows handling of preprocessed .s files and matches darwin gas. rdar://8798690 Also fix a comment on the next line of AsmParser.cpp after this new code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122531 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index 2f53b21f287..aac55351555 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -831,12 +831,17 @@ bool AsmParser::ParseStatement() { return false; } - // Statements always start with an identifier. + // Statements always start with an identifier or are a full line comment. AsmToken ID = getTok(); SMLoc IDLoc = ID.getLoc(); StringRef IDVal; int64_t LocalLabelVal = -1; - // GUESS allow an integer followed by a ':' as a directional local label + // A full line comment is a '#' as the first token. + if (Lexer.is(AsmToken::Hash)) { + EatToEndOfStatement(); + return false; + } + // Allow an integer followed by a ':' as a directional local label. if (Lexer.is(AsmToken::Integer)) { LocalLabelVal = getTok().getIntVal(); if (LocalLabelVal < 0) { diff --git a/test/MC/AsmParser/full_line_comment.s b/test/MC/AsmParser/full_line_comment.s new file mode 100644 index 00000000000..4c919863483 --- /dev/null +++ b/test/MC/AsmParser/full_line_comment.s @@ -0,0 +1,8 @@ +// RUN: llvm-mc -triple arm-apple-darwin10 %s | FileCheck %s +# this is a full line comment starting at column 1 + # this starting at column 2 + + .data +// CHECK: .long 0 +.long 0 +# .long 1 this line is commented out