diff options
| -rw-r--r-- | clang/lib/Lex/Lexer.cpp | 2 | ||||
| -rw-r--r-- | clang/test/Lexer/eof-conflict-marker.c | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index 52146d70335..946f36fb538 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -2610,7 +2610,7 @@ static const char *FindConflictEnd(const char *CurPtr, const char *BufferEnd, ConflictMarkerKind CMK) { const char *Terminator = CMK == CMK_Perforce ? "<<<<\n" : ">>>>>>>"; size_t TermLen = CMK == CMK_Perforce ? 5 : 7; - StringRef RestOfBuffer(CurPtr+TermLen, BufferEnd-CurPtr-TermLen); + auto RestOfBuffer = StringRef(CurPtr, BufferEnd - CurPtr).substr(TermLen); size_t Pos = RestOfBuffer.find(Terminator); while (Pos != StringRef::npos) { // Must occur at start of line. diff --git a/clang/test/Lexer/eof-conflict-marker.c b/clang/test/Lexer/eof-conflict-marker.c new file mode 100644 index 00000000000..e0c35401ccb --- /dev/null +++ b/clang/test/Lexer/eof-conflict-marker.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 %s -verify -fsyntax-only +// vim: set binary noeol: + +// This file intentionally ends without a \n on the last line. Make sure your +// editor doesn't add one. + +>>>> ORIGINAL +// expected-error@-1 {{version control conflict marker in file}} +<<<< +// expected-error@-1 {{expected identifier or '('}} +<<<<
\ No newline at end of file |

