[llvm-cov] Demangle symbols in function summaries (fixes PR31394)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294136 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Vedant Kumar 2017-02-05 20:11:03 +00:00
parent 4858447bc5
commit b766e93f51
4 changed files with 15 additions and 7 deletions

View 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

View 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;
}

View 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);
}
}
}

View 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>