Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:23

0001 //===- CoverageMappingWriter.h - Code coverage mapping writer ---*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file contains support for writing coverage mapping data for
0010 // instrumentation based coverage.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPINGWRITER_H
0015 #define LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPINGWRITER_H
0016 
0017 #include "llvm/ADT/ArrayRef.h"
0018 #include "llvm/ADT/StringRef.h"
0019 #include "llvm/ProfileData/Coverage/CoverageMapping.h"
0020 
0021 namespace llvm {
0022 
0023 class raw_ostream;
0024 
0025 namespace coverage {
0026 
0027 /// Writer of the filenames section for the instrumentation
0028 /// based code coverage.
0029 class CoverageFilenamesSectionWriter {
0030   ArrayRef<std::string> Filenames;
0031 
0032 public:
0033   CoverageFilenamesSectionWriter(ArrayRef<std::string> Filenames);
0034 
0035   /// Write encoded filenames to the given output stream. If \p Compress is
0036   /// true, attempt to compress the filenames.
0037   void write(raw_ostream &OS, bool Compress = true);
0038 };
0039 
0040 /// Writer for instrumentation based coverage mapping data.
0041 class CoverageMappingWriter {
0042   ArrayRef<unsigned> VirtualFileMapping;
0043   ArrayRef<CounterExpression> Expressions;
0044   MutableArrayRef<CounterMappingRegion> MappingRegions;
0045 
0046 public:
0047   CoverageMappingWriter(ArrayRef<unsigned> VirtualFileMapping,
0048                         ArrayRef<CounterExpression> Expressions,
0049                         MutableArrayRef<CounterMappingRegion> MappingRegions)
0050       : VirtualFileMapping(VirtualFileMapping), Expressions(Expressions),
0051         MappingRegions(MappingRegions) {}
0052 
0053   /// Write encoded coverage mapping data to the given output stream.
0054   void write(raw_ostream &OS);
0055 };
0056 
0057 /// Writer for the coverage mapping testing format.
0058 class TestingFormatWriter {
0059   uint64_t ProfileNamesAddr;
0060   StringRef ProfileNamesData;
0061   StringRef CoverageMappingData;
0062   StringRef CoverageRecordsData;
0063 
0064 public:
0065   TestingFormatWriter(uint64_t ProfileNamesAddr, StringRef ProfileNamesData,
0066                       StringRef CoverageMappingData,
0067                       StringRef CoverageRecordsData)
0068       : ProfileNamesAddr(ProfileNamesAddr), ProfileNamesData(ProfileNamesData),
0069         CoverageMappingData(CoverageMappingData),
0070         CoverageRecordsData(CoverageRecordsData) {}
0071 
0072   /// Encode to the given output stream.
0073   void
0074   write(raw_ostream &OS,
0075         TestingFormatVersion Version = TestingFormatVersion::CurrentVersion);
0076 };
0077 
0078 } // end namespace coverage
0079 
0080 } // end namespace llvm
0081 
0082 #endif // LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPINGWRITER_H