Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame^] | 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 | |
| 15 | #ifndef LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPINGWRITER_H |
| 16 | #define LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPINGWRITER_H |
| 17 | |
| 18 | #include "llvm/ADT/ArrayRef.h" |
| 19 | #include "llvm/ADT/StringRef.h" |
| 20 | #include "llvm/ProfileData/Coverage/CoverageMapping.h" |
| 21 | |
| 22 | namespace llvm { |
| 23 | |
| 24 | class raw_ostream; |
| 25 | |
| 26 | namespace coverage { |
| 27 | |
| 28 | /// \brief Writer of the filenames section for the instrumentation |
| 29 | /// based code coverage. |
| 30 | class CoverageFilenamesSectionWriter { |
| 31 | ArrayRef<StringRef> Filenames; |
| 32 | |
| 33 | public: |
| 34 | CoverageFilenamesSectionWriter(ArrayRef<StringRef> Filenames) |
| 35 | : Filenames(Filenames) {} |
| 36 | |
| 37 | /// \brief Write encoded filenames to the given output stream. |
| 38 | void write(raw_ostream &OS); |
| 39 | }; |
| 40 | |
| 41 | /// \brief Writer for instrumentation based coverage mapping data. |
| 42 | class CoverageMappingWriter { |
| 43 | ArrayRef<unsigned> VirtualFileMapping; |
| 44 | ArrayRef<CounterExpression> Expressions; |
| 45 | MutableArrayRef<CounterMappingRegion> MappingRegions; |
| 46 | |
| 47 | public: |
| 48 | CoverageMappingWriter(ArrayRef<unsigned> VirtualFileMapping, |
| 49 | ArrayRef<CounterExpression> Expressions, |
| 50 | MutableArrayRef<CounterMappingRegion> MappingRegions) |
| 51 | : VirtualFileMapping(VirtualFileMapping), Expressions(Expressions), |
| 52 | MappingRegions(MappingRegions) {} |
| 53 | |
| 54 | /// \brief Write encoded coverage mapping data to the given output stream. |
| 55 | void write(raw_ostream &OS); |
| 56 | }; |
| 57 | |
| 58 | } // end namespace coverage |
| 59 | |
| 60 | } // end namespace llvm |
| 61 | |
| 62 | #endif // LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPINGWRITER_H |