[cfe-commits] r154947 - in /cfe/trunk: lib/Frontend/TextDiagnostic.cpp test/Misc/wnull-character.cpp
Seth Cantrell
seth.cantrell at gmail.com
Tue Apr 17 13:06:06 PDT 2012
Author: socantre
Date: Tue Apr 17 15:06:06 2012
New Revision: 154947
URL: http://llvm.org/viewvc/llvm-project?rev=154947&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=154947&r1=154946&r2=154947&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/TextDiagnostic.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnostic.cpp Tue Apr 17 15:06:06 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=154947&view=auto
==============================================================================
Binary files cfe/trunk/test/Misc/wnull-character.cpp (added) and cfe/trunk/test/Misc/wnull-character.cpp Tue Apr 17 15:06:06 2012 differ
More information about the cfe-commits
mailing list