[PATCH] D92681: [MC] Fix ICE with non-newline terminated input
Scott Linder via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 9 15:40:14 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG19c56e11fa48: [MC] Fix ICE with non-newline terminated input (authored by scott.linder).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D92681/new/
https://reviews.llvm.org/D92681
Files:
llvm/lib/MC/MCParser/AsmLexer.cpp
llvm/test/MC/AsmParser/Inputs/no-newline-at-end-of-file.s
llvm/test/MC/AsmParser/preserve-comments.s
Index: llvm/test/MC/AsmParser/preserve-comments.s
===================================================================
--- llvm/test/MC/AsmParser/preserve-comments.s
+++ llvm/test/MC/AsmParser/preserve-comments.s
@@ -1,5 +1,6 @@
#RUN: llvm-mc -preserve-comments -n -triple i386-linux-gnu < %s > %t
#RUN: diff -b %s %t
+ #RUN: llvm-mc -preserve-comments -n -triple i386-linux-gnu < %p/Inputs/no-newline-at-end-of-file.s | FileCheck %s
.text
foo: #Comment here
@@ -11,3 +12,6 @@
#endif
.ident "clang version 3.9.0"
.section ".note.GNU-stack","", at progbits
+
+ #Confirm we don't crash on inputs without a terminating newline.
+ #CHECK: .text
Index: llvm/test/MC/AsmParser/Inputs/no-newline-at-end-of-file.s
===================================================================
--- /dev/null
+++ llvm/test/MC/AsmParser/Inputs/no-newline-at-end-of-file.s
@@ -0,0 +1 @@
+.text
\ No newline at end of file
Index: llvm/lib/MC/MCParser/AsmLexer.cpp
===================================================================
--- llvm/lib/MC/MCParser/AsmLexer.cpp
+++ llvm/lib/MC/MCParser/AsmLexer.cpp
@@ -715,7 +715,7 @@
if (CurChar == EOF && !IsAtStartOfStatement && EndStatementAtEOF) {
IsAtStartOfLine = true;
IsAtStartOfStatement = true;
- return AsmToken(AsmToken::EndOfStatement, StringRef(TokStart, 1));
+ return AsmToken(AsmToken::EndOfStatement, StringRef(TokStart, 0));
}
IsAtStartOfLine = false;
bool OldIsAtStartOfStatement = IsAtStartOfStatement;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92681.310690.patch
Type: text/x-patch
Size: 1482 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201209/84969e37/attachment.bin>
More information about the llvm-commits
mailing list