Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===- CoverageMappingWriter.h - Code coverage mapping writer ---*- C++ -*-===// |
| 2 | // |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 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 |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file contains support for writing coverage mapping data for |
| 10 | // instrumentation based coverage. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPINGWRITER_H |
| 15 | #define LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPINGWRITER_H |
| 16 | |
| 17 | #include "llvm/ADT/ArrayRef.h" |
| 18 | #include "llvm/ADT/StringRef.h" |
| 19 | #include "llvm/ProfileData/Coverage/CoverageMapping.h" |
| 20 | |
| 21 | namespace llvm { |
| 22 | |
| 23 | class raw_ostream; |
| 24 | |
| 25 | namespace coverage { |
| 26 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 27 | /// Writer of the filenames section for the instrumentation |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 28 | /// based code coverage. |
| 29 | class CoverageFilenamesSectionWriter { |
| 30 | ArrayRef<StringRef> Filenames; |
| 31 | |
| 32 | public: |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 33 | CoverageFilenamesSectionWriter(ArrayRef<StringRef> Filenames); |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 34 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 35 | /// Write encoded filenames to the given output stream. If \p Compress is |
| 36 | /// true, attempt to compress the filenames. |
| 37 | void write(raw_ostream &OS, bool Compress = true); |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 38 | }; |
| 39 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 40 | /// Writer for instrumentation based coverage mapping data. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 41 | class CoverageMappingWriter { |
| 42 | ArrayRef<unsigned> VirtualFileMapping; |
| 43 | ArrayRef<CounterExpression> Expressions; |
| 44 | MutableArrayRef<CounterMappingRegion> MappingRegions; |
| 45 | |
| 46 | public: |
| 47 | CoverageMappingWriter(ArrayRef<unsigned> VirtualFileMapping, |
| 48 | ArrayRef<CounterExpression> Expressions, |
| 49 | MutableArrayRef<CounterMappingRegion> MappingRegions) |
| 50 | : VirtualFileMapping(VirtualFileMapping), Expressions(Expressions), |
| 51 | MappingRegions(MappingRegions) {} |
| 52 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 53 | /// Write encoded coverage mapping data to the given output stream. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 54 | void write(raw_ostream &OS); |
| 55 | }; |
| 56 | |
| 57 | } // end namespace coverage |
| 58 | |
| 59 | } // end namespace llvm |
| 60 | |
| 61 | #endif // LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPINGWRITER_H |