//===- CoverageExporterLcov.cpp - Code coverage export --------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file implements export of code coverage data to lcov trace file format. // //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// // // The trace file code coverage export follows the following format (see also // https://linux.die.net/man/1/geninfo). Each quoted string appears on its own // line; the indentation shown here is only for documentation purposes. // // - for each source file: // - "SF:<absolute path to source file>" // - for each function: // - "FN:<line number of function start>,<function name>" // - for each function: // - "FNDA:<execution count>,<function name>" // - "FNF:<number of functions found>" // - "FNH:<number of functions hit>" // - for each instrumented line: // - "DA:<line number>,<execution count>[,<checksum>] // - for each branch: // - "BRDA:<line number>,<branch pair id>,<branch id>,<count>" // - "BRF:<number of branches found>" // - "BRH:<number of branches hit>" // - "LH:<number of lines with non-zero execution count>" // - "LF:<number of instrumented lines>" // - "end_of_record" // // If the user is exporting summary information only, then the FN, FNDA, and DA // lines will not be present. // //===----------------------------------------------------------------------===// #include "CoverageExporterLcov.h" #include "CoverageReport.h" usingnamespacellvm; namespace { void renderFunctionSummary(raw_ostream &OS, const FileCoverageSummary &Summary) { … } void renderFunctions( raw_ostream &OS, const iterator_range<coverage::FunctionRecordIterator> &Functions) { … } void renderLineExecutionCounts(raw_ostream &OS, const coverage::CoverageData &FileCoverage) { … } std::vector<llvm::coverage::CountedRegion> collectNestedBranches(const coverage::CoverageMapping &Coverage, ArrayRef<llvm::coverage::ExpansionRecord> Expansions, int ViewDepth = 0, int SrcLine = 0) { … } bool sortLine(llvm::coverage::CountedRegion I, llvm::coverage::CountedRegion J) { … } void renderBranchExecutionCounts(raw_ostream &OS, const coverage::CoverageMapping &Coverage, const coverage::CoverageData &FileCoverage) { … } void renderLineSummary(raw_ostream &OS, const FileCoverageSummary &Summary) { … } void renderBranchSummary(raw_ostream &OS, const FileCoverageSummary &Summary) { … } void renderFile(raw_ostream &OS, const coverage::CoverageMapping &Coverage, const std::string &Filename, const FileCoverageSummary &FileReport, bool ExportSummaryOnly, bool SkipFunctions, bool SkipBranches) { … } void renderFiles(raw_ostream &OS, const coverage::CoverageMapping &Coverage, ArrayRef<std::string> SourceFiles, ArrayRef<FileCoverageSummary> FileReports, bool ExportSummaryOnly, bool SkipFunctions, bool SkipBranches) { … } } // end anonymous namespace void CoverageExporterLcov::renderRoot(const CoverageFilters &IgnoreFilters) { … } void CoverageExporterLcov::renderRoot(ArrayRef<std::string> SourceFiles) { … }