]> granicus.if.org Git - llvm/commitdiff
[llvm-cov] Respect the value of the -show-instantiations option
authorVedant Kumar <vsk@apple.com>
Wed, 2 Aug 2017 23:35:24 +0000 (23:35 +0000)
committerVedant Kumar <vsk@apple.com>
Wed, 2 Aug 2017 23:35:24 +0000 (23:35 +0000)
Make `-show-instantiations=false` actually skip displaying instantiation
sub-views, instead of simply ignoring the option.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309903 91177308-0d34-0410-b5e6-96231b3b80d8

docs/CommandGuide/llvm-cov.rst
test/tools/llvm-cov/showTemplateInstantiations.cpp
tools/llvm-cov/CodeCoverage.cpp

index 3732b39740ff121a22d1e9361babb68de0aaeb51..97064c82cf4a2b03d418eddf64cb08e66296df72 100644 (file)
@@ -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
 
index e2fc3709bc79df95ce91625dba965431aaa6a4d9..326eb99f10b7002d59d776889776627cd6ee3247 100644 (file)
@@ -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: <pre>Source (<a href='#L{{[0-9]+}}'>jump to first uncovered line</a>)</pre>
 // HTML-JUMP-NOT: <pre>Source (<a href='#L{{[0-9]+}}'>jump to first uncovered line</a>)</pre>
+
+// 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_:
index 073bd83e7af3e2ae2bb0415a583c249130241ea2..c16d7b44ad628c3d3b890c1cc2b6520741605ba7 100644 (file)
@@ -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<SourceCoverageView> SubView{nullptr};
@@ -696,7 +698,7 @@ int CodeCoverageTool::show(int argc, const char **argv,
 
   cl::opt<bool> ShowInstantiations("show-instantiations", cl::Optional,
                                    cl::desc("Show function instantiations"),
-                                   cl::cat(ViewCategory));
+                                   cl::init(true), cl::cat(ViewCategory));
 
   cl::opt<std::string> ShowOutputDirectory(
       "output-dir", cl::init(""),