Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit d2e36ca

Browse files
committed
[llvm-cov] Use less space to describe source names
In r279628, we made SourceCoverageView list the binary associated with a view and started adding labels (e.g "Source: foo" or "Function: bar") to everything. Condense this information a bit to unclutter reports. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280896 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent a57be10 commit d2e36ca

9 files changed

+40
-52
lines changed

test/tools/llvm-cov/showProjectSummary.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,8 @@ int main(int argc, char ** argv) {
3636
// HTML: <span>Code Coverage Report</span>
3737
// HTML: <div class='created-time'>
3838
// HTML: <span>Created:
39-
// HTML-FILE: <pre>Source:
40-
// HTML-FILE: showProjectSummary.cpp</pre>
41-
// HTML-FILE: <pre>Binary:
42-
// HTML-FILE: showProjectSummary.covmapping</pre>
43-
// HTML-FUNCTION: <pre>Function: main</pre>
39+
// HTML-FILE: <pre>Source: {{.*}}showProjectSummary.cpp (Binary: showProjectSummary.covmapping)</pre>
40+
// HTML-FUNCTION: <pre>main</pre>
4441
// HTML-UNCOVEREDLINE: <a href='#L8'>Go to first unexecuted line</a>
4542
// HTML-HEADER: <tr><td><span><pre>Line No.</pre></span></td>
4643
// HTML-HEADER: <td><span><pre>Count</pre></span></td>

test/tools/llvm-cov/showTemplateInstantiations.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ int func(T x) { // ALL-NEXT: [[@LINE]]| 2|int func(T x) {
1212
int j = 1; // ALL-NEXT: [[@LINE]]| 0| int j = 1;
1313
} // ALL-NEXT: [[@LINE]]| 2|}
1414

15-
// SHARED: {{^ *(\| )?}}Function: _Z4funcIbEiT_:
15+
// SHARED: {{^ *(\| )?}}_Z4funcIbEiT_:
1616
// SHARED: [[@LINE-9]]| 1|int func(T x) {
1717
// SHARED-NEXT: [[@LINE-9]]| 1| if(x)
1818
// SHARED-NEXT: [[@LINE-9]]| 1| return 0;
@@ -21,8 +21,8 @@ int func(T x) { // ALL-NEXT: [[@LINE]]| 2|int func(T x) {
2121
// SHARED-NEXT: [[@LINE-9]]| 0| int j = 1;
2222
// SHARED-NEXT: [[@LINE-9]]| 1|}
2323

24-
// ALL: {{^ *}}| Function: _Z4funcIiEiT_:
25-
// FILTER-NOT: {{^ *(\| )?}}Function: _Z4funcIiEiT_:
24+
// ALL: {{^ *}}| _Z4funcIiEiT_:
25+
// FILTER-NOT: {{^ *(\| )?}} _Z4funcIiEiT_:
2626
// ALL: [[@LINE-19]]| 1|int func(T x) {
2727
// ALL-NEXT: [[@LINE-19]]| 1| if(x)
2828
// ALL-NEXT: [[@LINE-19]]| 0| return 0;
@@ -56,7 +56,7 @@ int main() { // ALL: [[@LINE]]| 1|int main() {
5656
// HTML-ALL: <td class='line-number'><a name='L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='uncovered-line'><pre>0</pre></td><td class='code'><pre>
5757
// HTML-ALL: <td class='line-number'><a name='L[[@LINE-44]]'><pre>[[@LINE-44]]</pre></a></td><td class='covered-line'><pre>2</pre></td><td class='code'><pre>}
5858

59-
// HTML-SHARED: <div class='source-name-title'><pre>Function: _Z4funcIbEiT_</pre></div>
59+
// HTML-SHARED: <div class='source-name-title'><pre>_Z4funcIbEiT_</pre></div>
6060
// HTML-SHARED: <td class='line-number'><a name='L[[@LINE-53]]'><pre>[[@LINE-53]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre>int func(T x) {
6161
// HTML-SHARED: <td class='line-number'><a name='L[[@LINE-53]]'><pre>[[@LINE-53]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre> if(x)
6262
// HTML-SHARED: <td class='line-number'><a name='L[[@LINE-53]]'><pre>[[@LINE-53]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre> ret
@@ -65,7 +65,7 @@ int main() { // ALL: [[@LINE]]| 1|int main() {
6565
// HTML-SHARED: <td class='line-number'><a name='L[[@LINE-53]]'><pre>[[@LINE-53]]</pre></a></td><td class='uncovered-line'><pre>0</pre></td><td class='code'><pre>
6666
// HTML-SHARED: <td class='line-number'><a name='L[[@LINE-53]]'><pre>[[@LINE-53]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre>}
6767

68-
// HTML-ALL: <div class='source-name-title'><pre>Function: _Z4funcIiEiT_</pre></div>
68+
// HTML-ALL: <div class='source-name-title'><pre>_Z4funcIiEiT_</pre></div>
6969
// HTML-FILTER-NOT: <div class='source-name-title'><pre>_Z4funcIiEiT_</pre></div><table>
7070
// HTML-ALL: <td class='line-number'><a name='L[[@LINE-63]]'><pre>[[@LINE-63]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre>int func(T x) {
7171
// HTML-ALL: <td class='line-number'><a name='L[[@LINE-63]]'><pre>[[@LINE-63]]</pre></a></td><td class='covered-line'><pre>1</pre></td><td class='code'><pre> if(x)

tools/llvm-cov/CodeCoverage.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ CodeCoverageTool::createFunctionView(const FunctionRecord &Function,
210210
return nullptr;
211211

212212
auto Expansions = FunctionCoverage.getExpansions();
213-
auto View = SourceCoverageView::create(
214-
getSymbolForHumans(Function.Name), SourceBuffer.get(), ViewOpts,
215-
std::move(FunctionCoverage), /*FunctionView=*/true);
213+
auto View = SourceCoverageView::create(getSymbolForHumans(Function.Name),
214+
SourceBuffer.get(), ViewOpts,
215+
std::move(FunctionCoverage));
216216
attachExpansionSubViews(*View, Expansions, Coverage);
217217

218218
return View;
@@ -238,7 +238,7 @@ CodeCoverageTool::createSourceFileView(StringRef SourceFile,
238238
auto SubViewExpansions = SubViewCoverage.getExpansions();
239239
auto SubView = SourceCoverageView::create(
240240
getSymbolForHumans(Function->Name), SourceBuffer.get(), ViewOpts,
241-
std::move(SubViewCoverage), /*FunctionView=*/true);
241+
std::move(SubViewCoverage));
242242
attachExpansionSubViews(*SubView, SubViewExpansions, Coverage);
243243

244244
if (SubView) {

tools/llvm-cov/SourceCoverageView.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,26 +129,28 @@ bool SourceCoverageView::hasSubViews() const {
129129
std::unique_ptr<SourceCoverageView>
130130
SourceCoverageView::create(StringRef SourceName, const MemoryBuffer &File,
131131
const CoverageViewOptions &Options,
132-
coverage::CoverageData &&CoverageInfo,
133-
bool FunctionView) {
132+
coverage::CoverageData &&CoverageInfo) {
134133
switch (Options.Format) {
135134
case CoverageViewOptions::OutputFormat::Text:
136135
return llvm::make_unique<SourceCoverageViewText>(
137-
SourceName, File, Options, std::move(CoverageInfo), FunctionView);
136+
SourceName, File, Options, std::move(CoverageInfo));
138137
case CoverageViewOptions::OutputFormat::HTML:
139138
return llvm::make_unique<SourceCoverageViewHTML>(
140-
SourceName, File, Options, std::move(CoverageInfo), FunctionView);
139+
SourceName, File, Options, std::move(CoverageInfo));
141140
}
142141
llvm_unreachable("Unknown coverage output format!");
143142
}
144143

145-
std::string SourceCoverageView::getNativeSourceName() const {
146-
std::string SourceFile = isFunctionView() ? "Function: " : "Source: ";
147-
SourceFile += getSourceName().str();
148-
SmallString<128> SourceText(SourceFile);
144+
std::string SourceCoverageView::getSourceName() const {
145+
SmallString<128> SourceText(SourceName);
149146
sys::path::remove_dots(SourceText, /*remove_dot_dots=*/true);
150147
sys::path::native(SourceText);
151-
return SourceText.c_str();
148+
return SourceText.str();
149+
}
150+
151+
std::string SourceCoverageView::getVerboseSourceName() const {
152+
return "Source: " + getSourceName() + " (Binary: " +
153+
sys::path::filename(getOptions().ObjectFilename).str() + ")";
152154
}
153155

154156
void SourceCoverageView::addExpansion(

tools/llvm-cov/SourceCoverageView.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,6 @@ class SourceCoverageView {
172172
/// on display.
173173
std::vector<InstantiationView> InstantiationSubViews;
174174

175-
/// Specifies whether or not the view is a function view.
176-
bool FunctionView;
177-
178175
/// Get the first uncovered line number for the source file.
179176
unsigned getFirstUncoveredLineNo();
180177

@@ -264,24 +261,24 @@ class SourceCoverageView {
264261

265262
SourceCoverageView(StringRef SourceName, const MemoryBuffer &File,
266263
const CoverageViewOptions &Options,
267-
coverage::CoverageData &&CoverageInfo, bool FunctionView)
264+
coverage::CoverageData &&CoverageInfo)
268265
: SourceName(SourceName), File(File), Options(Options),
269-
CoverageInfo(std::move(CoverageInfo)), FunctionView(FunctionView) {}
266+
CoverageInfo(std::move(CoverageInfo)) {}
270267

271268
public:
272269
static std::unique_ptr<SourceCoverageView>
273270
create(StringRef SourceName, const MemoryBuffer &File,
274271
const CoverageViewOptions &Options,
275-
coverage::CoverageData &&CoverageInfo, bool FucntionView = false);
272+
coverage::CoverageData &&CoverageInfo);
276273

277274
virtual ~SourceCoverageView() {}
278275

279-
StringRef getSourceName() const { return SourceName; }
280-
281276
/// \brief Return the source name formatted for the host OS.
282-
std::string getNativeSourceName() const;
277+
std::string getSourceName() const;
283278

284-
bool isFunctionView() const { return FunctionView; }
279+
/// \brief Return a verbose description of the source name and the binary it
280+
/// corresponds to.
281+
std::string getVerboseSourceName() const;
285282

286283
const CoverageViewOptions &getOptions() const { return Options; }
287284

tools/llvm-cov/SourceCoverageViewHTML.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -341,12 +341,10 @@ void SourceCoverageViewHTML::renderViewFooter(raw_ostream &OS) {
341341
void SourceCoverageViewHTML::renderSourceName(raw_ostream &OS, bool WholeFile,
342342
unsigned FirstUncoveredLineNo) {
343343
OS << BeginSourceNameDiv;
344-
// Render the source name for the view.
345-
OS << tag("pre", escape(getNativeSourceName(), getOptions()));
344+
std::string ViewInfo = escape(
345+
WholeFile ? getVerboseSourceName() : getSourceName(), getOptions());
346+
OS << tag("pre", ViewInfo);
346347
if (WholeFile) {
347-
// Render the object file name for the view.
348-
OS << tag("pre",
349-
escape("Binary: " + getOptions().ObjectFilename, getOptions()));
350348
// Render the "Go to first unexecuted line" link for the view.
351349
if (FirstUncoveredLineNo != 0) { // The file is not fully covered
352350
std::string LinkText =

tools/llvm-cov/SourceCoverageViewHTML.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,9 @@ class SourceCoverageViewHTML : public SourceCoverageView {
7878
public:
7979
SourceCoverageViewHTML(StringRef SourceName, const MemoryBuffer &File,
8080
const CoverageViewOptions &Options,
81-
coverage::CoverageData &&CoverageInfo,
82-
bool FunctionView)
83-
: SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo),
84-
FunctionView) {}
81+
coverage::CoverageData &&CoverageInfo)
82+
: SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo)) {
83+
}
8584
};
8685

8786
} // namespace llvm

tools/llvm-cov/SourceCoverageViewText.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,8 @@ void SourceCoverageViewText::renderViewFooter(raw_ostream &) {}
6565

6666
void SourceCoverageViewText::renderSourceName(raw_ostream &OS, bool WholeFile,
6767
unsigned FirstUncoveredLineNo) {
68-
getOptions().colored_ostream(OS, raw_ostream::CYAN) << getNativeSourceName()
69-
<< ":\n";
70-
if (WholeFile) {
71-
getOptions().colored_ostream(OS, raw_ostream::CYAN)
72-
<< "Binary: " << getOptions().ObjectFilename << ":\n";
73-
}
68+
std::string ViewInfo = WholeFile ? getVerboseSourceName() : getSourceName();
69+
getOptions().colored_ostream(OS, raw_ostream::CYAN) << ViewInfo << ":\n";
7470
}
7571

7672
void SourceCoverageViewText::renderLinePrefix(raw_ostream &OS,

tools/llvm-cov/SourceCoverageViewText.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,9 @@ class SourceCoverageViewText : public SourceCoverageView {
7878
public:
7979
SourceCoverageViewText(StringRef SourceName, const MemoryBuffer &File,
8080
const CoverageViewOptions &Options,
81-
coverage::CoverageData &&CoverageInfo,
82-
bool FunctionView)
83-
: SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo),
84-
FunctionView) {}
81+
coverage::CoverageData &&CoverageInfo)
82+
: SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo)) {
83+
}
8584
};
8685

8786
} // namespace llvm

0 commit comments

Comments
 (0)