blob: 86fb1bdf177374a8caa7ca564ef814cc8ddd62f8 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===- 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
22namespace llvm {
23
24class raw_ostream;
25
26namespace coverage {
27
Andrew Scullcdfcccc2018-10-05 20:58:37 +010028/// Writer of the filenames section for the instrumentation
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010029/// based code coverage.
30class CoverageFilenamesSectionWriter {
31 ArrayRef<StringRef> Filenames;
32
33public:
34 CoverageFilenamesSectionWriter(ArrayRef<StringRef> Filenames)
35 : Filenames(Filenames) {}
36
Andrew Scullcdfcccc2018-10-05 20:58:37 +010037 /// Write encoded filenames to the given output stream.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010038 void write(raw_ostream &OS);
39};
40
Andrew Scullcdfcccc2018-10-05 20:58:37 +010041/// Writer for instrumentation based coverage mapping data.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010042class CoverageMappingWriter {
43 ArrayRef<unsigned> VirtualFileMapping;
44 ArrayRef<CounterExpression> Expressions;
45 MutableArrayRef<CounterMappingRegion> MappingRegions;
46
47public:
48 CoverageMappingWriter(ArrayRef<unsigned> VirtualFileMapping,
49 ArrayRef<CounterExpression> Expressions,
50 MutableArrayRef<CounterMappingRegion> MappingRegions)
51 : VirtualFileMapping(VirtualFileMapping), Expressions(Expressions),
52 MappingRegions(MappingRegions) {}
53
Andrew Scullcdfcccc2018-10-05 20:58:37 +010054 /// Write encoded coverage mapping data to the given output stream.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010055 void write(raw_ostream &OS);
56};
57
58} // end namespace coverage
59
60} // end namespace llvm
61
62#endif // LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPINGWRITER_H