From 2d437f6b026c4f8ccb6e1daac412dd788e76b25a Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Tue, 14 Aug 2018 17:12:54 +0000 Subject: Remove manual byte counting from Highlighter code. Summary: This removes the manual byte counting mechanism from the syntax highlighting code. This is no longer necessary as the Stream class now has built-in support for automatically counting the bytes that were written to it so far. The advantage of automatic byte counting via Stream is that it is less error-prone than the manual version and we need to write less boilerplate code. Reviewers: labath Reviewed By: labath Subscribers: labath, lldb-commits Differential Revision: https://reviews.llvm.org/D50676 llvm-svn: 339695 --- .../Plugins/Language/ClangCommon/ClangHighlighter.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp') diff --git a/lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp b/lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp index 29da03d71dd..442d4cf53e3 100644 --- a/lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp +++ b/lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp @@ -128,14 +128,12 @@ determineClangStyle(const ClangHighlighter &highlighter, return HighlightStyle::ColorStyle(); } -std::size_t ClangHighlighter::Highlight(const HighlightStyle &options, - llvm::StringRef line, - llvm::StringRef previous_lines, - Stream &result) const { +void ClangHighlighter::Highlight(const HighlightStyle &options, + llvm::StringRef line, + llvm::StringRef previous_lines, + Stream &result) const { using namespace clang; - std::size_t written_bytes = 0; - FileSystemOptions file_opts; FileManager file_mgr(file_opts); @@ -210,7 +208,7 @@ std::size_t ClangHighlighter::Highlight(const HighlightStyle &options, HighlightStyle::ColorStyle color = determineClangStyle(*this, token, tok_str, options, in_pp_directive); - written_bytes += color.Apply(result, tok_str); + color.Apply(result, tok_str); } // If we went over the whole file but couldn't find our own file, then @@ -219,9 +217,6 @@ std::size_t ClangHighlighter::Highlight(const HighlightStyle &options, // debug mode we bail out with an assert as this should never happen. if (!found_user_line) { result << line; - written_bytes += line.size(); assert(false && "We couldn't find the user line in the input file?"); } - - return written_bytes; } -- cgit v1.2.3