[cfe-commits] r103968 - in /cfe/trunk: lib/Lex/Lexer.cpp test/Lexer/conflict-marker.c

Chris Lattner sabre at nondot.org
Mon May 17 13:27:25 PDT 2010


Author: lattner
Date: Mon May 17 15:27:25 2010
New Revision: 103968

URL: http://llvm.org/viewvc/llvm-project?rev=103968&view=rev
Log:
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 "<<<<<<<<<<"

Modified:
    cfe/trunk/lib/Lex/Lexer.cpp
    cfe/trunk/test/Lexer/conflict-marker.c

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=103968&r1=103967&r2=103968&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Mon May 17 15:27:25 2010
@@ -1422,6 +1422,7 @@
     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 @@
   
   // 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);

Modified: cfe/trunk/test/Lexer/conflict-marker.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/conflict-marker.c?rev=103968&r1=103967&r2=103968&view=diff
==============================================================================
--- cfe/trunk/test/Lexer/conflict-marker.c (original)
+++ cfe/trunk/test/Lexer/conflict-marker.c Mon May 17 15:27:25 2010
@@ -4,7 +4,7 @@
 // PR5238
 
 // diff3 style
-<<<<<<< .mine             // expected-error {{version control conflict marker in file}}
+<<<<<<< .mine      // expected-error {{version control conflict marker in file}}
 int x = 4;
 |||||||
 int x = 123;
@@ -13,7 +13,7 @@
 >>>>>>> .r91107
 
 // normal style.
-<<<<<<< .mine             // expected-error {{version control conflict marker in file}}
+<<<<<<< .mine     // expected-error {{version control conflict marker in file}}
 typedef int y;
 =======
 typedef struct foo *y;
@@ -22,6 +22,7 @@
 ;
 y b;
 
+
 int foo() {
   y a = x;
   return x + a;





More information about the cfe-commits mailing list