//===- CoverageMappingWriter.cpp - Code coverage mapping writer -----------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file contains support for writing coverage mapping data for // instrumentation based coverage. // //===----------------------------------------------------------------------===// #include "llvm/ProfileData/Coverage/CoverageMappingWriter.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ProfileData/InstrProf.h" #include "llvm/Support/Compression.h" #include "llvm/Support/LEB128.h" #include "llvm/Support/raw_ostream.h" #include <algorithm> #include <cassert> #include <limits> #include <vector> usingnamespacellvm; usingnamespacecoverage; CoverageFilenamesSectionWriter::CoverageFilenamesSectionWriter( ArrayRef<std::string> Filenames) : … { … } void CoverageFilenamesSectionWriter::write(raw_ostream &OS, bool Compress) { … } namespace { /// Gather only the expressions that are used by the mapping /// regions in this function. class CounterExpressionsMinimizer { … }; } // end anonymous namespace /// Encode the counter. /// /// The encoding uses the following format: /// Low 2 bits - Tag: /// Counter::Zero(0) - A Counter with kind Counter::Zero /// Counter::CounterValueReference(1) - A counter with kind /// Counter::CounterValueReference /// Counter::Expression(2) + CounterExpression::Subtract(0) - /// A counter with kind Counter::Expression and an expression /// with kind CounterExpression::Subtract /// Counter::Expression(2) + CounterExpression::Add(1) - /// A counter with kind Counter::Expression and an expression /// with kind CounterExpression::Add /// Remaining bits - Counter/Expression ID. static unsigned encodeCounter(ArrayRef<CounterExpression> Expressions, Counter C) { … } static void writeCounter(ArrayRef<CounterExpression> Expressions, Counter C, raw_ostream &OS) { … } void CoverageMappingWriter::write(raw_ostream &OS) { … } void TestingFormatWriter::write(raw_ostream &OS, TestingFormatVersion Version) { … }