]> granicus.if.org Git - llvm/commitdiff
[llvm-cov] Demangle symbols in function summaries (fixes PR31394)
authorVedant Kumar <vsk@apple.com>
Sun, 5 Feb 2017 20:11:03 +0000 (20:11 +0000)
committerVedant Kumar <vsk@apple.com>
Sun, 5 Feb 2017 20:11:03 +0000 (20:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294136 91177308-0d34-0410-b5e6-96231b3b80d8

test/tools/llvm-cov/demangle.test
tools/llvm-cov/CodeCoverage.cpp
tools/llvm-cov/CoverageReport.cpp
tools/llvm-cov/CoverageReport.h

index 90a26b734067240a9ad8d64f293ec2ff7fe3e6f9..360fcd97249a24ccd69a7248b7a546597e6167fa 100644 (file)
@@ -4,5 +4,8 @@ RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S
 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 that we demangle names when printing out function summaries.
+RUN: llvm-cov report %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
index 52169b6607cc4459cd56edca46e6d375369fee8d..a23dcc9ee1a8a72b7305cf147ba3c6e38dada90a 100644 (file)
@@ -823,7 +823,7 @@ int CodeCoverageTool::report(int argc, const char **argv,
   if (SourceFiles.empty())
     Report.renderFileReports(llvm::outs());
   else
-    Report.renderFunctionReports(SourceFiles, llvm::outs());
+    Report.renderFunctionReports(SourceFiles, DC, llvm::outs());
   return 0;
 }
 
index e88cb186acd667b72f75ec2f7cca2a6a8748082f..78333d09ad801fda2890b94a5fa1f4a3ea7e2c2f 100644 (file)
@@ -200,12 +200,14 @@ void CoverageReport::render(const FileCoverageSummary &File,
 }
 
 void CoverageReport::render(const FunctionCoverageSummary &Function,
+                            const DemangleCache &DC,
                             raw_ostream &OS) const {
   auto FuncCoverageColor =
       determineCoveragePercentageColor(Function.RegionCoverage);
   auto LineCoverageColor =
       determineCoveragePercentageColor(Function.LineCoverage);
-  OS << column(Function.Name, FunctionReportColumns[0], Column::RightTrim)
+  OS << column(DC.demangle(Function.Name), FunctionReportColumns[0],
+               Column::RightTrim)
      << format("%*u", FunctionReportColumns[1],
                (unsigned)Function.RegionCoverage.NumRegions);
   Options.colored_ostream(OS, FuncCoverageColor)
@@ -230,6 +232,7 @@ void CoverageReport::render(const FunctionCoverageSummary &Function,
 }
 
 void CoverageReport::renderFunctionReports(ArrayRef<std::string> Files,
+                                           const DemangleCache &DC,
                                            raw_ostream &OS) {
   bool isFirst = true;
   for (StringRef Filename : Files) {
@@ -242,7 +245,7 @@ void CoverageReport::renderFunctionReports(ArrayRef<std::string> Files,
 
     std::vector<StringRef> Funcnames;
     for (const auto &F : Functions)
-      Funcnames.emplace_back(F.Name);
+      Funcnames.emplace_back(DC.demangle(F.Name));
     adjustColumnWidths({}, Funcnames);
 
     OS << "File '" << Filename << "':\n";
@@ -262,12 +265,12 @@ void CoverageReport::renderFunctionReports(ArrayRef<std::string> Files,
       ++Totals.ExecutionCount;
       Totals.RegionCoverage += Function.RegionCoverage;
       Totals.LineCoverage += Function.LineCoverage;
-      render(Function, OS);
+      render(Function, DC, OS);
     }
     if (Totals.ExecutionCount) {
       renderDivider(FunctionReportColumns, OS);
       OS << "\n";
-      render(Totals, OS);
+      render(Totals, DC, OS);
     }
   }
 }
index 7a416497e258eda35296619299ebf62a54815de4..071be2e21594c6f65f783df571e91596c31944f7 100644 (file)
@@ -25,14 +25,16 @@ class CoverageReport {
   const coverage::CoverageMapping &Coverage;
 
   void render(const FileCoverageSummary &File, raw_ostream &OS) const;
-  void render(const FunctionCoverageSummary &Function, raw_ostream &OS) const;
+  void render(const FunctionCoverageSummary &Function, const DemangleCache &DC,
+              raw_ostream &OS) const;
 
 public:
   CoverageReport(const CoverageViewOptions &Options,
                  const coverage::CoverageMapping &Coverage)
       : Options(Options), Coverage(Coverage) {}
 
-  void renderFunctionReports(ArrayRef<std::string> Files, raw_ostream &OS);
+  void renderFunctionReports(ArrayRef<std::string> Files,
+                             const DemangleCache &DC, raw_ostream &OS);
 
   /// Prepare file reports for the files specified in \p Files.
   static std::vector<FileCoverageSummary>