Lines Matching full:coverage
1 //===- CodeCoverage.cpp - Coverage tool based on profiling instrumentation-===//
10 // report coverage information using the profiling instrumentation and code
11 // coverage mapping.
29 #include "llvm/ProfileData/Coverage/CoverageMapping.h"
52 using namespace coverage;
54 void exportCoverageDataToJson(const coverage::CoverageMapping &CoverageMapping,
59 /// The implementation of the coverage tool.
100 const CoverageMapping &Coverage);
113 const CoverageMapping &Coverage);
117 createSourceFileView(StringRef SourceFile, const CoverageMapping &Coverage);
119 /// Load the coverage mapping data. Return nullptr if an error occurred.
122 /// Create a mapping from files in the Coverage data to local copies
124 void remapPathNames(const CoverageMapping &Coverage);
126 /// Remove input source files which aren't mapped by \p Coverage.
127 void removeUnmappedInputs(const CoverageMapping &Coverage);
130 void demangleSymbols(const CoverageMapping &Coverage);
133 void writeSourceFileView(StringRef SourceFile, CoverageMapping *Coverage,
161 /// In -path-equivalence mode, this maps the absolute paths from the coverage
165 /// The coverage data path to be remapped from, and the source path to be
173 /// The architecture the coverage mapping data targets.
307 const CoverageMapping &Coverage) { in attachExpansionSubViews() argument
311 auto ExpansionCoverage = Coverage.getCoverageForExpansion(Expansion); in attachExpansionSubViews()
323 attachExpansionSubViews(*SubView, SubViewExpansions, Coverage); in attachExpansionSubViews()
371 const CoverageMapping &Coverage) { in createFunctionView() argument
372 auto FunctionCoverage = Coverage.getCoverageForFunction(Function); in createFunctionView()
385 attachExpansionSubViews(*View, Expansions, Coverage); in createFunctionView()
394 const CoverageMapping &Coverage) { in createSourceFileView() argument
398 auto FileCoverage = Coverage.getCoverageForFile(SourceFile); in createSourceFileView()
407 attachExpansionSubViews(*View, Expansions, Coverage); in createSourceFileView()
413 for (const auto &Group : Coverage.getInstantiationGroups(SourceFile)) { in createSourceFileView()
424 auto SubViewCoverage = Coverage.getCoverageForFunction(*Function); in createSourceFileView()
430 attachExpansionSubViews(*SubView, SubViewExpansions, Coverage); in createSourceFileView()
467 error("failed to load coverage: " + toString(std::move(E))); in load()
470 auto Coverage = std::move(CoverageOrErr.get()); in load() local
471 unsigned Mismatched = Coverage->getMismatchedCount(); in load()
476 for (const auto &HashMismatch : Coverage->getHashMismatches()) in load()
484 remapPathNames(*Coverage); in load()
487 removeUnmappedInputs(*Coverage); in load()
489 demangleSymbols(*Coverage); in load()
491 return Coverage; in load()
494 void CodeCoverageTool::remapPathNames(const CoverageMapping &Coverage) { in remapPathNames() argument
514 // Create a mapping from coverage data file paths to local paths. in remapPathNames()
515 for (StringRef Filename : Coverage.getUniqueSourceFiles()) { in remapPathNames()
529 // Convert input files from local paths to coverage data file paths. in remapPathNames()
544 void CodeCoverageTool::removeUnmappedInputs(const CoverageMapping &Coverage) { in removeUnmappedInputs() argument
545 std::vector<StringRef> CoveredFiles = Coverage.getUniqueSourceFiles(); in removeUnmappedInputs()
547 // The user may have specified source files which aren't in the coverage in removeUnmappedInputs()
554 void CodeCoverageTool::demangleSymbols(const CoverageMapping &Coverage) { in demangleSymbols() argument
570 for (const auto &Function : Coverage.getCoveredFunctions()) { in demangleSymbols()
625 for (const auto &Function : Coverage.getCoveredFunctions()) in demangleSymbols()
632 CoverageMapping *Coverage, in writeSourceFileView() argument
635 auto View = createSourceFileView(SourceFile, *Coverage); in writeSourceFileView()
659 "object", cl::desc("Coverage executable or object file")); in run()
663 cl::desc("Show the collected coverage object files")); in run()
678 "arch", cl::desc("architectures of the coverage mapping binaries")); in run()
692 "format", cl::desc("Output format for line-based coverage reports"), in run()
703 cl::desc("<from>,<to> Map coverage data paths to local source file " in run()
710 cl::desc("Show code coverage only for functions with the given name"), in run()
715 cl::desc("Show code coverage only for functions listed in the given " in run()
721 cl::desc("Show code coverage only for functions that match the given " in run()
732 "region-coverage-lt", cl::Optional, in run()
733 cl::desc("Show code coverage only for functions with region coverage " in run()
738 "region-coverage-gt", cl::Optional, in run()
739 cl::desc("Show code coverage only for functions with region coverage " in run()
744 "line-coverage-lt", cl::Optional, in run()
745 cl::desc("Show code coverage only for functions with line coverage less " in run()
750 "line-coverage-gt", cl::Optional, in run()
751 cl::desc("Show code coverage only for functions with line coverage " in run()
792 cl::desc("Directory used as a base for relative coverage mapping paths")); in run()
799 cl::ParseCommandLineOptions(argc, argv, "LLVM code coverage tool\n"); in run()
986 cl::desc("Show coverage for branch conditions"), cl::cat(ViewCategory), in doShow()
995 cl::desc("Show the MCDC Coverage for each applicable boolean expression"), in doShow()
1012 cl::opt<bool> ShowDirectoryCoverage("show-directory-coverage", cl::Optional, in doShow()
1013 cl::desc("Show directory coverage"), in doShow()
1018 cl::desc("Directory in which coverage information is written out")); in doShow()
1025 "Set tab expansion size for html coverage reports (default = 2)")); in doShow()
1029 cl::desc("Set project title for the coverage report")); in doShow()
1032 "coverage-watermark", cl::Optional, in doShow()
1034 "coverage watermark")); in doShow()
1052 "-coverage-watermark"); in doShow()
1062 "-coverage-watermark"); in doShow()
1071 "-coverage-watermark"); in doShow()
1081 "-coverage-watermark"); in doShow()
1122 auto Coverage = load(); in doShow() local
1123 if (!Coverage) in doShow()
1129 // Get the source files from the function coverage mapping. in doShow()
1130 for (StringRef Filename : Coverage->getUniqueSourceFiles()) { in doShow()
1137 if (Error E = Printer->createIndexFile(SourceFiles, *Coverage, Filters)) { in doShow()
1148 for (const auto &Function : Coverage->getCoveredFunctions(SourceFile)) in doShow()
1149 if (Filters.matches(*Coverage, Function)) in doShow()
1166 auto FunctionView = createFunctionView(*Function, *Coverage); in doShow()
1168 warning("Could not read coverage for '" + Function->Name + "'."); in doShow()
1196 writeSourceFileView(SourceFile, Coverage.get(), Printer.get(), in doShow()
1203 Coverage.get(), Printer.get(), ShowFilenames); in doShow()
1214 cl::desc("Show coverage summaries for each function")); in doReport()
1234 auto Coverage = load(); in doReport() local
1235 if (!Coverage) in doReport()
1238 CoverageReport Report(ViewOpts, *Coverage); in doReport()
1283 error("coverage data can only be exported as textual JSON or an " in doExport()
1294 auto Coverage = load(); in doExport() local
1295 if (!Coverage) { in doExport()
1296 error("could not load coverage information"); in doExport()
1305 std::make_unique<CoverageExporterJson>(*Coverage, ViewOpts, outs()); in doExport()
1313 std::make_unique<CoverageExporterLcov>(*Coverage, ViewOpts, outs()); in doExport()