diff options
author | Raphael Isemann <teemperor@gmail.com> | 2018-08-14 17:12:54 +0000 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2018-08-14 17:12:54 +0000 |
commit | 2d437f6b026c4f8ccb6e1daac412dd788e76b25a (patch) | |
tree | 5f4767bffbfaa0c8f26615160b88807f8a214327 /lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp | |
parent | 148c44547567bc2410e8adf3d31e7eefa62f7051 (diff) | |
download | bcm5719-llvm-2d437f6b026c4f8ccb6e1daac412dd788e76b25a.tar.gz bcm5719-llvm-2d437f6b026c4f8ccb6e1daac412dd788e76b25a.zip |
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
Diffstat (limited to 'lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp')
-rw-r--r-- | lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
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; } |