[llvm-cov] Hide instantiation views for unexecuted functions

Copying in the full text of the function doesn't help at all when we
already know that it's never executed. Just say that it's unexecuted --
the relevant source text has already been printed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281589 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Vedant Kumar 2016-09-15 06:44:51 +00:00
parent 2fcbfcf470
commit 61f5694c30
5 changed files with 56 additions and 15 deletions

View File

@ -0,0 +1,16 @@
_Z4funcIbEiT_
10
2
0
0
_Z4funcIiEiT_
10
2
0
0
main
0
1
0

View File

@ -0,0 +1,10 @@
RUN: llvm-profdata merge %S/Inputs/hideUnexecutedSubviews.proftext -o %t.profdata
RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %t.profdata -filename-equivalence %S/showTemplateInstantiations.cpp | FileCheck %s
RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %t.profdata -format html -o %t.html.dir -filename-equivalence %S/showTemplateInstantiations.cpp
RUN: FileCheck %s -input-file %t.html.dir/coverage/tmp/showTemplateInstantiations.cpp.html
CHECK: Unexecuted instantiation: _Z4funcIbEiT_
CHECK: Unexecuted instantiation: _Z4funcIiEiT_
CHECK-NOT: Unexecuted instantiation

View File

@ -234,14 +234,17 @@ CodeCoverageTool::createSourceFileView(StringRef SourceFile,
attachExpansionSubViews(*View, Expansions, Coverage); attachExpansionSubViews(*View, Expansions, Coverage);
for (const auto *Function : Coverage.getInstantiations(SourceFile)) { for (const auto *Function : Coverage.getInstantiations(SourceFile)) {
std::unique_ptr<SourceCoverageView> SubView{nullptr};
if (Function->ExecutionCount > 0) {
auto SubViewCoverage = Coverage.getCoverageForFunction(*Function); auto SubViewCoverage = Coverage.getCoverageForFunction(*Function);
auto SubViewExpansions = SubViewCoverage.getExpansions(); auto SubViewExpansions = SubViewCoverage.getExpansions();
auto SubView = SourceCoverageView::create( SubView = SourceCoverageView::create(
getSymbolForHumans(Function->Name), SourceBuffer.get(), ViewOpts, getSymbolForHumans(Function->Name), SourceBuffer.get(), ViewOpts,
std::move(SubViewCoverage)); std::move(SubViewCoverage));
attachExpansionSubViews(*SubView, SubViewExpansions, Coverage); attachExpansionSubViews(*SubView, SubViewExpansions, Coverage);
}
if (SubView) {
unsigned FileID = Function->CountedRegions.front().FileID; unsigned FileID = Function->CountedRegions.front().FileID;
unsigned Line = 0; unsigned Line = 0;
for (const auto &CR : Function->CountedRegions) for (const auto &CR : Function->CountedRegions)
@ -249,7 +252,6 @@ CodeCoverageTool::createSourceFileView(StringRef SourceFile,
Line = std::max(CR.LineEnd, Line); Line = std::max(CR.LineEnd, Line);
View->addInstantiation(Function->Name, Line, std::move(SubView)); View->addInstantiation(Function->Name, Line, std::move(SubView));
} }
}
return View; return View;
} }

View File

@ -584,7 +584,15 @@ void SourceCoverageViewHTML::renderInstantiationView(raw_ostream &OS,
InstantiationView &ISV, InstantiationView &ISV,
unsigned ViewDepth) { unsigned ViewDepth) {
OS << BeginExpansionDiv; OS << BeginExpansionDiv;
ISV.View->print(OS, /*WholeFile=*/false, /*ShowSourceName=*/true, ViewDepth); if (!ISV.View)
OS << BeginSourceNameDiv
<< tag("pre",
escape("Unexecuted instantiation: " + ISV.FunctionName.str(),
getOptions()))
<< EndSourceNameDiv;
else
ISV.View->print(OS, /*WholeFile=*/false, /*ShowSourceName=*/true,
ViewDepth);
OS << EndExpansionDiv; OS << EndExpansionDiv;
} }

View File

@ -215,7 +215,12 @@ void SourceCoverageViewText::renderInstantiationView(raw_ostream &OS,
unsigned ViewDepth) { unsigned ViewDepth) {
renderLinePrefix(OS, ViewDepth); renderLinePrefix(OS, ViewDepth);
OS << ' '; OS << ' ';
ISV.View->print(OS, /*WholeFile=*/false, /*ShowSourceName=*/true, ViewDepth); if (!ISV.View)
getOptions().colored_ostream(OS, raw_ostream::RED)
<< "Unexecuted instantiation: " << ISV.FunctionName << "\n";
else
ISV.View->print(OS, /*WholeFile=*/false, /*ShowSourceName=*/true,
ViewDepth);
} }
void SourceCoverageViewText::renderTitle(raw_ostream &OS, StringRef Title) { void SourceCoverageViewText::renderTitle(raw_ostream &OS, StringRef Title) {