diff options
author | Chris Lattner <sabre@nondot.org> | 2009-03-08 08:11:22 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-03-08 08:11:22 +0000 |
commit | cd1148b6145094ae3cabd02e6ef1d50dcc2d07b0 (patch) | |
tree | 740b7a4e9d1d98fb45e45a4bc31ac8e37b629b3e /lib/Frontend/TextDiagnosticPrinter.cpp | |
parent | 1fa495304c81e03f07f278a47b5efe9317104aab (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66374 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/TextDiagnosticPrinter.cpp')
-rw-r--r-- | lib/Frontend/TextDiagnosticPrinter.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp index d3e46ff029..3e6c3ae74b 100644 --- a/lib/Frontend/TextDiagnosticPrinter.cpp +++ b/lib/Frontend/TextDiagnosticPrinter.cpp @@ -145,7 +145,6 @@ void TextDiagnosticPrinter::EmitCaretDiagnostic(SourceLocation Loc, // 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 @@ void TextDiagnosticPrinter::EmitCaretDiagnostic(SourceLocation Loc, // 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. |