зеркало из https://github.com/microsoft/clang-1.git
Add flags for additional control over coverage generation. Pick the version
string to be emitted, and two properties about the files themselves. Use $PWD to absolut-ify the path to the coverage file. Yes, this is what GCC does. Reverts my own r175706. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176617 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
018e9aa033
Коммит
0f815f1f91
|
@ -149,6 +149,12 @@ def femit_coverage_data: Flag<["-"], "femit-coverage-data">,
|
|||
def coverage_file : Separate<["-"], "coverage-file">,
|
||||
HelpText<"Emit coverage data to this filename. The extension will be replaced.">;
|
||||
def coverage_file_EQ : Joined<["-"], "coverage-file=">, Alias<coverage_file>;
|
||||
def coverage_cfg_checksum : Flag<["-"], "coverage-cfg-checksum">,
|
||||
HelpText<"Emit CFG checksum for functions in .gcno files.">;
|
||||
def coverage_function_names_in_data : Flag<["-"], "coverage-function-names-in-data">,
|
||||
HelpText<"Emit function names in .gcda files.">;
|
||||
def coverage_version_EQ : Joined<["-"], "coverage-version=">,
|
||||
HelpText<"Four-byte version string for gcov files.">;
|
||||
def fuse_register_sized_bitfield_access: Flag<["-"], "fuse-register-sized-bitfield-access">,
|
||||
HelpText<"Use register sized accesses to bit-fields, when possible.">;
|
||||
def relaxed_aliasing : Flag<["-"], "relaxed-aliasing">,
|
||||
|
|
|
@ -30,6 +30,8 @@ CODEGENOPT(Name, Bits, Default)
|
|||
|
||||
CODEGENOPT(AsmVerbose , 1, 0) ///< -dA, -fverbose-asm.
|
||||
CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be EH-safe.
|
||||
CODEGENOPT(CoverageExtraChecksum, 1, 0) ///< Whether we need a second checksum for functions in GCNO files.
|
||||
CODEGENOPT(CoverageFunctionNamesInData, 1, 0) ///< Whether we should include function names in GCDA files.
|
||||
CODEGENOPT(CUDAIsDevice , 1, 0) ///< Set when compiling for CUDA device.
|
||||
CODEGENOPT(CXAAtExit , 1, 1) ///< Use __cxa_atexit for calling destructors.
|
||||
CODEGENOPT(CXXCtorDtorAliases, 1, 0) ///< Emit complete ctors/dtors as linker
|
||||
|
|
|
@ -78,6 +78,9 @@ public:
|
|||
/// replaced.
|
||||
std::string CoverageFile;
|
||||
|
||||
/// The version string to put into coverage files.
|
||||
char CoverageVersion[4];
|
||||
|
||||
/// Enable additional debugging information.
|
||||
std::string DebugPass;
|
||||
|
||||
|
@ -134,6 +137,7 @@ public:
|
|||
#include "clang/Frontend/CodeGenOptions.def"
|
||||
|
||||
RelocationModel = "pic";
|
||||
memcpy(CoverageVersion, "*204", 4);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -2332,8 +2332,15 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
if (Output.isFilename()) {
|
||||
CmdArgs.push_back("-coverage-file");
|
||||
SmallString<128> CoverageFilename(Output.getFilename());
|
||||
if (!C.getArgs().hasArg(options::OPT_no_canonical_prefixes))
|
||||
llvm::sys::fs::make_absolute(CoverageFilename);
|
||||
if (llvm::sys::path::is_relative(CoverageFilename.str())) {
|
||||
if (const char *pwd = ::getenv("PWD")) {
|
||||
if (llvm::sys::path::is_absolute(pwd)) {
|
||||
SmallString<128> Pwd(pwd);
|
||||
llvm::sys::path::append(Pwd, CoverageFilename.str());
|
||||
CoverageFilename.swap(Pwd);
|
||||
}
|
||||
}
|
||||
}
|
||||
CmdArgs.push_back(Args.MakeArgString(CoverageFilename));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -380,12 +380,31 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
|
|||
Opts.VerifyModule = !Args.hasArg(OPT_disable_llvm_verifier);
|
||||
Opts.SanitizeRecover = !Args.hasArg(OPT_fno_sanitize_recover);
|
||||
|
||||
Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
|
||||
Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
|
||||
Opts.EmitGcovArcs = Args.hasArg(OPT_femit_coverage_data);
|
||||
Opts.EmitGcovNotes = Args.hasArg(OPT_femit_coverage_notes);
|
||||
Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
|
||||
if (Opts.EmitGcovArcs || Opts.EmitGcovNotes) {
|
||||
Opts.CoverageFile = Args.getLastArgValue(OPT_coverage_file);
|
||||
Opts.CoverageExtraChecksum = Args.hasArg(OPT_coverage_cfg_checksum);
|
||||
Opts.CoverageFunctionNamesInData =
|
||||
Args.hasArg(OPT_coverage_function_names_in_data);
|
||||
if (Args.hasArg(OPT_coverage_version_EQ)) {
|
||||
StringRef CoverageVersion = Args.getLastArgValue(OPT_coverage_version_EQ);
|
||||
if (CoverageVersion.size() != 4) {
|
||||
Diags.Report(diag::err_drv_invalid_value)
|
||||
<< Args.getLastArg(OPT_coverage_version_EQ)->getAsString(Args)
|
||||
<< CoverageVersion;
|
||||
} else {
|
||||
Opts.CoverageVersion[0] = CoverageVersion[3];
|
||||
Opts.CoverageVersion[1] = CoverageVersion[2];
|
||||
Opts.CoverageVersion[2] = CoverageVersion[1];
|
||||
Opts.CoverageVersion[3] = CoverageVersion[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
|
||||
Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
|
||||
Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
|
||||
Opts.DebugCompilationDir = Args.getLastArgValue(OPT_fdebug_compilation_dir);
|
||||
Opts.LinkBitcodeFile = Args.getLastArgValue(OPT_mlink_bitcode_file);
|
||||
Opts.SanitizerBlacklistFile = Args.getLastArgValue(OPT_fsanitize_blacklist);
|
||||
|
|
Загрузка…
Ссылка в новой задаче