Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion llvm/lib/MC/MCParser/AsmLexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,14 @@ AsmToken AsmLexer::LexToken() {
}

if (isAtStartOfComment(TokStart)) {
CurPtr += MAI.getCommentString().size() - 1;
StringRef CommentString = MAI.getCommentString();
// For multi-char comment strings, advance CurPtr only if we matched the
// full string. This stops us from accidentally eating the newline if the
// current line ends in a single comment char.
if (CommentString.size() > 1 &&
StringRef(TokStart, CommentString.size()) == CommentString) {
CurPtr += CommentString.size() - 1;
}
return LexLineComment();
}

Expand Down
10 changes: 10 additions & 0 deletions llvm/test/MC/AsmParser/comments-x86-darwin-eol-dropped.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// RUN: llvm-mc -triple i386-apple-darwin %s 2>&1 | FileCheck %s
.p2align 3
// CHECK: .p2align 3
test:
// CHECK-LABEL: test:
// CHECK: pushl %ebp
// CHECK: movl %esp, %ebp
# Check that the following line's comment # doesn't drop the movl after
pushl %ebp #
movl %esp, %ebp