Index: lib/MC/MCParser/AsmLexer.cpp =================================================================== --- lib/MC/MCParser/AsmLexer.cpp +++ lib/MC/MCParser/AsmLexer.cpp @@ -210,8 +210,8 @@ int CurChar = getNextChar(); while (CurChar != '\n' && CurChar != '\r' && CurChar != EOF) CurChar = getNextChar(); - if (CurChar == '\r') - CurPtr++; + if (CurChar == '\r' && CurPtr != CurBuf.end() && *(CurPtr + 1) == '\n') + CurPtr++; // If we have a CommentConsumer, notify it about the comment. if (CommentConsumer) { @@ -612,8 +612,8 @@ case '\r': IsAtStartOfLine = true; IsAtStartOfStatement = true; - if (CurChar == '\r') - CurPtr++; + if (CurChar == '\r' && CurPtr != CurBuf.end() && *(CurPtr + 1) == '\n') + CurPtr++; return AsmToken(AsmToken::EndOfStatement, StringRef(TokStart, 1)); case ':': return AsmToken(AsmToken::Colon, StringRef(TokStart, 1)); case '+': return AsmToken(AsmToken::Plus, StringRef(TokStart, 1));