#include "CoverageMappingGen.h"
#include "CodeGenFunction.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/FileManager.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Lex/Lexer.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ProfileData/Coverage/CoverageMapping.h"
#include "llvm/ProfileData/Coverage/CoverageMappingReader.h"
#include "llvm/ProfileData/Coverage/CoverageMappingWriter.h"
#include "llvm/ProfileData/InstrProfReader.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include <optional>
#define COVMAP_V3
namespace llvm {
cl::opt<bool>
EnableSingleByteCoverage("enable-single-byte-coverage",
llvm::cl::ZeroOrMore,
llvm::cl::desc("Enable single byte coverage"),
llvm::cl::Hidden, llvm::cl::init(false));
}
static llvm::cl::opt<bool> EmptyLineCommentCoverage(
"emptyline-comment-coverage",
llvm::cl::desc("Emit emptylines and comment lines as skipped regions (only "
"disable it on test)"),
llvm::cl::init(true), llvm::cl::Hidden);
namespace llvm::coverage {
cl::opt<bool> SystemHeadersCoverage(
"system-headers-coverage",
cl::desc("Enable collecting coverage from system headers"), cl::init(false),
cl::Hidden);
}
usingnamespaceclang;
usingnamespaceCodeGen;
usingnamespacellvm::coverage;
CoverageSourceInfo *
CoverageMappingModuleGen::setUpCoverageCallbacks(Preprocessor &PP) { … }
void CoverageSourceInfo::AddSkippedRange(SourceRange Range,
SkippedRange::Kind RangeKind) { … }
void CoverageSourceInfo::SourceRangeSkipped(SourceRange Range, SourceLocation) { … }
void CoverageSourceInfo::HandleEmptyline(SourceRange Range) { … }
bool CoverageSourceInfo::HandleComment(Preprocessor &PP, SourceRange Range) { … }
void CoverageSourceInfo::updateNextTokLoc(SourceLocation Loc) { … }
namespace {
class SourceMappingRegion { … };
struct SpellingRegion { … };
class CoverageMappingBuilder { … };
struct EmptyCoverageMappingBuilder : public CoverageMappingBuilder { … };
struct MCDCCoverageBuilder { … };
struct CounterCoverageMappingBuilder
: public CoverageMappingBuilder,
public ConstStmtVisitor<CounterCoverageMappingBuilder> { … };
}
static void dump(llvm::raw_ostream &OS, StringRef FunctionName,
ArrayRef<CounterExpression> Expressions,
ArrayRef<CounterMappingRegion> Regions) { … }
CoverageMappingModuleGen::CoverageMappingModuleGen(
CodeGenModule &CGM, CoverageSourceInfo &SourceInfo)
: … { … }
std::string CoverageMappingModuleGen::getCurrentDirname() { … }
std::string CoverageMappingModuleGen::normalizeFilename(StringRef Filename) { … }
static std::string getInstrProfSection(const CodeGenModule &CGM,
llvm::InstrProfSectKind SK) { … }
void CoverageMappingModuleGen::emitFunctionMappingRecord(
const FunctionInfo &Info, uint64_t FilenamesRef) { … }
void CoverageMappingModuleGen::addFunctionMappingRecord(
llvm::GlobalVariable *NamePtr, StringRef NameValue, uint64_t FuncHash,
const std::string &CoverageMapping, bool IsUsed) { … }
void CoverageMappingModuleGen::emit() { … }
unsigned CoverageMappingModuleGen::getFileID(FileEntryRef File) { … }
void CoverageMappingGen::emitCounterMapping(const Decl *D,
llvm::raw_ostream &OS) { … }
void CoverageMappingGen::emitEmptyMapping(const Decl *D,
llvm::raw_ostream &OS) { … }