From 79554e450e184160084c9abe90fe865735890477 Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Wed, 2 Aug 2017 23:35:24 +0000 Subject: [PATCH] [llvm-cov] Respect the value of the -show-instantiations option Make `-show-instantiations=false` actually skip displaying instantiation sub-views, instead of simply ignoring the option. llvm-svn: 309903 --- llvm/docs/CommandGuide/llvm-cov.rst | 1 + llvm/test/tools/llvm-cov/showTemplateInstantiations.cpp | 4 ++++ llvm/tools/llvm-cov/CodeCoverage.cpp | 4 +++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/llvm/docs/CommandGuide/llvm-cov.rst b/llvm/docs/CommandGuide/llvm-cov.rst index 3732b39..97064c8 100644 --- a/llvm/docs/CommandGuide/llvm-cov.rst +++ b/llvm/docs/CommandGuide/llvm-cov.rst @@ -207,6 +207,7 @@ OPTIONS For source regions that are instantiated multiple times, such as templates in ``C++``, show each instantiation separately as well as the combined summary. + This option is enabled by default. .. option:: -show-regions diff --git a/llvm/test/tools/llvm-cov/showTemplateInstantiations.cpp b/llvm/test/tools/llvm-cov/showTemplateInstantiations.cpp index e2fc370..326eb99f 100644 --- a/llvm/test/tools/llvm-cov/showTemplateInstantiations.cpp +++ b/llvm/test/tools/llvm-cov/showTemplateInstantiations.cpp @@ -87,3 +87,7 @@ int main() { // ALL: [[@LINE]]| 1|int main() { // RUN: FileCheck -check-prefix=HTML-JUMP -input-file=%t.html.dir/coverage/tmp/showTemplateInstantiations.cpp.html %s // HTML-JUMP:
Source (jump to first uncovered line)
// HTML-JUMP-NOT:
Source (jump to first uncovered line)
+ +// RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -show-instantiations=false -filename-equivalence %s | FileCheck -check-prefix=NO_INSTS %s +// NO_INSTS-NOT: {{^ *}}| _Z4funcIbEiT_: +// NO_INSTS-NOT: {{^ *}}| _Z4funcIiEiT_: diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp index 073bd83..c16d7b4 100644 --- a/llvm/tools/llvm-cov/CodeCoverage.cpp +++ b/llvm/tools/llvm-cov/CodeCoverage.cpp @@ -288,6 +288,8 @@ CodeCoverageTool::createSourceFileView(StringRef SourceFile, auto View = SourceCoverageView::create(SourceFile, SourceBuffer.get(), ViewOpts, std::move(FileCoverage)); attachExpansionSubViews(*View, Expansions, Coverage); + if (!ViewOpts.ShowFunctionInstantiations) + return View; for (const auto *Function : Coverage.getInstantiations(SourceFile)) { std::unique_ptr SubView{nullptr}; @@ -696,7 +698,7 @@ int CodeCoverageTool::show(int argc, const char **argv, cl::opt ShowInstantiations("show-instantiations", cl::Optional, cl::desc("Show function instantiations"), - cl::cat(ViewCategory)); + cl::init(true), cl::cat(ViewCategory)); cl::opt ShowOutputDirectory( "output-dir", cl::init(""), -- 2.7.4