[llvm] r217861 - llvm-cov: Rename a variable and clean up its usage
Justin Bogner
mail at justinbogner.com
Mon Sep 15 23:21:57 PDT 2014
Author: bogner
Date: Tue Sep 16 01:21:57 2014
New Revision: 217861
URL: http://llvm.org/viewvc/llvm-project?rev=217861&view=rev
Log:
llvm-cov: Rename a variable and clean up its usage
Offset is a terrible name for an indentation / nesting level, and it
confuses me every time I look at this code.
Modified:
llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp
llvm/trunk/tools/llvm-cov/SourceCoverageView.h
Modified: llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp?rev=217861&r1=217860&r2=217861&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp Tue Sep 16 01:21:57 2014
@@ -63,17 +63,16 @@ void SourceCoverageView::renderLine(raw_
}
}
-void SourceCoverageView::renderOffset(raw_ostream &OS, unsigned I) {
- for (unsigned J = 0; J < I; ++J)
+void SourceCoverageView::renderIndent(raw_ostream &OS, unsigned Level) {
+ for (unsigned I = 0; I < Level; ++I)
OS << " |";
}
-void SourceCoverageView::renderViewDivider(unsigned Offset, unsigned Length,
+void SourceCoverageView::renderViewDivider(unsigned Level, unsigned Length,
raw_ostream &OS) {
- for (unsigned J = 1; J < Offset; ++J)
- OS << " |";
- if (Offset != 0)
- OS.indent(2);
+ assert(Level != 0 && "Cannot render divider at top level");
+ renderIndent(OS, Level - 1);
+ OS.indent(2);
for (unsigned I = 0; I < Length; ++I)
OS << "-";
}
@@ -228,7 +227,7 @@ gatherLineSubViews(size_t &CurrentIdx,
return Items.slice(PrevIdx, CurrentIdx - PrevIdx);
}
-void SourceCoverageView::render(raw_ostream &OS, unsigned Offset) {
+void SourceCoverageView::render(raw_ostream &OS, unsigned IndentLevel) {
// Make sure that the children are in sorted order.
sortChildren();
@@ -256,7 +255,7 @@ void SourceCoverageView::render(raw_ostr
// Gather the child subviews that are visible on this line.
auto LineSubViews = gatherLineSubViews(CurrentChild, Children, LineNo);
- renderOffset(OS, Offset);
+ renderIndent(OS, IndentLevel);
if (Options.ShowLineStats)
renderLineCoverageColumn(OS, LineStats[I]);
if (Options.ShowLineNumbers)
@@ -290,7 +289,7 @@ void SourceCoverageView::render(raw_ostr
LineStats[I].hasMultipleRegions();
auto LineMarkers = gatherLineItems(CurrentRegionMarker, Markers, LineNo);
if (ShowMarkers && !LineMarkers.empty()) {
- renderOffset(OS, Offset);
+ renderIndent(OS, IndentLevel);
OS.indent(CombinedColumnWidth);
renderRegionMarkers(OS, LineMarkers);
}
@@ -299,14 +298,14 @@ void SourceCoverageView::render(raw_ostr
bool FirstChildExpansion = true;
if (LineSubViews.empty())
continue;
- unsigned NewOffset = Offset + 1;
- renderViewDivider(NewOffset, DividerWidth, OS);
+ unsigned NestedIndent = IndentLevel + 1;
+ renderViewDivider(NestedIndent, DividerWidth, OS);
OS << "\n";
for (const auto &Child : LineSubViews) {
// If this subview shows a function instantiation, render the function's
// name.
if (Child->isInstantiationSubView()) {
- renderOffset(OS, NewOffset);
+ renderIndent(OS, NestedIndent);
OS << ' ';
Options.colored_ostream(OS, raw_ostream::CYAN) << Child->FunctionName
<< ":";
@@ -319,17 +318,17 @@ void SourceCoverageView::render(raw_ostr
insertHighlightRange(LineHighlightRanges,
Child->getExpansionHighlightRange(),
AdjustedLineHighlightRanges);
- renderOffset(OS, Offset);
- OS.indent(CombinedColumnWidth + (Offset == 0 ? 0 : 1));
+ renderIndent(OS, IndentLevel);
+ OS.indent(CombinedColumnWidth + (IndentLevel == 0 ? 0 : 1));
renderLine(OS, Line, AdjustedLineHighlightRanges);
- renderViewDivider(NewOffset, DividerWidth, OS);
+ renderViewDivider(NestedIndent, DividerWidth, OS);
OS << "\n";
} else
FirstChildExpansion = false;
}
// Render the child subview
- Child->render(OS, NewOffset);
- renderViewDivider(NewOffset, DividerWidth, OS);
+ Child->render(OS, NestedIndent);
+ renderViewDivider(NestedIndent, DividerWidth, OS);
OS << "\n";
}
}
Modified: llvm/trunk/tools/llvm-cov/SourceCoverageView.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageView.h?rev=217861&r1=217860&r2=217861&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageView.h (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageView.h Tue Sep 16 01:21:57 2014
@@ -141,7 +141,7 @@ private:
void renderLine(raw_ostream &OS, StringRef Line,
ArrayRef<HighlightRange> Ranges);
- void renderOffset(raw_ostream &OS, unsigned I);
+ void renderIndent(raw_ostream &OS, unsigned Level);
void renderViewDivider(unsigned Offset, unsigned Length, raw_ostream &OS);
@@ -192,7 +192,7 @@ public:
/// \brief Print the code coverage information for a specific
/// portion of a source file to the output stream.
- void render(raw_ostream &OS, unsigned Offset = 0);
+ void render(raw_ostream &OS, unsigned IndentLevel = 0);
/// \brief Load the coverage information required for rendering
/// from the mapping regions in the data manager.
More information about the llvm-commits
mailing list