[PATCH] D33993: Fix compiler crash in AsmParser::Lex
Nirav Dave via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 9 07:04:42 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL305077: [MC] Fix compiler crash in AsmParser::Lex (authored by niravd).
Changed prior to commit:
https://reviews.llvm.org/D33993?vs=101748&id=102027#toc
Repository:
rL LLVM
https://reviews.llvm.org/D33993
Files:
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
llvm/trunk/test/MC/AsmParser/empty-comment.s
Index: llvm/trunk/test/MC/AsmParser/empty-comment.s
===================================================================
--- llvm/trunk/test/MC/AsmParser/empty-comment.s
+++ llvm/trunk/test/MC/AsmParser/empty-comment.s
@@ -0,0 +1,4 @@
+ #RUN: llvm-mc -preserve-comments -n -triple i386-linux-gnu < %s > %t
+ .text
+foo:
+ nop #
\ No newline at end of file
Index: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
===================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp
@@ -703,7 +703,7 @@
// if it's a end of statement with a comment in it
if (getTok().is(AsmToken::EndOfStatement)) {
// if this is a line comment output it.
- if (getTok().getString().front() != '\n' &&
+ if (!getTok().getString().empty() && getTok().getString().front() != '\n' &&
getTok().getString().front() != '\r' && MAI.preserveAsmComments())
Out.addExplicitComment(Twine(getTok().getString()));
}
@@ -1523,7 +1523,7 @@
Lex();
if (Lexer.is(AsmToken::EndOfStatement)) {
// if this is a line comment we can drop it safely
- if (getTok().getString().front() == '\r' ||
+ if (getTok().getString().empty() || getTok().getString().front() == '\r' ||
getTok().getString().front() == '\n')
Out.AddBlankLine();
Lex();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33993.102027.patch
Type: text/x-patch
Size: 1351 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170609/03526fea/attachment.bin>
More information about the llvm-commits
mailing list