summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/TextDiagnostic.cpp
diff options
context:
space:
mode:
authorSeth Cantrell <seth.cantrell@gmail.com>2012-04-17 20:06:06 +0000
committerSeth Cantrell <seth.cantrell@gmail.com>2012-04-17 20:06:06 +0000
commitf504f99c7d7ca976f5b5f50c416570d50f7e7b2e (patch)
treed36d43580c27a3ceb130aa35c21470b6fc604ad6 /clang/lib/Frontend/TextDiagnostic.cpp
parentfae205811e875f28d105e125b3af77f3f1011d56 (diff)
downloadbcm5719-llvm-f504f99c7d7ca976f5b5f50c416570d50f7e7b2e.tar.gz
bcm5719-llvm-f504f99c7d7ca976f5b5f50c416570d50f7e7b2e.zip
fix display of source lines with null characters
llvm-svn: 154947
Diffstat (limited to 'clang/lib/Frontend/TextDiagnostic.cpp')
-rw-r--r--clang/lib/Frontend/TextDiagnostic.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Frontend/TextDiagnostic.cpp b/clang/lib/Frontend/TextDiagnostic.cpp
index 54b2f37e2be..988baf0995d 100644
--- a/clang/lib/Frontend/TextDiagnostic.cpp
+++ b/clang/lib/Frontend/TextDiagnostic.cpp
@@ -839,10 +839,13 @@ void TextDiagnostic::emitSnippetAndCaret(
// 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 @@ void TextDiagnostic::emitSnippetAndCaret(
// 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
OpenPOWER on IntegriCloud