CoverageMappingWriter.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- CoverageMappingWriter.h - Code coverage mapping writer ---*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file contains support for writing coverage mapping data for
  15. // instrumentation based coverage.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPINGWRITER_H
  19. #define LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPINGWRITER_H
  20. #include "llvm/ADT/ArrayRef.h"
  21. #include "llvm/ADT/StringRef.h"
  22. #include "llvm/ProfileData/Coverage/CoverageMapping.h"
  23. namespace llvm {
  24. class raw_ostream;
  25. namespace coverage {
  26. /// Writer of the filenames section for the instrumentation
  27. /// based code coverage.
  28. class CoverageFilenamesSectionWriter {
  29. ArrayRef<std::string> Filenames;
  30. public:
  31. CoverageFilenamesSectionWriter(ArrayRef<std::string> Filenames);
  32. /// Write encoded filenames to the given output stream. If \p Compress is
  33. /// true, attempt to compress the filenames.
  34. void write(raw_ostream &OS, bool Compress = true);
  35. };
  36. /// Writer for instrumentation based coverage mapping data.
  37. class CoverageMappingWriter {
  38. ArrayRef<unsigned> VirtualFileMapping;
  39. ArrayRef<CounterExpression> Expressions;
  40. MutableArrayRef<CounterMappingRegion> MappingRegions;
  41. public:
  42. CoverageMappingWriter(ArrayRef<unsigned> VirtualFileMapping,
  43. ArrayRef<CounterExpression> Expressions,
  44. MutableArrayRef<CounterMappingRegion> MappingRegions)
  45. : VirtualFileMapping(VirtualFileMapping), Expressions(Expressions),
  46. MappingRegions(MappingRegions) {}
  47. /// Write encoded coverage mapping data to the given output stream.
  48. void write(raw_ostream &OS);
  49. };
  50. } // end namespace coverage
  51. } // end namespace llvm
  52. #endif // LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPINGWRITER_H
  53. #ifdef __GNUC__
  54. #pragma GCC diagnostic pop
  55. #endif