CoverageReport.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //===- CoverageReport.h - Code coverage report ----------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This class implements rendering of a code coverage report.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_COV_COVERAGEREPORT_H
  13. #define LLVM_COV_COVERAGEREPORT_H
  14. #include "CoverageFilters.h"
  15. #include "CoverageSummaryInfo.h"
  16. #include "CoverageViewOptions.h"
  17. namespace llvm {
  18. /// Displays the code coverage report.
  19. class CoverageReport {
  20. const CoverageViewOptions &Options;
  21. const coverage::CoverageMapping &Coverage;
  22. void render(const FileCoverageSummary &File, raw_ostream &OS) const;
  23. void render(const FunctionCoverageSummary &Function, const DemangleCache &DC,
  24. raw_ostream &OS) const;
  25. public:
  26. CoverageReport(const CoverageViewOptions &Options,
  27. const coverage::CoverageMapping &Coverage)
  28. : Options(Options), Coverage(Coverage) {}
  29. void renderFunctionReports(ArrayRef<std::string> Files,
  30. const DemangleCache &DC, raw_ostream &OS);
  31. /// Prepare file reports for the files specified in \p Files.
  32. static std::vector<FileCoverageSummary>
  33. prepareFileReports(const coverage::CoverageMapping &Coverage,
  34. FileCoverageSummary &Totals, ArrayRef<std::string> Files,
  35. const CoverageViewOptions &Options,
  36. const CoverageFilter &Filters = CoverageFiltersMatchAll());
  37. static void
  38. prepareSingleFileReport(const StringRef Filename,
  39. const coverage::CoverageMapping *Coverage,
  40. const CoverageViewOptions &Options,
  41. const unsigned LCP,
  42. FileCoverageSummary *FileReport,
  43. const CoverageFilter *Filters);
  44. /// Render file reports for every unique file in the coverage mapping.
  45. void renderFileReports(raw_ostream &OS,
  46. const CoverageFilters &IgnoreFilenameFilters) const;
  47. /// Render file reports for the files specified in \p Files.
  48. void renderFileReports(raw_ostream &OS, ArrayRef<std::string> Files) const;
  49. /// Render file reports for the files specified in \p Files and the functions
  50. /// in \p Filters.
  51. void renderFileReports(raw_ostream &OS, ArrayRef<std::string> Files,
  52. const CoverageFiltersMatchAll &Filters) const;
  53. };
  54. } // end namespace llvm
  55. #endif // LLVM_COV_COVERAGEREPORT_H