[cfe-commits] r154981 - in /cfe/trunk: lib/Frontend/TextDiagnostic.cpp test/Misc/wnull-character.cpp
Seth Cantrell
seth.cantrell at gmail.com
Tue Apr 17 19:44:49 PDT 2012
Author: socantre
Date: Tue Apr 17 21:44:48 2012
New Revision: 154981
URL: http://llvm.org/viewvc/llvm-project?rev=154981&view=rev
Log:
fix display of source lines with null characters
Added:
cfe/trunk/test/Misc/wnull-character.cpp
Modified:
cfe/trunk/lib/Frontend/TextDiagnostic.cpp
Modified: cfe/trunk/lib/Frontend/TextDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnostic.cpp?rev=154981&r1=154980&r2=154981&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/TextDiagnostic.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnostic.cpp Tue Apr 17 21:44:48 2012
@@ -839,10 +839,13 @@
// Get information about the buffer it points into.
bool Invalid = false;
- const char *BufStart = SM.getBufferData(FID, &Invalid).data();
+ StringRef BufData = SM.getBufferData(FID, &Invalid);
if (Invalid)
return;
+ const char *BufStart = BufData.data();
+ const char *BufEnd = BufStart + BufData.size();
+
unsigned LineNo = SM.getLineNumber(FID, FileOffset);
unsigned ColNo = SM.getColumnNumber(FID, FileOffset);
unsigned CaretEndColNo
@@ -856,7 +859,7 @@
// Compute the line end. Scan forward from the error position to the end of
// the line.
const char *LineEnd = TokPtr;
- while (*LineEnd != '\n' && *LineEnd != '\r' && *LineEnd != '\0')
+ while (*LineEnd != '\n' && *LineEnd != '\r' && LineEnd!=BufEnd)
++LineEnd;
// FIXME: This shouldn't be necessary, but the CaretEndColNo can extend past
Added: cfe/trunk/test/Misc/wnull-character.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/wnull-character.cpp?rev=154981&view=auto
==============================================================================
Binary files cfe/trunk/test/Misc/wnull-character.cpp (added) and cfe/trunk/test/Misc/wnull-character.cpp Tue Apr 17 21:44:48 2012 differ
More information about the cfe-commits
mailing list