aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/Lexer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-05-17 20:27:25 +0000
committerChris Lattner <sabre@nondot.org>2010-05-17 20:27:25 +0000
commit3d488990e13835cb35538b2f0cd53dbda92e36be (patch)
treee2dea12f934e02f1cf792c27fdcd51b4183a7ff7 /lib/Lex/Lexer.cpp
parent40b492a43bac3ed0c465772aa6921d011cfc273f (diff)
robustify the conflict marker stuff. Don't add 7 twice, which would
make it miss (invalid) things like: <<<<<<< >>>>>>> and crash if <<<<<<< was at the end of the line. When we find a >>>>>>> that is not at the end of the line, make sure to reset Pos so we don't crash on something like: <<<<<<< >>>>>>> This isn't worth making testcases for, since each would require a new file. rdar://7987078 - signal 11 compiling "<<<<<<<<<<" git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103968 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/Lexer.cpp')
-rw-r--r--lib/Lex/Lexer.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp
index 83de8c83a9..0925dd73fe 100644
--- a/lib/Lex/Lexer.cpp
+++ b/lib/Lex/Lexer.cpp
@@ -1422,6 +1422,7 @@ static const char *FindConflictEnd(const char *CurPtr, const char *BufferEnd) {
if (RestOfBuffer[Pos-1] != '\r' &&
RestOfBuffer[Pos-1] != '\n') {
RestOfBuffer = RestOfBuffer.substr(Pos+7);
+ Pos = RestOfBuffer.find(">>>>>>>");
continue;
}
return RestOfBuffer.data()+Pos;
@@ -1451,7 +1452,7 @@ bool Lexer::IsStartOfConflictMarker(const char *CurPtr) {
// Check to see if there is a >>>>>>> somewhere in the buffer at the start of
// a line to terminate this conflict marker.
- if (FindConflictEnd(CurPtr+7, BufferEnd)) {
+ if (FindConflictEnd(CurPtr, BufferEnd)) {
// We found a match. We are really in a conflict marker.
// Diagnose this, and ignore to the end of line.
Diag(CurPtr, diag::err_conflict_marker);