diff --git a/llvm/lib/MC/MCParser/AsmLexer.cpp b/llvm/lib/MC/MCParser/AsmLexer.cpp --- a/llvm/lib/MC/MCParser/AsmLexer.cpp +++ b/llvm/lib/MC/MCParser/AsmLexer.cpp @@ -214,6 +214,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; @@ -221,7 +222,7 @@ if (CommentConsumer) { CommentConsumer->HandleComment( SMLoc::getFromPointer(CommentTextStart), - StringRef(CommentTextStart, CurPtr - 1 - CommentTextStart)); + StringRef(CommentTextStart, NewlinePtr - 1 - CommentTextStart)); } IsAtStartOfLine = true;