blob: 303e5184d4937a5aab3d7bee243270a8bcfe738c [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===- CoverageMappingWriter.h - Code coverage mapping writer ---*- C++ -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// 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 Scull5e1ddfa2018-08-14 10:06:54 +01006//
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
21namespace llvm {
22
23class raw_ostream;
24
25namespace coverage {
26
Andrew Scullcdfcccc2018-10-05 20:58:37 +010027/// Writer of the filenames section for the instrumentation
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010028/// based code coverage.
29class CoverageFilenamesSectionWriter {
30 ArrayRef<StringRef> Filenames;
31
32public:
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020033 CoverageFilenamesSectionWriter(ArrayRef<StringRef> Filenames);
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010034
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020035 /// 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 Scull5e1ddfa2018-08-14 10:06:54 +010038};
39
Andrew Scullcdfcccc2018-10-05 20:58:37 +010040/// Writer for instrumentation based coverage mapping data.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010041class CoverageMappingWriter {
42 ArrayRef<unsigned> VirtualFileMapping;
43 ArrayRef<CounterExpression> Expressions;
44 MutableArrayRef<CounterMappingRegion> MappingRegions;
45
46public:
47 CoverageMappingWriter(ArrayRef<unsigned> VirtualFileMapping,
48 ArrayRef<CounterExpression> Expressions,
49 MutableArrayRef<CounterMappingRegion> MappingRegions)
50 : VirtualFileMapping(VirtualFileMapping), Expressions(Expressions),
51 MappingRegions(MappingRegions) {}
52
Andrew Scullcdfcccc2018-10-05 20:58:37 +010053 /// Write encoded coverage mapping data to the given output stream.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010054 void write(raw_ostream &OS);
55};
56
57} // end namespace coverage
58
59} // end namespace llvm
60
61#endif // LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPINGWRITER_H