[PATCH] MC: handle '//' correctly in AsmLexer::isAtStartOfComment()
Janne Grunau
j at jannau.net
Sat Jul 19 14:19:33 PDT 2014
Hi dpeixott, compnerd, grosbach, rafael,
'//' is the only multi-char CommentString. X86MCAsmInfo.cpp specifies
'##' to avoid problems with C preprocessor but expects '#' to be handled
as comment.
Fixes divisions in constant expressions for the AArch64 assembler.
http://reviews.llvm.org/D4597
Files:
lib/MC/MCParser/AsmLexer.cpp
test/MC/AArch64/single-slash.s
Index: lib/MC/MCParser/AsmLexer.cpp
===================================================================
--- lib/MC/MCParser/AsmLexer.cpp
+++ lib/MC/MCParser/AsmLexer.cpp
@@ -459,8 +459,11 @@
}
bool AsmLexer::isAtStartOfComment(char Char) {
- // FIXME: This won't work for multi-character comment indicators like "//".
- return Char == *MAI.getCommentString();
+ const char *CommentString = MAI.getCommentString();
+ // handle "//" specially since it is the only real two character CommentString
+ if (CommentString[1] == '/')
+ return Char == CommentString[0] && *CurPtr == CommentString[1];
+ return Char == *CommentString;
}
bool AsmLexer::isAtStatementSeparator(const char *Ptr) {
Index: test/MC/AArch64/single-slash.s
===================================================================
--- /dev/null
+++ test/MC/AArch64/single-slash.s
@@ -0,0 +1,6 @@
+// RUN: llvm-mc -triple aarch64-none-linux-gnu < %s | FileCheck %s
+
+// Test that a single slash is not mistaken as the start of comment.
+
+//CHECK: movz x0, #0x10
+ mov x0, #(32 / 2)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4597.11685.patch
Type: text/x-patch
Size: 1065 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140719/516c8fec/attachment.bin>
More information about the llvm-commits
mailing list