[PATCH] D90234: [MCParser] Correctly handle Windows line-endings when consuming lexed line comments
Stephen Tozer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 17 06:31:25 PDT 2021
StephenTozer updated this revision to Diff 366882.
StephenTozer added a comment.
Added text diff of test file to review.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D90234/new/
https://reviews.llvm.org/D90234
Files:
llvm/.gitattributes
llvm/lib/MC/MCParser/AsmLexer.cpp
llvm/test/tools/llvm-mca/directives-handle-crlf.s
Index: llvm/test/tools/llvm-mca/directives-handle-crlf.s
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-mca/directives-handle-crlf.s
@@ -0,0 +1,4 @@
+# RUN: llvm-mca -mtriple=x86_64-unknown-unknown %s
+# LLVM-MCA-BEGIN
+addl $42, %eax
+# LLVM-MCA-END
Index: llvm/lib/MC/MCParser/AsmLexer.cpp
===================================================================
--- llvm/lib/MC/MCParser/AsmLexer.cpp
+++ llvm/lib/MC/MCParser/AsmLexer.cpp
@@ -228,6 +228,7 @@
int CurChar = getNextChar();
while (CurChar != '\n' && CurChar != '\r' && CurChar != EOF)
CurChar = getNextChar();
+ const char *NewlinePtr = CurPtr;
if (CurChar == '\r' && CurPtr != CurBuf.end() && *CurPtr == '\n')
++CurPtr;
@@ -235,7 +236,7 @@
if (CommentConsumer) {
CommentConsumer->HandleComment(
SMLoc::getFromPointer(CommentTextStart),
- StringRef(CommentTextStart, CurPtr - 1 - CommentTextStart));
+ StringRef(CommentTextStart, NewlinePtr - 1 - CommentTextStart));
}
IsAtStartOfLine = true;
Index: llvm/.gitattributes
===================================================================
--- llvm/.gitattributes
+++ llvm/.gitattributes
@@ -17,3 +17,4 @@
# binary and not autoconvert line endings (for example, when core.autocrlf is
# on).
test/MC/AsmParser/preserve-comments-crlf.s binary
+test/tools/llvm-mca/directives-handle-crlf.s binary
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90234.366882.patch
Type: text/x-patch
Size: 1450 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210817/379da084/attachment.bin>
More information about the llvm-commits
mailing list