13#ifndef LLVM_CLANG_LIB_CODEGEN_COVERAGEMAPPINGGEN_H
14#define LLVM_CLANG_LIB_CODEGEN_COVERAGEMAPPINGGEN_H
20#include "llvm/ADT/DenseMap.h"
21#include "llvm/IR/GlobalValue.h"
22#include "llvm/Support/CommandLine.h"
23#include "llvm/Support/raw_ostream.h"
71 std::vector<SkippedRange> SkippedRanges;
107 struct FunctionInfo {
110 std::string CoverageMapping;
116 llvm::SmallDenseMap<FileEntryRef, unsigned, 8> FileEntries;
117 std::vector<llvm::Constant *> FunctionNames;
118 std::vector<FunctionInfo> FunctionRecords;
120 std::string getCurrentDirname();
121 std::string normalizeFilename(StringRef
Filename);
124 void emitFunctionMappingRecord(
const FunctionInfo &Info,
125 uint64_t FilenamesRef);
139 StringRef FunctionNameValue,
140 uint64_t FunctionHash,
141 const std::string &CoverageMapping,
161 llvm::DenseMap<const Stmt *, unsigned> *CounterMap;
167 : CVM(CVM),
SM(
SM), LangOpts(LangOpts), CounterMap(nullptr),
168 MCDCState(nullptr) {}
172 llvm::DenseMap<const Stmt *, unsigned> *CounterMap,
174 : CVM(CVM),
SM(
SM), LangOpts(LangOpts), CounterMap(CounterMap),
175 MCDCState(MCDCState) {}
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the PPCallbacks interface.
Defines the clang::Preprocessor interface.
Defines the clang::SourceLocation class and associated facilities.
This class organizes the cross-function state that is used while generating LLVM code.
Organizes the per-function state that is used while generating code coverage mapping data.
void emitEmptyMapping(const Decl *D, llvm::raw_ostream &OS)
Emit the coverage mapping data for an unused function.
CoverageMappingGen(CoverageMappingModuleGen &CVM, SourceManager &SM, const LangOptions &LangOpts)
void emitCounterMapping(const Decl *D, llvm::raw_ostream &OS)
Emit the coverage mapping data which maps the regions of code to counters that will be used to find t...
CoverageMappingGen(CoverageMappingModuleGen &CVM, SourceManager &SM, const LangOptions &LangOpts, llvm::DenseMap< const Stmt *, unsigned > *CounterMap, MCDC::State *MCDCState)
Organizes the cross-function state that is used while generating code coverage mapping data.
void addFunctionMappingRecord(llvm::GlobalVariable *FunctionName, StringRef FunctionNameValue, uint64_t FunctionHash, const std::string &CoverageMapping, bool IsUsed=true)
Add a function's coverage mapping record to the collection of the function mapping records.
CoverageSourceInfo & getSourceInfo() const
static CoverageSourceInfo * setUpCoverageCallbacks(Preprocessor &PP)
void emit()
Emit the coverage mapping data for a translation unit.
CodeGenModule & getCodeGenModule()
Return an interface into CodeGenModule.
unsigned getFileID(FileEntryRef File)
Return the coverage mapping translation unit file id for the given file.
Stores additional source code information like skipped ranges which is required by the coverage mappi...
void SourceRangeSkipped(SourceRange Range, SourceLocation EndifLoc) override
Hook called when a source range is skipped.
void updateNextTokLoc(SourceLocation Loc)
void AddSkippedRange(SourceRange Range, SkippedRange::Kind RangeKind)
std::vector< SkippedRange > & getSkippedRanges()
bool HandleComment(Preprocessor &PP, SourceRange Range) override
SourceLocation PrevTokLoc
CoverageSourceInfo(SourceManager &SourceMgr)
void HandleEmptyline(SourceRange Range) override
Decl - This represents one declaration (or definition), e.g.
Abstract base class that describes a handler that will receive source ranges for empty lines encounte...
A reference to a FileEntry that includes the name of the file as it was accessed by the FileManager's...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
This interface provides a way to observe the actions of the preprocessor as it does its thing.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Encodes a location in the source.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
The JSON file list parser is used to communicate input to InstallAPI.
cl::opt< bool > SystemHeadersCoverage
Per-Function MC/DC state.
SourceLocation NextTokLoc
SkippedRange(SourceRange Range, Kind K, SourceLocation PrevTokLoc=SourceLocation(), SourceLocation NextTokLoc=SourceLocation())
SourceLocation PrevTokLoc