[cfe-commits] r66374 - /cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp

Chris Lattner sabre at nondot.org
Sun Mar 8 00:11:22 PST 2009


Author: lattner
Date: Sun Mar  8 03:11:22 2009
New Revision: 66374

URL: http://llvm.org/viewvc/llvm-project?rev=66374&view=rev
Log:
generalize the "end of line" checking logic to stop at any \0 at the
end of line instead of just the end of buffer.  Scratch buffers contain
embedded \0's between tokens which are logic line separators.  If a 
normal text buffer contains \0's, it doesn't make a lot of sense to include
them in the caret diag output anyway.

Modified:
    cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp

Modified: cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp?rev=66374&r1=66373&r2=66374&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp Sun Mar  8 03:11:22 2009
@@ -145,7 +145,6 @@
   // Get information about the buffer it points into.
   std::pair<const char*, const char*> BufferInfo = SM.getBufferData(FID);
   const char *BufStart = BufferInfo.first;
-  const char *BufEnd = BufferInfo.second;
 
   unsigned ColNo = SM.getColumnNumber(FID, FileOffset);
   
@@ -157,8 +156,7 @@
   // Compute the line end.  Scan forward from the error position to the end of
   // the line.
   const char *LineEnd = TokPtr;
-  while (LineEnd != BufEnd && 
-         *LineEnd != '\n' && *LineEnd != '\r')
+  while (*LineEnd != '\n' && *LineEnd != '\r' && *LineEnd != '\0')
     ++LineEnd;
   
   // Copy the line of code into an std::string for ease of manipulation.





More information about the cfe-commits mailing list