CoverageMappingWriter.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //=-- CoverageMappingWriter.h - Code coverage mapping writer ------*- C++ -*-=//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file contains support for writing coverage mapping data for
  11. // instrumentation based coverage.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #ifndef LLVM_PROFILEDATA_COVERAGEMAPPINGWRITER_H
  15. #define LLVM_PROFILEDATA_COVERAGEMAPPINGWRITER_H
  16. #include "llvm/ADT/ArrayRef.h"
  17. #include "llvm/ADT/StringMap.h"
  18. #include "llvm/ProfileData/CoverageMapping.h"
  19. #include "llvm/Support/raw_ostream.h"
  20. namespace llvm {
  21. namespace coverage {
  22. /// \brief Writer of the filenames section for the instrumentation
  23. /// based code coverage.
  24. class CoverageFilenamesSectionWriter {
  25. ArrayRef<StringRef> Filenames;
  26. public:
  27. CoverageFilenamesSectionWriter(ArrayRef<StringRef> Filenames)
  28. : Filenames(Filenames) {}
  29. /// \brief Write encoded filenames to the given output stream.
  30. void write(raw_ostream &OS);
  31. };
  32. /// \brief Writer for instrumentation based coverage mapping data.
  33. class CoverageMappingWriter {
  34. ArrayRef<unsigned> VirtualFileMapping;
  35. ArrayRef<CounterExpression> Expressions;
  36. MutableArrayRef<CounterMappingRegion> MappingRegions;
  37. public:
  38. CoverageMappingWriter(ArrayRef<unsigned> VirtualFileMapping,
  39. ArrayRef<CounterExpression> Expressions,
  40. MutableArrayRef<CounterMappingRegion> MappingRegions)
  41. : VirtualFileMapping(VirtualFileMapping), Expressions(Expressions),
  42. MappingRegions(MappingRegions) {}
  43. CoverageMappingWriter(ArrayRef<CounterExpression> Expressions,
  44. MutableArrayRef<CounterMappingRegion> MappingRegions)
  45. : Expressions(Expressions), MappingRegions(MappingRegions) {}
  46. /// \brief Write encoded coverage mapping data to the given output stream.
  47. void write(raw_ostream &OS);
  48. };
  49. } // end namespace coverage
  50. } // end namespace llvm
  51. #endif