From e90797794f93666add49a97c4d0940c40dd3ea32 Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Tue, 20 Sep 2016 21:27:48 +0000 Subject: [PATCH] [llvm-cov] Demangle names for hidden instantiation views llvm-svn: 282020 --- llvm/test/tools/llvm-cov/demangle.test | 10 +++++++--- llvm/tools/llvm-cov/CodeCoverage.cpp | 7 ++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/llvm/test/tools/llvm-cov/demangle.test b/llvm/test/tools/llvm-cov/demangle.test index f9a0f9183ebf..90a26b734067 100644 --- a/llvm/test/tools/llvm-cov/demangle.test +++ b/llvm/test/tools/llvm-cov/demangle.test @@ -1,4 +1,8 @@ -// RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -Xdemangler sed -Xdemangler 's/_/X/g' -filename-equivalence %S/showTemplateInstantiations.cpp | FileCheck %s +RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -Xdemangler sed -Xdemangler 's/_/X/g' -filename-equivalence %S/showTemplateInstantiations.cpp | FileCheck %s -// CHECK-DAG: XZ4funcIbEiTX -// CHECK-DAG: XZ4funcIiEiTX +// Check that we demangle names even if the sub-view will be hidden. +RUN: llvm-profdata merge %S/Inputs/hideUnexecutedSubviews.proftext -o %t.profdata +RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %t.profdata -Xdemangler sed -Xdemangler 's/_/X/g' -filename-equivalence %S/showTemplateInstantiations.cpp | FileCheck %s + +CHECK-DAG: XZ4funcIbEiTX +CHECK-DAG: XZ4funcIiEiTX diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp index 9eacbcad5ce8..8c9da116b968 100644 --- a/llvm/tools/llvm-cov/CodeCoverage.cpp +++ b/llvm/tools/llvm-cov/CodeCoverage.cpp @@ -236,12 +236,13 @@ CodeCoverageTool::createSourceFileView(StringRef SourceFile, for (const auto *Function : Coverage.getInstantiations(SourceFile)) { std::unique_ptr SubView{nullptr}; + StringRef Funcname = getSymbolForHumans(Function->Name); + 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)); + Funcname, SourceBuffer.get(), ViewOpts, std::move(SubViewCoverage)); attachExpansionSubViews(*SubView, SubViewExpansions, Coverage); } @@ -250,7 +251,7 @@ CodeCoverageTool::createSourceFileView(StringRef SourceFile, for (const auto &CR : Function->CountedRegions) if (CR.FileID == FileID) Line = std::max(CR.LineEnd, Line); - View->addInstantiation(Function->Name, Line, std::move(SubView)); + View->addInstantiation(Funcname, Line, std::move(SubView)); } return View; }