diff options
| author | Justin Bogner <mail@justinbogner.com> | 2014-09-17 15:43:01 +0000 |
|---|---|---|
| committer | Justin Bogner <mail@justinbogner.com> | 2014-09-17 15:43:01 +0000 |
| commit | 69fe4e98fa00cce06d64c8bf81882dfea0851302 (patch) | |
| tree | be94d5979419e62fa61aba9b303f9d165b165868 /llvm/tools/llvm-cov/SourceCoverageView.cpp | |
| parent | 253e5da7ad727b518ccfe7befe1d9cd43530cf60 (diff) | |
| download | llvm-69fe4e98fa00cce06d64c8bf81882dfea0851302.zip llvm-69fe4e98fa00cce06d64c8bf81882dfea0851302.tar.gz llvm-69fe4e98fa00cce06d64c8bf81882dfea0851302.tar.bz2 | |
LineIterator: Provide a variant that keeps blank lines
It isn't always useful to skip blank lines, as evidenced by the
somewhat awkward use of line_iterator in llvm-cov. This adds a knob to
control whether or not to skip blanks.
llvm-svn: 217960
Diffstat (limited to 'llvm/tools/llvm-cov/SourceCoverageView.cpp')
| -rw-r--r-- | llvm/tools/llvm-cov/SourceCoverageView.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/llvm/tools/llvm-cov/SourceCoverageView.cpp b/llvm/tools/llvm-cov/SourceCoverageView.cpp index f18f0f6..a83bd54 100644 --- a/llvm/tools/llvm-cov/SourceCoverageView.cpp +++ b/llvm/tools/llvm-cov/SourceCoverageView.cpp @@ -206,7 +206,7 @@ void SourceCoverageView::render(raw_ostream &OS, unsigned IndentLevel) { size_t CurrentHighlightRange = 0; size_t CurrentRegionMarker = 0; - line_iterator Lines(File); + line_iterator Lines(File, /*SkipBlanks=*/false); // Advance the line iterator to the first line. while (Lines.line_number() < LineOffset) ++Lines; @@ -228,8 +228,9 @@ void SourceCoverageView::render(raw_ostream &OS, unsigned IndentLevel) { auto NextISV = InstantiationSubViews.begin(); auto EndISV = InstantiationSubViews.end(); - for (size_t I = 0, E = LineStats.size(); I < E; ++I) { - unsigned LineNo = I + LineOffset; + for (size_t I = 0, E = LineStats.size(); I < E && !Lines.is_at_eof(); + ++I, ++Lines) { + unsigned LineNo = Lines.line_number(); renderIndent(OS, IndentLevel); if (Options.ShowLineStats) @@ -252,11 +253,6 @@ void SourceCoverageView::render(raw_ostream &OS, unsigned IndentLevel) { // Display the source code for the current line. StringRef Line = *Lines; - // Check if the line is empty, as line_iterator skips blank lines. - if (LineNo < Lines.line_number()) - Line = ""; - else if (!Lines.is_at_eof()) - ++Lines; renderLine(OS, Line, LineRanges); // Show the region markers. |
