Allow multiple occurrences for almost all command-line flags

Except for `-sanitize` and `-cache-prune*`.
This commit is contained in:
Martin 2017-05-14 02:43:09 +02:00
parent 6c6379d534
commit d01a91f755
13 changed files with 149 additions and 183 deletions

View file

@ -114,8 +114,7 @@ namespace {
// Options for the cache pruning algorithm // Options for the cache pruning algorithm
llvm::cl::opt<bool> pruneEnabled("cache-prune", llvm::cl::opt<bool> pruneEnabled("cache-prune",
llvm::cl::desc("Enable cache pruning."), llvm::cl::desc("Enable cache pruning."));
llvm::cl::ZeroOrMore);
llvm::cl::opt<unsigned long long> pruneSizeLimitInBytes( llvm::cl::opt<unsigned long long> pruneSizeLimitInBytes(
"cache-prune-maxbytes", "cache-prune-maxbytes",
llvm::cl::desc("Sets the maximum cache size to <size> bytes. Implies " llvm::cl::desc("Sets the maximum cache size to <size> bytes. Implies "
@ -142,7 +141,7 @@ llvm::cl::opt<unsigned> pruneSizeLimitPercentage(
enum class RetrievalMode { Copy, HardLink, AnyLink, SymLink }; enum class RetrievalMode { Copy, HardLink, AnyLink, SymLink };
llvm::cl::opt<RetrievalMode> cacheRecoveryMode( llvm::cl::opt<RetrievalMode> cacheRecoveryMode(
"cache-retrieval", "cache-retrieval", llvm::cl::ZeroOrMore,
llvm::cl::desc("Set the cache retrieval mechanism (default: copy)."), llvm::cl::desc("Set the cache retrieval mechanism (default: copy)."),
llvm::cl::init(RetrievalMode::Copy), llvm::cl::init(RetrievalMode::Copy),
clEnumValues( clEnumValues(

View file

@ -77,9 +77,8 @@ cl::opt<bool, true>
cl::opt<bool> compileOnly("c", cl::desc("Do not link"), cl::ZeroOrMore); cl::opt<bool> compileOnly("c", cl::desc("Do not link"), cl::ZeroOrMore);
static cl::opt<bool, true> createStaticLib("lib", static cl::opt<bool, true> createStaticLib("lib", cl::ZeroOrMore,
cl::desc("Create static library"), cl::desc("Create static library"),
cl::ZeroOrMore,
cl::location(global.params.lib)); cl::location(global.params.lib));
static cl::opt<bool, true> static cl::opt<bool, true>
@ -103,9 +102,8 @@ static cl::opt<bool, true> verbose_cg("v-cg", cl::desc("Verbose codegen"),
cl::location(global.params.verbose_cg)); cl::location(global.params.verbose_cg));
static cl::opt<unsigned, true> errorLimit( static cl::opt<unsigned, true> errorLimit(
"verrors", cl::ZeroOrMore, "verrors", cl::ZeroOrMore, cl::location(global.errorLimit),
cl::desc("Limit the number of error messages (0 means unlimited)"), cl::desc("Limit the number of error messages (0 means unlimited)"));
cl::location(global.errorLimit));
static cl::opt<bool, true> static cl::opt<bool, true>
showGaggedErrors("verrors-spec", cl::ZeroOrMore, showGaggedErrors("verrors-spec", cl::ZeroOrMore,
@ -114,12 +112,12 @@ static cl::opt<bool, true>
"__traits(compiles,...)")); "__traits(compiles,...)"));
static cl::opt<ubyte, true> warnings( static cl::opt<ubyte, true> warnings(
cl::desc("Warnings:"), cl::ZeroOrMore, cl::desc("Warnings:"), cl::ZeroOrMore, cl::location(global.params.warnings),
clEnumValues( clEnumValues(
clEnumValN(1, "w", "Enable warnings as errors (compilation will halt)"), clEnumValN(1, "w", "Enable warnings as errors (compilation will halt)"),
clEnumValN(2, "wi", clEnumValN(2, "wi",
"Enable warnings as messages (compilation will continue)")), "Enable warnings as messages (compilation will continue)")),
cl::location(global.params.warnings), cl::init(0)); cl::init(0));
static cl::opt<bool, true> ignoreUnsupportedPragmas( static cl::opt<bool, true> ignoreUnsupportedPragmas(
"ignore", cl::desc("Ignore unsupported pragmas"), cl::ZeroOrMore, "ignore", cl::desc("Ignore unsupported pragmas"), cl::ZeroOrMore,
@ -135,11 +133,11 @@ static cl::opt<ubyte, true> debugInfo(
cl::location(global.params.symdebug), cl::init(0)); cl::location(global.params.symdebug), cl::init(0));
static cl::opt<unsigned, true> static cl::opt<unsigned, true>
dwarfVersion("dwarf-version", cl::desc("Dwarf version"), dwarfVersion("dwarf-version", cl::desc("Dwarf version"), cl::ZeroOrMore,
cl::location(global.params.dwarfVersion), cl::init(0), cl::location(global.params.dwarfVersion), cl::Hidden);
cl::Hidden);
cl::opt<bool> noAsm("noasm", cl::desc("Disallow use of inline assembler")); cl::opt<bool> noAsm("noasm", cl::desc("Disallow use of inline assembler"),
cl::ZeroOrMore);
// Output file options // Output file options
cl::opt<bool> dontWriteObj("o-", cl::desc("Do not write object file"), cl::opt<bool> dontWriteObj("o-", cl::desc("Do not write object file"),
@ -150,12 +148,13 @@ cl::opt<std::string> objectFile("of", cl::value_desc("filename"), cl::Prefix,
cl::ZeroOrMore); cl::ZeroOrMore);
cl::opt<std::string> objectDir("od", cl::value_desc("directory"), cl::Prefix, cl::opt<std::string> objectDir("od", cl::value_desc("directory"), cl::Prefix,
cl::ZeroOrMore, cl::desc("Write object files to <directory>"),
cl::desc("Write object files to <directory>")); cl::ZeroOrMore);
cl::opt<std::string> cl::opt<std::string>
soname("soname", cl::value_desc("soname"), cl::Hidden, cl::Prefix, soname("soname", cl::value_desc("soname"), cl::Hidden, cl::Prefix,
cl::desc("Use <soname> as output shared library soname")); cl::desc("Use <soname> as output shared library soname"),
cl::ZeroOrMore);
// Output format options // Output format options
cl::opt<bool> output_bc("output-bc", cl::desc("Write LLVM bitcode"), cl::opt<bool> output_bc("output-bc", cl::desc("Write LLVM bitcode"),
@ -170,16 +169,15 @@ cl::opt<cl::boolOrDefault> output_o("output-o", cl::ZeroOrMore,
cl::desc("Write native object")); cl::desc("Write native object"));
static cl::opt<bool, true> static cl::opt<bool, true>
cleanupObjectFiles("cleanup-obj", cleanupObjectFiles("cleanup-obj", cl::ZeroOrMore, cl::ReallyHidden,
cl::desc("Remove generated object files on success"), cl::desc("Remove generated object files on success"),
cl::ZeroOrMore, cl::ReallyHidden,
cl::location(global.params.cleanupObjectFiles)); cl::location(global.params.cleanupObjectFiles));
// Disabling Red Zone // Disabling Red Zone
cl::opt<bool, true> cl::opt<bool, true>
disableRedZone("disable-red-zone", disableRedZone("disable-red-zone", cl::ZeroOrMore,
cl::desc("Do not emit code that uses the red zone."), cl::desc("Do not emit code that uses the red zone."),
cl::location(global.params.disableRedZone), cl::init(false)); cl::location(global.params.disableRedZone));
// DDoc options // DDoc options
static cl::opt<bool, true> doDdoc("D", cl::desc("Generate documentation"), static cl::opt<bool, true> doDdoc("D", cl::desc("Generate documentation"),
@ -208,19 +206,17 @@ static cl::opt<bool, true>
doHdrGen("H", cl::desc("Generate 'header' file"), cl::ZeroOrMore, doHdrGen("H", cl::desc("Generate 'header' file"), cl::ZeroOrMore,
cl::location(global.params.doHdrGeneration)); cl::location(global.params.doHdrGeneration));
cl::opt<std::string> hdrDir("Hd", cl::opt<std::string> hdrDir("Hd", cl::ZeroOrMore, cl::Prefix,
cl::desc("Write 'header' file to <directory>"), cl::desc("Write 'header' file to <directory>"),
cl::value_desc("directory"), cl::Prefix, cl::value_desc("directory"));
cl::ZeroOrMore);
cl::opt<std::string> hdrFile("Hf", cl::ZeroOrMore, cl::opt<std::string> hdrFile("Hf", cl::ZeroOrMore, cl::Prefix,
cl::desc("Write 'header' file to <filename>"), cl::desc("Write 'header' file to <filename>"),
cl::value_desc("filename"), cl::Prefix); cl::value_desc("filename"));
cl::opt<bool> cl::opt<bool>
hdrKeepAllBodies("Hkeep-all-bodies", hdrKeepAllBodies("Hkeep-all-bodies", cl::ZeroOrMore,
cl::desc("Keep all function bodies in .di files"), cl::desc("Keep all function bodies in .di files"));
cl::ZeroOrMore);
static cl::opt<bool, true> unittest("unittest", cl::ZeroOrMore, static cl::opt<bool, true> unittest("unittest", cl::ZeroOrMore,
cl::desc("Compile in unit tests"), cl::desc("Compile in unit tests"),
@ -229,7 +225,7 @@ static cl::opt<bool, true> unittest("unittest", cl::ZeroOrMore,
cl::opt<std::string> cl::opt<std::string>
cacheDir("cache", cl::desc("Enable compilation cache, using <cache dir> to " cacheDir("cache", cl::desc("Enable compilation cache, using <cache dir> to "
"store cache files (experimental)"), "store cache files (experimental)"),
cl::value_desc("cache dir")); cl::value_desc("cache dir"), cl::ZeroOrMore);
static StringsAdapter strImpPathStore("J", global.params.fileImppath); static StringsAdapter strImpPathStore("J", global.params.fileImppath);
static cl::list<std::string, StringsAdapter> stringImportPaths( static cl::list<std::string, StringsAdapter> stringImportPaths(
@ -267,22 +263,19 @@ static D_DebugStorage dds;
// -debug is already declared in LLVM (at least, in debug builds), // -debug is already declared in LLVM (at least, in debug builds),
// so we need to be a bit more verbose. // so we need to be a bit more verbose.
static cl::list<std::string, D_DebugStorage> debugVersionsOption( static cl::list<std::string, D_DebugStorage> debugVersionsOption(
"d-debug", "d-debug", cl::location(dds), cl::CommaSeparated, cl::ValueOptional,
cl::desc("Compile in debug code >= <level> or identified by <idents>"), cl::desc("Compile in debug code >= <level> or identified by <idents>"),
cl::value_desc("level/idents"), cl::location(dds), cl::CommaSeparated, cl::value_desc("level/idents"));
cl::ValueOptional);
// -version is also declared in LLVM, so again we need to be a bit more verbose. // -version is also declared in LLVM, so again we need to be a bit more verbose.
cl::list<std::string> versions( cl::list<std::string> versions(
"d-version", "d-version", cl::CommaSeparated, cl::value_desc("level/idents"),
cl::desc("Compile in version code >= <level> or identified by <idents>"), cl::desc("Compile in version code >= <level> or identified by <idents>"));
cl::value_desc("level/idents"), cl::CommaSeparated);
cl::list<std::string> transitions( cl::list<std::string> transitions(
"transition", "transition", cl::CommaSeparated, cl::value_desc("idents"),
cl::desc( cl::desc(
"Help with language change identified by <idents>, use ? for list"), "Help with language change identified by <idents>, use ? for list"));
cl::value_desc("idents"), cl::CommaSeparated);
cl::list<std::string> linkerSwitches("L", cl::list<std::string> linkerSwitches("L",
cl::desc("Pass <linkerflag> to the linker"), cl::desc("Pass <linkerflag> to the linker"),
@ -293,13 +286,13 @@ cl::list<std::string> ccSwitches("Xcc", cl::CommaSeparated,
cl::value_desc("ccflag")); cl::value_desc("ccflag"));
cl::opt<std::string> cl::opt<std::string>
moduleDeps("deps", moduleDeps("deps", cl::ValueOptional, cl::ZeroOrMore,
cl::value_desc("filename"),
cl::desc("Write module dependencies to filename (only imports). " cl::desc("Write module dependencies to filename (only imports). "
"'-deps' alone prints module dependencies " "'-deps' alone prints module dependencies "
"(imports/file/version/debug/lib)"), "(imports/file/version/debug/lib)"));
cl::value_desc("filename"), cl::ValueOptional);
cl::opt<std::string> mArch("march", cl::opt<std::string> mArch("march", cl::ZeroOrMore,
cl::desc("Architecture to generate code for:")); cl::desc("Architecture to generate code for:"));
cl::opt<bool> m32bits("m32", cl::desc("32 bit target"), cl::ZeroOrMore); cl::opt<bool> m32bits("m32", cl::desc("32 bit target"), cl::ZeroOrMore);
@ -307,23 +300,21 @@ cl::opt<bool> m32bits("m32", cl::desc("32 bit target"), cl::ZeroOrMore);
cl::opt<bool> m64bits("m64", cl::desc("64 bit target"), cl::ZeroOrMore); cl::opt<bool> m64bits("m64", cl::desc("64 bit target"), cl::ZeroOrMore);
cl::opt<std::string> cl::opt<std::string>
mCPU("mcpu", mCPU("mcpu", cl::ZeroOrMore, cl::value_desc("cpu-name"), cl::init(""),
cl::desc("Target a specific cpu type (-mcpu=help for details)"), cl::desc("Target a specific cpu type (-mcpu=help for details)"));
cl::value_desc("cpu-name"), cl::init(""));
cl::list<std::string> cl::list<std::string>
mAttrs("mattr", cl::CommaSeparated, mAttrs("mattr", cl::CommaSeparated,
cl::desc("Target specific attributes (-mattr=help for details)"), cl::value_desc("a1,+a2,-a3,..."),
cl::value_desc("a1,+a2,-a3,...")); cl::desc("Target specific attributes (-mattr=help for details)"));
cl::opt<std::string> mTargetTriple("mtriple", cl::opt<std::string> mTargetTriple("mtriple", cl::ZeroOrMore,
cl::desc("Override target triple")); cl::desc("Override target triple"));
#if LDC_LLVM_VER >= 307 #if LDC_LLVM_VER >= 307
cl::opt<std::string> cl::opt<std::string>
mABI("mabi", mABI("mabi", cl::ZeroOrMore, cl::Hidden, cl::init(""),
cl::desc("The name of the ABI to be targeted from the backend"), cl::desc("The name of the ABI to be targeted from the backend"));
cl::Hidden, cl::init(""));
#endif #endif
static StringsAdapter static StringsAdapter
@ -350,7 +341,8 @@ cl::opt<llvm::Reloc::Model> mRelocModel(
"Relocatable external references, non-relocatable code"))); "Relocatable external references, non-relocatable code")));
cl::opt<llvm::CodeModel::Model> mCodeModel( cl::opt<llvm::CodeModel::Model> mCodeModel(
"code-model", cl::desc("Code model"), cl::init(llvm::CodeModel::Default), "code-model", cl::desc("Code model"), cl::ZeroOrMore,
cl::init(llvm::CodeModel::Default),
clEnumValues( clEnumValues(
clEnumValN(llvm::CodeModel::Default, "default", clEnumValN(llvm::CodeModel::Default, "default",
"Target default code model"), "Target default code model"),
@ -361,7 +353,7 @@ cl::opt<llvm::CodeModel::Model> mCodeModel(
cl::opt<FloatABI::Type> mFloatABI( cl::opt<FloatABI::Type> mFloatABI(
"float-abi", cl::desc("ABI/operations to use for floating-point types:"), "float-abi", cl::desc("ABI/operations to use for floating-point types:"),
cl::init(FloatABI::Default), cl::ZeroOrMore, cl::init(FloatABI::Default),
clEnumValues( clEnumValues(
clEnumValN(FloatABI::Default, "default", clEnumValN(FloatABI::Default, "default",
"Target default floating-point ABI"), "Target default floating-point ABI"),
@ -374,73 +366,67 @@ cl::opt<FloatABI::Type> mFloatABI(
cl::opt<bool> cl::opt<bool>
disableFpElim("disable-fp-elim", cl::ZeroOrMore, disableFpElim("disable-fp-elim", cl::ZeroOrMore,
cl::desc("Disable frame pointer elimination optimization"), cl::desc("Disable frame pointer elimination optimization"));
cl::init(false));
static cl::opt<bool, true, FlagParser<bool>> static cl::opt<bool, true, FlagParser<bool>>
asserts("asserts", cl::desc("(*) Enable assertions"), asserts("asserts", cl::ZeroOrMore, cl::desc("(*) Enable assertions"),
cl::value_desc("bool"), cl::location(global.params.useAssert), cl::value_desc("bool"), cl::location(global.params.useAssert),
cl::init(true)); cl::init(true));
cl::opt<BOUNDSCHECK> boundsCheck( cl::opt<BOUNDSCHECK> boundsCheck(
"boundscheck", cl::desc("Array bounds check"), "boundscheck", cl::ZeroOrMore, cl::desc("Array bounds check"),
cl::init(BOUNDSCHECKdefault),
clEnumValues(clEnumValN(BOUNDSCHECKoff, "off", "Disabled"), clEnumValues(clEnumValN(BOUNDSCHECKoff, "off", "Disabled"),
clEnumValN(BOUNDSCHECKsafeonly, "safeonly", clEnumValN(BOUNDSCHECKsafeonly, "safeonly",
"Enabled for @safe functions only"), "Enabled for @safe functions only"),
clEnumValN(BOUNDSCHECKon, "on", "Enabled for all functions")), clEnumValN(BOUNDSCHECKon, "on", "Enabled for all functions")));
cl::init(BOUNDSCHECKdefault));
static cl::opt<bool, true, FlagParser<bool>> static cl::opt<bool, true, FlagParser<bool>>
invariants("invariants", cl::desc("(*) Enable invariants"), invariants("invariants", cl::ZeroOrMore, cl::desc("(*) Enable invariants"),
cl::location(global.params.useInvariants), cl::init(true)); cl::location(global.params.useInvariants), cl::init(true));
static cl::opt<bool, true, FlagParser<bool>> static cl::opt<bool, true, FlagParser<bool>> preconditions(
preconditions("preconditions", "preconditions", cl::ZeroOrMore, cl::location(global.params.useIn),
cl::desc("(*) Enable function preconditions"), cl::desc("(*) Enable function preconditions"), cl::init(true));
cl::location(global.params.useIn), cl::init(true));
static cl::opt<bool, true, FlagParser<bool>> static cl::opt<bool, true, FlagParser<bool>>
postconditions("postconditions", postconditions("postconditions", cl::ZeroOrMore,
cl::desc("(*) Enable function postconditions"), cl::location(global.params.useOut), cl::init(true),
cl::location(global.params.useOut), cl::init(true)); cl::desc("(*) Enable function postconditions"));
static MultiSetter ContractsSetter(false, &global.params.useIn, static MultiSetter ContractsSetter(false, &global.params.useIn,
&global.params.useOut, NULL); &global.params.useOut, nullptr);
static cl::opt<MultiSetter, true, FlagParser<bool>> static cl::opt<MultiSetter, true, FlagParser<bool>>
contracts("contracts", contracts("contracts", cl::ZeroOrMore, cl::location(ContractsSetter),
cl::desc("(*) Enable function pre- and post-conditions"), cl::desc("(*) Enable function pre- and post-conditions"));
cl::location(ContractsSetter));
bool nonSafeBoundsChecks = true; bool nonSafeBoundsChecks = true;
static MultiSetter ReleaseSetter(true, &global.params.useAssert, static MultiSetter ReleaseSetter(true, &global.params.useAssert,
&nonSafeBoundsChecks, &nonSafeBoundsChecks,
&global.params.useInvariants, &global.params.useInvariants,
&global.params.useOut, &global.params.useIn, &global.params.useOut, &global.params.useIn,
NULL); nullptr);
static cl::opt<MultiSetter, true, cl::parser<bool>> static cl::opt<MultiSetter, true, cl::parser<bool>>
release("release", release("release", cl::ZeroOrMore, cl::location(ReleaseSetter),
cl::desc("Disables asserts, invariants, contracts and boundscheck"), cl::desc("Disables asserts, invariants, contracts and boundscheck"),
cl::location(ReleaseSetter), cl::ValueDisallowed); cl::ValueDisallowed);
cl::opt<bool, true> cl::opt<bool, true>
singleObj("singleobj", cl::desc("Create only a single output object file"), singleObj("singleobj", cl::desc("Create only a single output object file"),
cl::location(global.params.oneobj)); cl::ZeroOrMore, cl::location(global.params.oneobj));
cl::opt<uint32_t, true> hashThreshold( cl::opt<uint32_t, true> hashThreshold(
"hash-threshold", "hash-threshold", cl::ZeroOrMore, cl::location(global.params.hashThreshold),
cl::desc("Hash symbol names longer than this threshold (experimental)"), cl::desc("Hash symbol names longer than this threshold (experimental)"));
cl::location(global.params.hashThreshold), cl::init(0));
cl::opt<bool> linkonceTemplates( cl::opt<bool> linkonceTemplates(
"linkonce-templates", "linkonce-templates", cl::ZeroOrMore,
cl::desc( cl::desc(
"Use linkonce_odr linkage for template symbols instead of weak_odr"), "Use linkonce_odr linkage for template symbols instead of weak_odr"));
cl::ZeroOrMore);
cl::opt<bool> disableLinkerStripDead( cl::opt<bool> disableLinkerStripDead(
"disable-linker-strip-dead", "disable-linker-strip-dead", cl::ZeroOrMore,
cl::desc("Do not try to remove unused symbols during linking"), cl::desc("Do not try to remove unused symbols during linking"));
cl::init(false));
// Math options // Math options
bool fFastMath; // Storage for the dynamically created ffast-math option. bool fFastMath; // Storage for the dynamically created ffast-math option.
@ -455,33 +441,32 @@ void setDefaultMathOptions(llvm::TargetMachine &target) {
} }
cl::opt<bool, true> cl::opt<bool, true>
allinst("allinst", cl::ZeroOrMore, allinst("allinst", cl::ZeroOrMore, cl::location(global.params.allInst),
cl::desc("Generate code for all template instantiations"), cl::desc("Generate code for all template instantiations"));
cl::location(global.params.allInst));
cl::opt<unsigned, true> nestedTemplateDepth( cl::opt<unsigned, true> nestedTemplateDepth(
"template-depth", cl::location(global.params.nestedTmpl), cl::init(500), "template-depth", cl::ZeroOrMore, cl::location(global.params.nestedTmpl),
cl::init(500),
cl::desc( cl::desc(
"Set maximum number of nested template instantiations (experimental)")); "Set maximum number of nested template instantiations (experimental)"));
cl::opt<bool, true> cl::opt<bool, true>
useDIP25("dip25", cl::ZeroOrMore, useDIP25("dip25", cl::ZeroOrMore, cl::location(global.params.useDIP25),
cl::desc("Implement http://wiki.dlang.org/DIP25 (experimental)"), cl::desc("Implement http://wiki.dlang.org/DIP25 (experimental)"));
cl::location(global.params.useDIP25));
cl::opt<bool> useDIP1000( cl::opt<bool> useDIP1000(
"dip1000", cl::ZeroOrMore, "dip1000", cl::ZeroOrMore,
cl::desc("Implement http://wiki.dlang.org/DIP1000 (experimental)")); cl::desc("Implement http://wiki.dlang.org/DIP1000 (experimental)"));
cl::opt<bool, true> betterC( cl::opt<bool, true> betterC(
"betterC", cl::ZeroOrMore, "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::location(global.params.betterC));
cl::opt<unsigned char, true, CoverageParser> coverageAnalysis( cl::opt<unsigned char, true, CoverageParser> coverageAnalysis(
"cov", cl::desc("Compile-in code coverage analysis\n(use -cov=n for n% " "cov", cl::ZeroOrMore, cl::location(global.params.covPercent),
"minimum required coverage)"), cl::desc("Compile-in code coverage analysis\n(use -cov=n for n% "
cl::location(global.params.covPercent), cl::ValueOptional, cl::init(127)); "minimum required coverage)"),
cl::ValueOptional, cl::init(127));
#if LDC_WITH_PGO #if LDC_WITH_PGO
cl::opt<std::string> cl::opt<std::string>
@ -489,22 +474,22 @@ cl::opt<std::string>
cl::desc("Generate instrumented code to collect a runtime " cl::desc("Generate instrumented code to collect a runtime "
"profile into default.profraw (overriden by " "profile into default.profraw (overriden by "
"'=<filename>' or LLVM_PROFILE_FILE env var)"), "'=<filename>' or LLVM_PROFILE_FILE env var)"),
cl::ValueOptional); cl::ZeroOrMore, cl::ValueOptional);
cl::opt<std::string> usefileInstrProf( cl::opt<std::string> usefileInstrProf(
"fprofile-instr-use", cl::value_desc("filename"), "fprofile-instr-use", cl::ZeroOrMore, cl::value_desc("filename"),
cl::desc("Use instrumentation data for profile-guided optimization"), cl::desc("Use instrumentation data for profile-guided optimization"),
cl::ValueRequired); cl::ValueRequired);
#endif #endif
cl::opt<bool> cl::opt<bool>
instrumentFunctions("finstrument-functions", instrumentFunctions("finstrument-functions", cl::ZeroOrMore,
cl::desc("Instrument function entry and exit with " cl::desc("Instrument function entry and exit with "
"GCC-compatible profiling calls")); "GCC-compatible profiling calls"));
#if LDC_LLVM_VER >= 309 #if LDC_LLVM_VER >= 309
cl::opt<LTOKind> ltoMode( cl::opt<LTOKind> ltoMode(
"flto", cl::desc("Set LTO mode, requires linker support"), "flto", cl::ZeroOrMore, cl::desc("Set LTO mode, requires linker support"),
cl::init(LTO_None), cl::init(LTO_None),
clEnumValues( clEnumValues(
clEnumValN(LTO_Full, "full", "Merges all input into a single module"), clEnumValN(LTO_Full, "full", "Merges all input into a single module"),
@ -563,11 +548,10 @@ void createClashingOptions() {
// Step 2. Add the LDC options. // Step 2. Add the LDC options.
new cl::opt<bool, true, FlagParser<bool>>( new cl::opt<bool, true, FlagParser<bool>>(
"color", cl::desc("Force colored console output"), "color", cl::ZeroOrMore, cl::location(global.params.color),
cl::location(global.params.color)); cl::desc("(*) Force colored console output"));
new cl::opt<bool, true>( new cl::opt<bool, true>("ffast-math", cl::ZeroOrMore, cl::location(fFastMath),
"ffast-math", cl::desc("Set @fastmath for all functions."), cl::desc("Set @fastmath for all functions."));
cl::location(fFastMath), cl::init(false), cl::ZeroOrMore);
} }
/// Hides command line options exposed from within LLVM that are unlikely /// Hides command line options exposed from within LLVM that are unlikely

View file

@ -31,9 +31,9 @@ namespace sys = llvm::sys;
// dummy only; needs to be parsed manually earlier as the switches contained in // dummy only; needs to be parsed manually earlier as the switches contained in
// the config file are injected into the command line options fed to the parser // the config file are injected into the command line options fed to the parser
llvm::cl::opt<std::string> static llvm::cl::opt<std::string>
clConf("conf", llvm::cl::desc("Use configuration file <filename>"), clConf("conf", llvm::cl::desc("Use configuration file <filename>"),
llvm::cl::value_desc("filename")); llvm::cl::value_desc("filename"), llvm::cl::ZeroOrMore);
#if _WIN32 #if _WIN32
std::string getUserHomeDirectory() { std::string getUserHomeDirectory() {

View file

@ -33,23 +33,21 @@
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
static llvm::cl::opt<bool> staticFlag( static llvm::cl::opt<bool>
"static", staticFlag("static", llvm::cl::ZeroOrMore,
llvm::cl::desc( llvm::cl::desc("Create a statically linked binary, including "
"Create a statically linked binary, including all system dependencies"), "all system dependencies"));
llvm::cl::ZeroOrMore);
static llvm::cl::opt<std::string> mscrtlib( static llvm::cl::opt<std::string> mscrtlib(
"mscrtlib", "mscrtlib", llvm::cl::ZeroOrMore, llvm::cl::value_desc("name"),
llvm::cl::desc( llvm::cl::desc(
"MS C runtime library to link against (libcmt[d] / msvcrt[d])"), "MS C runtime library to link against (libcmt[d] / msvcrt[d])"));
llvm::cl::value_desc("name"), llvm::cl::ZeroOrMore);
static llvm::cl::opt<std::string> static llvm::cl::opt<std::string>
ltoLibrary("flto-binary", ltoLibrary("flto-binary", llvm::cl::ZeroOrMore,
llvm::cl::desc("Set the linker LTO plugin library file (e.g. " llvm::cl::desc("Set the linker LTO plugin library file (e.g. "
"LLVMgold.so (Unixes) or libLTO.dylib (Darwin))"), "LLVMgold.so (Unixes) or libLTO.dylib (Darwin))"),
llvm::cl::value_desc("file"), llvm::cl::ZeroOrMore); llvm::cl::value_desc("file"));
static llvm::cl::opt<std::string> ar("ar", llvm::cl::desc("Archiver"), static llvm::cl::opt<std::string> ar("ar", llvm::cl::desc("Archiver"),
llvm::cl::Hidden, llvm::cl::ZeroOrMore); llvm::cl::Hidden, llvm::cl::ZeroOrMore);

View file

@ -81,10 +81,9 @@ using namespace opts;
extern void getenv_setargv(const char *envvar, int *pargc, char ***pargv); extern void getenv_setargv(const char *envvar, int *pargc, char ***pargv);
static cl::opt<bool> static cl::opt<bool> noDefaultLib(
noDefaultLib("nodefaultlib", "nodefaultlib", cl::ZeroOrMore, cl::Hidden,
cl::desc("Don't add a default library for linking implicitly"), cl::desc("Don't add a default library for linking implicitly"));
cl::ZeroOrMore, cl::Hidden);
static StringsAdapter impPathsStore("I", global.params.imppath); static StringsAdapter impPathsStore("I", global.params.imppath);
static cl::list<std::string, StringsAdapter> static cl::list<std::string, StringsAdapter>
@ -93,19 +92,16 @@ static cl::list<std::string, StringsAdapter>
cl::Prefix); cl::Prefix);
static cl::opt<std::string> static cl::opt<std::string>
defaultLib("defaultlib", defaultLib("defaultlib", cl::ZeroOrMore, cl::value_desc("lib1,lib2,..."),
cl::desc("Default libraries to link with (overrides previous)"), cl::desc("Default libraries to link with (overrides previous)"));
cl::value_desc("lib1,lib2,..."), cl::ZeroOrMore);
static cl::opt<std::string> debugLib( static cl::opt<std::string> debugLib(
"debuglib", "debuglib", cl::ZeroOrMore, cl::value_desc("lib1,lib2,..."),
cl::desc("Debug versions of default libraries (overrides previous)"), cl::desc("Debug versions of default libraries (overrides previous)"));
cl::value_desc("lib1,lib2,..."), cl::ZeroOrMore);
static cl::opt<bool> linkDebugLib( static cl::opt<bool> linkDebugLib(
"link-debuglib", "link-debuglib", cl::ZeroOrMore,
cl::desc("Link with libraries specified in -debuglib, not -defaultlib"), cl::desc("Link with libraries specified in -debuglib, not -defaultlib"));
cl::ZeroOrMore);
#if LDC_LLVM_VER >= 309 #if LDC_LLVM_VER >= 309
static inline llvm::Optional<llvm::Reloc::Model> getRelocModel() { static inline llvm::Optional<llvm::Reloc::Model> getRelocModel() {

View file

@ -59,7 +59,8 @@ using LLErrorInfo = std::string;
#endif #endif
static llvm::cl::opt<bool> static llvm::cl::opt<bool>
NoIntegratedAssembler("no-integrated-as", llvm::cl::Hidden, NoIntegratedAssembler("no-integrated-as", llvm::cl::ZeroOrMore,
llvm::cl::Hidden,
llvm::cl::desc("Disable integrated assembler")); llvm::cl::desc("Disable integrated assembler"));
// based on llc code, University of Illinois Open Source License // based on llc code, University of Illinois Open Source License

View file

@ -46,7 +46,7 @@
#include "llvm/Support/CommandLine.h" #include "llvm/Support/CommandLine.h"
llvm::cl::opt<llvm::GlobalVariable::ThreadLocalMode> clThreadModel( llvm::cl::opt<llvm::GlobalVariable::ThreadLocalMode> clThreadModel(
"fthread-model", llvm::cl::desc("Thread model"), "fthread-model", llvm::cl::ZeroOrMore, llvm::cl::desc("Thread model"),
llvm::cl::init(llvm::GlobalVariable::GeneralDynamicTLSModel), llvm::cl::init(llvm::GlobalVariable::GeneralDynamicTLSModel),
clEnumValues(clEnumValN(llvm::GlobalVariable::GeneralDynamicTLSModel, clEnumValues(clEnumValN(llvm::GlobalVariable::GeneralDynamicTLSModel,
"global-dynamic", "global-dynamic",

View file

@ -54,14 +54,13 @@
#endif #endif
static llvm::cl::opt<bool, true> static llvm::cl::opt<bool, true>
preservePaths("op", llvm::cl::desc("Preserve source path for output files"), preservePaths("op", llvm::cl::ZeroOrMore,
llvm::cl::ZeroOrMore, llvm::cl::desc("Preserve source path for output files"),
llvm::cl::location(global.params.preservePaths)); llvm::cl::location(global.params.preservePaths));
static llvm::cl::opt<bool, true> static llvm::cl::opt<bool, true>
fqnNames("oq", fqnNames("oq", llvm::cl::ZeroOrMore,
llvm::cl::desc("Write object files with fully qualified names"), llvm::cl::desc("Write object files with fully qualified names"),
llvm::cl::ZeroOrMore,
llvm::cl::location(global.params.fullyQualifiedObjectFiles)); llvm::cl::location(global.params.fullyQualifiedObjectFiles));
void Module::checkAndAddOutputFile(File *file) { void Module::checkAndAddOutputFile(File *file) {

View file

@ -54,54 +54,46 @@ static cl::opt<signed char> optimizeLevel(
clEnumValN(-2, "Oz", "Like -Os but reduces code size further")), clEnumValN(-2, "Oz", "Like -Os but reduces code size further")),
cl::init(0)); cl::init(0));
static cl::opt<bool> noVerify("disable-verify", static cl::opt<bool> noVerify("disable-verify", cl::ZeroOrMore, cl::Hidden,
cl::desc("Do not verify result module"), cl::desc("Do not verify result module"));
cl::Hidden);
static cl::opt<bool> static cl::opt<bool>
verifyEach("verify-each", verifyEach("verify-each", cl::ZeroOrMore, cl::Hidden,
cl::desc("Run verifier after D-specific and explicitly " cl::desc("Run verifier after D-specific and explicitly "
"specified optimization passes"), "specified optimization passes"));
cl::Hidden, cl::ZeroOrMore);
static cl::opt<bool> static cl::opt<bool>
disableLangSpecificPasses("disable-d-passes", disableLangSpecificPasses("disable-d-passes", cl::ZeroOrMore,
cl::desc("Disable all D-specific passes"), cl::desc("Disable all D-specific passes"));
cl::ZeroOrMore);
static cl::opt<bool> disableSimplifyDruntimeCalls( static cl::opt<bool> disableSimplifyDruntimeCalls(
"disable-simplify-drtcalls", "disable-simplify-drtcalls", cl::ZeroOrMore,
cl::desc("Disable simplification of druntime calls"), cl::ZeroOrMore); cl::desc("Disable simplification of druntime calls"));
static cl::opt<bool> disableSimplifyLibCalls( static cl::opt<bool> disableSimplifyLibCalls(
"disable-simplify-libcalls", "disable-simplify-libcalls", cl::ZeroOrMore,
cl::desc("Disable simplification of well-known C runtime calls"), cl::desc("Disable simplification of well-known C runtime calls"));
cl::ZeroOrMore);
static cl::opt<bool> disableGCToStack( static cl::opt<bool> disableGCToStack(
"disable-gc2stack", "disable-gc2stack", cl::ZeroOrMore,
cl::desc("Disable promotion of GC allocations to stack memory"), cl::desc("Disable promotion of GC allocations to stack memory"));
cl::ZeroOrMore);
static cl::opt<cl::boolOrDefault, false, opts::FlagParser<cl::boolOrDefault>> static cl::opt<cl::boolOrDefault, false, opts::FlagParser<cl::boolOrDefault>>
enableInlining( enableInlining(
"inlining", "inlining", cl::ZeroOrMore,
cl::desc("Enable function inlining (default in -O2 and higher)"), cl::desc("(*) Enable function inlining (default in -O2 and higher)"));
cl::ZeroOrMore);
static llvm::cl::opt<llvm::cl::boolOrDefault, false, static cl::opt<cl::boolOrDefault, false, opts::FlagParser<cl::boolOrDefault>>
opts::FlagParser<llvm::cl::boolOrDefault>>
enableCrossModuleInlining( enableCrossModuleInlining(
"cross-module-inlining", "cross-module-inlining", cl::ZeroOrMore, cl::Hidden,
llvm::cl::desc("Enable cross-module function inlining (default " cl::desc("(*) Enable cross-module function inlining (default disabled) "
"disabled) (LLVM >= 3.7)"), "(LLVM >= 3.7)"));
llvm::cl::ZeroOrMore, llvm::cl::Hidden);
static cl::opt<bool> unitAtATime("unit-at-a-time", cl::desc("Enable basic IPO"), static cl::opt<bool> unitAtATime("unit-at-a-time", cl::desc("Enable basic IPO"),
cl::init(true)); cl::ZeroOrMore, cl::init(true));
static cl::opt<bool> stripDebug( static cl::opt<bool> stripDebug(
"strip-debug", "strip-debug", cl::ZeroOrMore,
cl::desc("Strip symbolic debug information before optimization")); cl::desc("Strip symbolic debug information before optimization"));
cl::opt<opts::SanitizerCheck> opts::sanitize( cl::opt<opts::SanitizerCheck> opts::sanitize(
@ -113,17 +105,15 @@ cl::opt<opts::SanitizerCheck> opts::sanitize(
"Race detection"))); "Race detection")));
static cl::opt<bool> disableLoopUnrolling( static cl::opt<bool> disableLoopUnrolling(
"disable-loop-unrolling", "disable-loop-unrolling", cl::ZeroOrMore,
cl::desc("Disable loop unrolling in all relevant passes"), cl::init(false)); cl::desc("Disable loop unrolling in all relevant passes"));
static cl::opt<bool> static cl::opt<bool>
disableLoopVectorization("disable-loop-vectorization", disableLoopVectorization("disable-loop-vectorization", cl::ZeroOrMore,
cl::desc("Disable the loop vectorization pass"), cl::desc("Disable the loop vectorization pass"));
cl::init(false));
static cl::opt<bool> static cl::opt<bool>
disableSLPVectorization("disable-slp-vectorization", disableSLPVectorization("disable-slp-vectorization", cl::ZeroOrMore,
cl::desc("Disable the slp vectorization pass"), cl::desc("Disable the slp vectorization pass"));
cl::init(false));
unsigned optLevel() { unsigned optLevel() {
// Use -O2 as a base for the size-optimization levels. // Use -O2 as a base for the size-optimization levels.

View file

@ -54,7 +54,8 @@ STATISTIC(NumDeleted,
"Number of GC calls deleted because the return value was unused"); "Number of GC calls deleted because the return value was unused");
static cl::opt<unsigned> static cl::opt<unsigned>
SizeLimit("dgc2stack-size-limit", cl::init(1024), cl::Hidden, SizeLimit("dgc2stack-size-limit", cl::ZeroOrMore, cl::Hidden,
cl::init(1024),
cl::desc("Require allocs to be smaller than n bytes to be " cl::desc("Require allocs to be smaller than n bytes to be "
"promoted, 0 to ignore.")); "promoted, 0 to ignore."));

View file

@ -37,9 +37,9 @@
#if LDC_LLVM_VER >= 309 #if LDC_LLVM_VER >= 309
namespace { namespace {
llvm::cl::opt<bool, false, opts::FlagParser<bool>> enablePGOIndirectCalls( llvm::cl::opt<bool, false, opts::FlagParser<bool>> enablePGOIndirectCalls(
"pgo-indirect-calls", "pgo-indirect-calls", llvm::cl::ZeroOrMore, llvm::cl::Hidden,
llvm::cl::desc("(*) Enable PGO of indirect calls (LLVM >= 3.9)"), llvm::cl::desc("(*) Enable PGO of indirect calls (LLVM >= 3.9)"),
llvm::cl::init(true), llvm::cl::Hidden); llvm::cl::init(true));
} }
#endif #endif

View file

@ -43,10 +43,9 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static llvm::cl::opt<bool> nogc( static llvm::cl::opt<bool> nogc(
"nogc", "nogc", llvm::cl::ZeroOrMore,
llvm::cl::desc( llvm::cl::desc(
"Do not allow code that generates implicit garbage collector calls"), "Do not allow code that generates implicit garbage collector calls"));
llvm::cl::ZeroOrMore);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -56,9 +56,8 @@
#include "ctfe.h" #include "ctfe.h"
llvm::cl::opt<bool> checkPrintf( llvm::cl::opt<bool> checkPrintf(
"check-printf-calls", "check-printf-calls", llvm::cl::ZeroOrMore,
llvm::cl::desc("Validate printf call format strings against arguments"), llvm::cl::desc("Validate printf call format strings against arguments"));
llvm::cl::ZeroOrMore);
bool walkPostorder(Expression *e, StoppableVisitor *v); bool walkPostorder(Expression *e, StoppableVisitor *v);