• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_COVERAGEMAPPINGWRITER_H
16 #define LLVM_PROFILEDATA_COVERAGEMAPPINGWRITER_H
17 
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/StringMap.h"
20 #include "llvm/ProfileData/Coverage/CoverageMapping.h"
21 #include "llvm/Support/raw_ostream.h"
22 
23 namespace llvm {
24 namespace coverage {
25 
26 /// \brief Writer of the filenames section for the instrumentation
27 /// based code coverage.
28 class CoverageFilenamesSectionWriter {
29   ArrayRef<StringRef> Filenames;
30 
31 public:
CoverageFilenamesSectionWriter(ArrayRef<StringRef> Filenames)32   CoverageFilenamesSectionWriter(ArrayRef<StringRef> Filenames)
33       : Filenames(Filenames) {}
34 
35   /// \brief Write encoded filenames to the given output stream.
36   void write(raw_ostream &OS);
37 };
38 
39 /// \brief Writer for instrumentation based coverage mapping data.
40 class CoverageMappingWriter {
41   ArrayRef<unsigned> VirtualFileMapping;
42   ArrayRef<CounterExpression> Expressions;
43   MutableArrayRef<CounterMappingRegion> MappingRegions;
44 
45 public:
CoverageMappingWriter(ArrayRef<unsigned> VirtualFileMapping,ArrayRef<CounterExpression> Expressions,MutableArrayRef<CounterMappingRegion> MappingRegions)46   CoverageMappingWriter(ArrayRef<unsigned> VirtualFileMapping,
47                         ArrayRef<CounterExpression> Expressions,
48                         MutableArrayRef<CounterMappingRegion> MappingRegions)
49       : VirtualFileMapping(VirtualFileMapping), Expressions(Expressions),
50         MappingRegions(MappingRegions) {}
51 
CoverageMappingWriter(ArrayRef<CounterExpression> Expressions,MutableArrayRef<CounterMappingRegion> MappingRegions)52   CoverageMappingWriter(ArrayRef<CounterExpression> Expressions,
53                         MutableArrayRef<CounterMappingRegion> MappingRegions)
54       : Expressions(Expressions), MappingRegions(MappingRegions) {}
55 
56   /// \brief Write encoded coverage mapping data to the given output stream.
57   void write(raw_ostream &OS);
58 };
59 
60 } // end namespace coverage
61 } // end namespace llvm
62 
63 #endif
64