aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCParser/AsmLexer.cpp
diff options
context:
space:
mode:
authorJim Grosbach <grosbach@apple.com>2011-09-15 16:52:06 +0000
committerJim Grosbach <grosbach@apple.com>2011-09-15 16:52:06 +0000
commita9aa3c18e35ded0d10e16bef2a774989cbd5162f (patch)
treef5900bddd9a0e33bcfb8051f035f6c69ea89d37b /llvm/lib/MC/MCParser/AsmLexer.cpp
parent07b3503f8b5ff65e5079e0f463561085a7d2684c (diff)
downloadllvm-a9aa3c18e35ded0d10e16bef2a774989cbd5162f.zip
llvm-a9aa3c18e35ded0d10e16bef2a774989cbd5162f.tar.gz
llvm-a9aa3c18e35ded0d10e16bef2a774989cbd5162f.tar.bz2
Handle missing newline at EOF more gracefully in MC AsmLexer.
If we see an EOF w/o a preceding end-of-line, return an EndOfStatement token before returning the Eof token. Based on patch by Stepan Dyatkovskiy. llvm-svn: 139798
Diffstat (limited to 'llvm/lib/MC/MCParser/AsmLexer.cpp')
-rw-r--r--llvm/lib/MC/MCParser/AsmLexer.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCParser/AsmLexer.cpp b/llvm/lib/MC/MCParser/AsmLexer.cpp
index e446a83..c76052d 100644
--- a/llvm/lib/MC/MCParser/AsmLexer.cpp
+++ b/llvm/lib/MC/MCParser/AsmLexer.cpp
@@ -375,8 +375,15 @@ AsmToken AsmLexer::LexToken() {
return AsmToken(AsmToken::EndOfStatement,
StringRef(TokStart, strlen(MAI.getSeparatorString())));
}
- isAtStartOfLine = false;
+ // If we're missing a newline at EOF, make sure we still get an
+ // EndOfStatement token before the Eof token.
+ if (CurChar == EOF && !isAtStartOfLine) {
+ isAtStartOfLine = true;
+ return AsmToken(AsmToken::EndOfStatement, StringRef(TokStart, 1));
+ }
+
+ isAtStartOfLine = false;
switch (CurChar) {
default:
// Handle identifier: [a-zA-Z_.][a-zA-Z0-9_$.@]*