mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-05 17:43:35 +03:00
Add support for -cov=ctfe
Incl. making sure `-cov=N ... -cov[=ctfe]` doesn't reset the required percentage to 0. Use a dummy *bool* option for a better help output (displaying `--cov`, not `--cov=<value>`).
This commit is contained in:
parent
9677bf4068
commit
47b25ca6ab
3 changed files with 38 additions and 34 deletions
|
@ -23,33 +23,6 @@ llvm::SmallVector<const char *, 32> allArguments;
|
||||||
|
|
||||||
cl::OptionCategory linkingCategory("Linking options");
|
cl::OptionCategory linkingCategory("Linking options");
|
||||||
|
|
||||||
/* Option parser that defaults to zero when no explicit number is given.
|
|
||||||
* i.e.: -cov --> value = 0
|
|
||||||
* -cov=9 --> value = 9
|
|
||||||
* -cov=101 --> error, value must be in range [0..100]
|
|
||||||
*/
|
|
||||||
struct CoverageParser : public cl::parser<unsigned char> {
|
|
||||||
explicit CoverageParser(cl::Option &O) : cl::parser<unsigned char>(O) {}
|
|
||||||
|
|
||||||
bool parse(cl::Option &O, llvm::StringRef /*ArgName*/, llvm::StringRef Arg,
|
|
||||||
unsigned char &Val) {
|
|
||||||
if (Arg == "") {
|
|
||||||
Val = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Arg.getAsInteger(0, Val)) {
|
|
||||||
return O.error("'" + Arg +
|
|
||||||
"' value invalid for required coverage percentage");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Val > 100) {
|
|
||||||
return O.error("Required coverage percentage must be <= 100");
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Positional options first, in order:
|
// Positional options first, in order:
|
||||||
cl::list<std::string> fileList(cl::Positional, cl::desc("files"));
|
cl::list<std::string> fileList(cl::Positional, cl::desc("files"));
|
||||||
|
|
||||||
|
@ -515,11 +488,43 @@ cl::opt<bool, true> betterC(
|
||||||
"betterC", cl::ZeroOrMore, cl::location(global.params.betterC),
|
"betterC", cl::ZeroOrMore, cl::location(global.params.betterC),
|
||||||
cl::desc("Omit generating some runtime information and helper functions"));
|
cl::desc("Omit generating some runtime information and helper functions"));
|
||||||
|
|
||||||
cl::opt<unsigned char, true, CoverageParser> coverageAnalysis(
|
// `-cov[=<n>|ctfe]` parser.
|
||||||
"cov", cl::ZeroOrMore, cl::location(global.params.covPercent),
|
struct CoverageParser : public cl::parser<bool> {
|
||||||
cl::desc("Compile-in code coverage analysis\n(use -cov=n for n% "
|
explicit CoverageParser(cl::Option &O) : cl::parser<bool>(O) {}
|
||||||
"minimum required coverage)"),
|
|
||||||
cl::ValueOptional, cl::init(127));
|
bool parse(cl::Option &O, llvm::StringRef /*ArgName*/, llvm::StringRef Arg,
|
||||||
|
bool & /*Val*/) {
|
||||||
|
global.params.cov = true;
|
||||||
|
|
||||||
|
if (Arg.empty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Arg == "ctfe") {
|
||||||
|
global.params.ctfe_cov = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char percent = 0;
|
||||||
|
if (Arg.getAsInteger(0, percent)) {
|
||||||
|
return O.error("'" + Arg +
|
||||||
|
"' value invalid for required coverage percentage");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (percent > 100) {
|
||||||
|
return O.error("required coverage percentage must be <= 100");
|
||||||
|
}
|
||||||
|
|
||||||
|
global.params.covPercent = percent;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static cl::opt<bool, false, CoverageParser> coverageAnalysis(
|
||||||
|
"cov", cl::ZeroOrMore,
|
||||||
|
cl::desc("Compile-in code coverage analysis and .lst file generation\n"
|
||||||
|
"Use -cov=<n> for n% minimum required coverage\n"
|
||||||
|
"Use -cov=ctfe to include code executed during CTFE"));
|
||||||
|
|
||||||
cl::opt<LTOKind> ltoMode(
|
cl::opt<LTOKind> ltoMode(
|
||||||
"flto", cl::ZeroOrMore, cl::desc("Set LTO mode, requires linker support"),
|
"flto", cl::ZeroOrMore, cl::desc("Set LTO mode, requires linker support"),
|
||||||
|
|
|
@ -158,6 +158,7 @@ Where:\n\
|
||||||
force colored console output on or off, or only when not redirected (default)\n\
|
force colored console output on or off, or only when not redirected (default)\n\
|
||||||
-conf=<filename> use config file at filename\n\
|
-conf=<filename> use config file at filename\n\
|
||||||
-cov do code coverage analysis\n\
|
-cov do code coverage analysis\n\
|
||||||
|
-cov=ctfe include code executed during CTFE in coverage report\n\
|
||||||
-cov=<nnn> require at least nnn%% code coverage\n\
|
-cov=<nnn> require at least nnn%% code coverage\n\
|
||||||
-D generate documentation\n\
|
-D generate documentation\n\
|
||||||
-Dd<directory> write documentation file to directory\n\
|
-Dd<directory> write documentation file to directory\n\
|
||||||
|
|
|
@ -429,8 +429,6 @@ void parseCommandLine(Strings &sourceFiles) {
|
||||||
global.params.output_mlir = opts::output_mlir ? OUTPUTFLAGset : OUTPUTFLAGno;
|
global.params.output_mlir = opts::output_mlir ? OUTPUTFLAGset : OUTPUTFLAGno;
|
||||||
global.params.output_s = opts::output_s ? OUTPUTFLAGset : OUTPUTFLAGno;
|
global.params.output_s = opts::output_s ? OUTPUTFLAGset : OUTPUTFLAGno;
|
||||||
|
|
||||||
global.params.cov = (global.params.covPercent <= 100);
|
|
||||||
|
|
||||||
templateLinkage = opts::linkonceTemplates ? LLGlobalValue::LinkOnceODRLinkage
|
templateLinkage = opts::linkonceTemplates ? LLGlobalValue::LinkOnceODRLinkage
|
||||||
: LLGlobalValue::WeakODRLinkage;
|
: LLGlobalValue::WeakODRLinkage;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue