Index: include/llvm/MC/MCParser/AsmLexer.h =================================================================== --- include/llvm/MC/MCParser/AsmLexer.h +++ include/llvm/MC/MCParser/AsmLexer.h @@ -49,7 +49,7 @@ const AsmToken peekTok(bool ShouldSkipSpace = true) override; - bool isAtStartOfComment(char Char); + bool isAtStartOfComment(const char * Char); bool isAtStatementSeparator(const char *Ptr); const MCAsmInfo &getMAI() const { return MAI; } Index: lib/MC/MCParser/AsmLexer.cpp =================================================================== --- lib/MC/MCParser/AsmLexer.cpp +++ lib/MC/MCParser/AsmLexer.cpp @@ -417,7 +417,7 @@ StringRef AsmLexer::LexUntilEndOfStatement() { TokStart = CurPtr; - while (!isAtStartOfComment(*CurPtr) && // Start of line comment. + while (!isAtStartOfComment(CurPtr) && // Start of line comment. !isAtStatementSeparator(CurPtr) && // End of statement marker. *CurPtr != '\n' && *CurPtr != '\r' && (*CurPtr != 0 || CurPtr != CurBuf.end())) { @@ -458,9 +458,8 @@ return Token; } -bool AsmLexer::isAtStartOfComment(char Char) { - // FIXME: This won't work for multi-character comment indicators like "//". - return Char == *MAI.getCommentString(); +bool AsmLexer::isAtStartOfComment(const char * Char) { + return strncmp(Char, MAI.getCommentString(), strlen(MAI.getCommentString()))==0; } bool AsmLexer::isAtStatementSeparator(const char *Ptr) { @@ -473,7 +472,7 @@ // This always consumes at least one character. int CurChar = getNextChar(); - if (isAtStartOfComment(CurChar)) { + if (isAtStartOfComment(TokStart)) { // If this comment starts with a '#', then return the Hash token and let // the assembler parser see if it can be parsed as a cpp line filename // comment. We do this only if we are at the start of a line. Index: test/MC/AsmParser/AsmLexer/aarch64-comment.s =================================================================== --- /dev/null +++ test/MC/AsmParser/AsmLexer/aarch64-comment.s @@ -0,0 +1,8 @@ +; RUN: echo "add s0, s1,s2 //" | llvm-mc -as-lex -triple=aarch64 | FileCheck %s +; CHECK: identifier: add ("add") +; CHECK: identifier: s0 ("s0") +; CHECK: Comma (",") +; CHECK: identifier: s1 ("s1") +; CHECK: Comma (",") +; CHECK: identifier: s2 ("s2") +; CHECK: EndOfStatement ("") Index: test/MC/AsmParser/AsmLexer/aarch64-not-a-comment.s =================================================================== --- /dev/null +++ test/MC/AsmParser/AsmLexer/aarch64-not-a-comment.s @@ -0,0 +1,9 @@ +; RUN: echo "add s0, s1,s2 /" | llvm-mc -as-lex -triple=aarch64 | FileCheck %s +; CHECK: identifier: add ("add") +; CHECK: identifier: s0 ("s0") +; CHECK: Comma (",") +; CHECK: identifier: s1 ("s1") +; CHECK: Comma (",") +; CHECK: identifier: s2 ("s2") +; CHECK: Slash ("/") +; CHECK: EndOfStatement ("\n") Index: test/MC/AsmParser/macros-darwin.s =================================================================== --- test/MC/AsmParser/macros-darwin.s +++ test/MC/AsmParser/macros-darwin.s @@ -80,7 +80,7 @@ // CHECK: .globl "a,b,c" test8 a, b, c // CHECK: .globl "%1,%2,%3" -test8 %1, %2, %3 #a comment +test8 %1, %2, %3 ##a comment // CHECK: .globl "x-y,z,1" test8 x - y, z, 1 // CHECK: .globl "1 2 3" Index: test/MC/MachO/tlv-reloc.s =================================================================== --- test/MC/MachO/tlv-reloc.s +++ test/MC/MachO/tlv-reloc.s @@ -18,7 +18,7 @@ _foo: movq _a@TLVP(%rip), %rdi - call *(%rdi) # returns &a in %rax + call *(%rdi) ## returns &a in %rax ret // CHECK: ('cputype', 16777223) Index: test/MC/MachO/x86_32-optimal_nop.s =================================================================== --- test/MC/MachO/x86_32-optimal_nop.s +++ test/MC/MachO/x86_32-optimal_nop.s @@ -1,14 +1,14 @@ // RUN: llvm-mc -triple i386-apple-darwin9 %s -filetype=obj -o - | macho-dump --dump-section-data | FileCheck %s # 1 byte nop test - .align 4, 0 # start with 16 byte alignment filled with zeros + .align 4, 0 ## start with 16 byte alignment filled with zeros ret # nop # 0x90 .align 1, 0x90 ret # 2 byte nop test - .align 4, 0 # start with 16 byte alignment filled with zeros + .align 4, 0 ## start with 16 byte alignment filled with zeros ret ret # xchg %ax,%ax @@ -16,14 +16,14 @@ .align 2, 0x90 ret # 3 byte nop test - .align 4, 0 # start with 16 byte alignment filled with zeros + .align 4, 0 ## start with 16 byte alignment filled with zeros ret # nopl (%[re]ax) # 0x0f, 0x1f, 0x00 .align 2, 0x90 ret # 4 byte nop test - .align 4, 0 # start with 16 byte alignment filled with zeros + .align 4, 0 ## start with 16 byte alignment filled with zeros ret ret ret @@ -33,7 +33,7 @@ .align 3, 0x90 ret # 5 byte nop test - .align 4, 0 # start with 16 byte alignment filled with zeros + .align 4, 0 ## start with 16 byte alignment filled with zeros ret ret ret @@ -42,7 +42,7 @@ .align 3, 0x90 ret # 6 byte nop test - .align 4, 0 # start with 16 byte alignment filled with zeros + .align 4, 0 ## start with 16 byte alignment filled with zeros ret ret # nopw 0(%[re]ax,%[re]ax,1) @@ -50,14 +50,14 @@ .align 3, 0x90 ret # 7 byte nop test - .align 4, 0 # start with 16 byte alignment filled with zeros + .align 4, 0 ## start with 16 byte alignment filled with zeros ret # nopl 0L(%[re]ax) # 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00 .align 3, 0x90 ret # 8 byte nop test - .align 4, 0 # start with 16 byte alignment filled with zeros + .align 4, 0 ## start with 16 byte alignment filled with zeros ret ret ret @@ -71,7 +71,7 @@ .align 3, 0x90 ret # 9 byte nop test - .align 4, 0 # start with 16 byte alignment filled with zeros + .align 4, 0 ## start with 16 byte alignment filled with zeros ret ret ret @@ -84,7 +84,7 @@ .align 4, 0x90 ret # 10 byte nop test - .align 4, 0 # start with 16 byte alignment filled with zeros + .align 4, 0 ## start with 16 byte alignment filled with zeros ret ret ret @@ -97,7 +97,7 @@ .align 4, 0x90 ret # 11 byte nop test - .align 4, 0 # start with 16 byte alignment filled with zeros + .align 4, 0 ## start with 16 byte alignment filled with zeros ret ret ret @@ -108,7 +108,7 @@ .align 4, 0x90 ret # 12 byte nop test - .align 4, 0 # start with 16 byte alignment filled with zeros + .align 4, 0 ## start with 16 byte alignment filled with zeros ret ret ret @@ -120,7 +120,7 @@ .align 4, 0x90 ret # 13 byte nop test - .align 4, 0 # start with 16 byte alignment filled with zeros + .align 4, 0 ## start with 16 byte alignment filled with zeros ret ret ret @@ -131,7 +131,7 @@ .align 4, 0x90 ret # 14 byte nop test - .align 4, 0 # start with 16 byte alignment filled with zeros + .align 4, 0 ## start with 16 byte alignment filled with zeros ret ret # nopl 0L(%[re]ax) @@ -141,7 +141,7 @@ .align 4, 0x90 ret # 15 byte nop test - .align 4, 0 # start with 16 byte alignment filled with zeros + .align 4, 0 ## start with 16 byte alignment filled with zeros ret # nopl 0L(%[re]ax) # nopl 0L(%[re]ax,%[re]ax,1)