diff options
author | Vedant Kumar <vsk@apple.com> | 2016-09-15 06:44:51 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2016-09-15 06:44:51 +0000 |
commit | a8c396d99f972877831e74c869eeada081bd8bdc (patch) | |
tree | c95784da46f4ea6be23a2e404315e52a1ff4f83a /llvm/tools/llvm-cov/CodeCoverage.cpp | |
parent | ea1e97b94ccaa25cc71cb0900c3dfd3d00e18b43 (diff) | |
download | bcm5719-llvm-a8c396d99f972877831e74c869eeada081bd8bdc.tar.gz bcm5719-llvm-a8c396d99f972877831e74c869eeada081bd8bdc.zip |
[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.
llvm-svn: 281589
Diffstat (limited to 'llvm/tools/llvm-cov/CodeCoverage.cpp')
-rw-r--r-- | llvm/tools/llvm-cov/CodeCoverage.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp index 6edca9f6071..9eacbcad5ce 100644 --- a/llvm/tools/llvm-cov/CodeCoverage.cpp +++ b/llvm/tools/llvm-cov/CodeCoverage.cpp @@ -234,21 +234,23 @@ CodeCoverageTool::createSourceFileView(StringRef SourceFile, attachExpansionSubViews(*View, Expansions, Coverage); for (const auto *Function : Coverage.getInstantiations(SourceFile)) { - auto SubViewCoverage = Coverage.getCoverageForFunction(*Function); - auto SubViewExpansions = SubViewCoverage.getExpansions(); - auto SubView = SourceCoverageView::create( - getSymbolForHumans(Function->Name), SourceBuffer.get(), ViewOpts, - std::move(SubViewCoverage)); - attachExpansionSubViews(*SubView, SubViewExpansions, Coverage); - - if (SubView) { - unsigned FileID = Function->CountedRegions.front().FileID; - unsigned Line = 0; - for (const auto &CR : Function->CountedRegions) - if (CR.FileID == FileID) - Line = std::max(CR.LineEnd, Line); - View->addInstantiation(Function->Name, Line, std::move(SubView)); + std::unique_ptr<SourceCoverageView> SubView{nullptr}; + + if (Function->ExecutionCount > 0) { + auto SubViewCoverage = Coverage.getCoverageForFunction(*Function); + auto SubViewExpansions = SubViewCoverage.getExpansions(); + SubView = SourceCoverageView::create( + getSymbolForHumans(Function->Name), SourceBuffer.get(), ViewOpts, + std::move(SubViewCoverage)); + attachExpansionSubViews(*SubView, SubViewExpansions, Coverage); } + + unsigned FileID = Function->CountedRegions.front().FileID; + unsigned Line = 0; + for (const auto &CR : Function->CountedRegions) + if (CR.FileID == FileID) + Line = std::max(CR.LineEnd, Line); + View->addInstantiation(Function->Name, Line, std::move(SubView)); } return View; } |