// RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -show-instantiations=false -path-equivalence=/tmp,%S %s | FileCheck -check-prefix=NO_INSTS %s
// NO_INSTS-NOT: {{^ *}}| _Z4funcIbEiT_:
// NO_INSTS-NOT: {{^ *}}| _Z4funcIiEiT_:
+
+// RUN: llvm-cov report %S/Inputs/templateInstantiations.covmapping -dump -instr-profile %S/Inputs/templateInstantiations.profdata -path-equivalence=/tmp,%S %s | FileCheck -check-prefix=DUMP %s
+// DUMP: InstantiationGroup: Definition at line 7, column 30 with size = 2
+// DUMP: InstantiationGroup: main with size = 1
using namespace coverage;
void exportCoverageDataToJson(const coverage::CoverageMapping &CoverageMapping,
+ const CoverageViewOptions &Options,
raw_ostream &OS);
namespace {
return 1;
}
- exportCoverageDataToJson(*Coverage.get(), outs());
+ exportCoverageDataToJson(*Coverage.get(), ViewOpts, outs());
return 0;
}
using namespace coverage;
class CoverageExporterJson {
+ const CoverageViewOptions &Options;
+
/// \brief Output stream to print JSON to.
raw_ostream &OS;
std::vector<std::string> SourceFiles;
for (StringRef SF : Coverage.getUniqueSourceFiles())
SourceFiles.emplace_back(SF);
- auto FileReports =
- CoverageReport::prepareFileReports(Coverage, Totals, SourceFiles);
+ auto FileReports = CoverageReport::prepareFileReports(Coverage, Totals,
+ SourceFiles, Options);
renderFiles(SourceFiles, FileReports);
emitDictKey("functions");
}
public:
- CoverageExporterJson(const CoverageMapping &CoverageMapping, raw_ostream &OS)
- : OS(OS), Coverage(CoverageMapping) {
+ CoverageExporterJson(const CoverageMapping &CoverageMapping,
+ const CoverageViewOptions &Options, raw_ostream &OS)
+ : Options(Options), OS(OS), Coverage(CoverageMapping) {
State.push(JsonState::None);
}
/// \brief Export the given CoverageMapping to a JSON Format.
void exportCoverageDataToJson(const CoverageMapping &CoverageMapping,
+ const CoverageViewOptions &Options,
raw_ostream &OS) {
- auto Exporter = CoverageExporterJson(CoverageMapping, OS);
+ auto Exporter = CoverageExporterJson(CoverageMapping, Options, OS);
Exporter.print();
}
}
}
-std::vector<FileCoverageSummary>
-CoverageReport::prepareFileReports(const coverage::CoverageMapping &Coverage,
- FileCoverageSummary &Totals,
- ArrayRef<std::string> Files) {
+std::vector<FileCoverageSummary> CoverageReport::prepareFileReports(
+ const coverage::CoverageMapping &Coverage, FileCoverageSummary &Totals,
+ ArrayRef<std::string> Files, const CoverageViewOptions &Options) {
std::vector<FileCoverageSummary> FileReports;
unsigned LCP = getRedundantPrefixLen(Files);
auto GroupSummary =
FunctionCoverageSummary::get(Group, InstantiationSummaries);
+
+ if (Options.Debug)
+ outs() << "InstantiationGroup: " << GroupSummary.Name << " with "
+ << "size = " << Group.size() << "\n";
+
Summary.addFunction(GroupSummary);
Totals.addFunction(GroupSummary);
}
void CoverageReport::renderFileReports(raw_ostream &OS,
ArrayRef<std::string> Files) const {
FileCoverageSummary Totals("TOTAL");
- auto FileReports = prepareFileReports(Coverage, Totals, Files);
+ auto FileReports = prepareFileReports(Coverage, Totals, Files, Options);
std::vector<StringRef> Filenames;
for (const FileCoverageSummary &FCS : FileReports)
/// Prepare file reports for the files specified in \p Files.
static std::vector<FileCoverageSummary>
prepareFileReports(const coverage::CoverageMapping &Coverage,
- FileCoverageSummary &Totals, ArrayRef<std::string> Files);
+ FileCoverageSummary &Totals, ArrayRef<std::string> Files,
+ const CoverageViewOptions &Options);
/// Render file reports for every unique file in the coverage mapping.
void renderFileReports(raw_ostream &OS) const;
<< Group.getColumn();
}
- FunctionCoverageSummary Summary(std::move(Name));
+ FunctionCoverageSummary Summary(Name);
Summary.ExecutionCount = Group.getTotalExecutionCount();
Summary.RegionCoverage = Summaries[0].RegionCoverage;
Summary.LineCoverage = Summaries[0].LineCoverage;
RegionCoverageInfo RegionCoverage;
LineCoverageInfo LineCoverage;
- FunctionCoverageSummary(StringRef Name) : Name(Name), ExecutionCount(0) {}
+ FunctionCoverageSummary(const std::string &Name)
+ : Name(Name), ExecutionCount(0) {}
- FunctionCoverageSummary(StringRef Name, uint64_t ExecutionCount,
+ FunctionCoverageSummary(const std::string &Name, uint64_t ExecutionCount,
const RegionCoverageInfo &RegionCoverage,
const LineCoverageInfo &LineCoverage)
: Name(Name), ExecutionCount(ExecutionCount),
- RegionCoverage(RegionCoverage), LineCoverage(LineCoverage) {
- }
+ RegionCoverage(RegionCoverage), LineCoverage(LineCoverage) {}
/// \brief Compute the code coverage summary for the given function coverage
/// mapping record.
emitColumnLabelsForIndex(OSRef);
FileCoverageSummary Totals("TOTALS");
auto FileReports =
- CoverageReport::prepareFileReports(Coverage, Totals, SourceFiles);
+ CoverageReport::prepareFileReports(Coverage, Totals, SourceFiles, Opts);
bool EmptyFiles = false;
for (unsigned I = 0, E = FileReports.size(); I < E; ++I) {
if (FileReports[I].FunctionCoverage.NumFunctions)