mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-04-29 22:50:53 +03:00
Rework LDMD command-line translation and add -verrors-spec
Simplify LDMD quite a bit by translating the few different command-line options directly in-place. This puts some more stress onto LDC's command-line parsing, especially due to multiple occurrences of a single Boolean option (e.g., '-o-') or mixtures of `-m64` and `-m32` etc. for dmd-testsuite. Also add new command-line option `-verrors-spec` showing gagged errors (DMD's equivalent is `-verrors=<spec|limit>`) and sync the usage text with DMD. LDMD now also recognizes `-h` (and `/?` on Windows).
This commit is contained in:
parent
99795b8a57
commit
84e74e3932
4 changed files with 332 additions and 719 deletions
|
@ -88,11 +88,11 @@ static cl::opt<bool, true> verbose("v", cl::desc("Verbose"), cl::ZeroOrMore,
|
|||
|
||||
static cl::opt<bool, true>
|
||||
vcolumns("vcolumns",
|
||||
cl::desc("print character (column) numbers in diagnostics"),
|
||||
cl::desc("Print character (column) numbers in diagnostics"),
|
||||
cl::ZeroOrMore, cl::location(global.params.showColumns));
|
||||
|
||||
static cl::opt<bool, true>
|
||||
vgc("vgc", cl::desc("list all gc allocations including hidden ones"),
|
||||
vgc("vgc", cl::desc("List all gc allocations including hidden ones"),
|
||||
cl::ZeroOrMore, cl::location(global.params.vgc));
|
||||
|
||||
static cl::opt<bool, true> verbose_cg("v-cg", cl::desc("Verbose codegen"),
|
||||
|
@ -100,10 +100,16 @@ static cl::opt<bool, true> verbose_cg("v-cg", cl::desc("Verbose codegen"),
|
|||
cl::location(global.params.verbose_cg));
|
||||
|
||||
static cl::opt<unsigned, true> errorLimit(
|
||||
"verrors",
|
||||
cl::desc("limit the number of error messages (0 means unlimited)"),
|
||||
"verrors", cl::ZeroOrMore,
|
||||
cl::desc("Limit the number of error messages (0 means unlimited)"),
|
||||
cl::location(global.errorLimit));
|
||||
|
||||
static cl::opt<bool, true>
|
||||
showGaggedErrors("verrors-spec", cl::ZeroOrMore,
|
||||
cl::location(global.params.showGaggedErrors),
|
||||
cl::desc("Show errors from speculative compiles such as "
|
||||
"__traits(compiles,...)"));
|
||||
|
||||
static cl::opt<ubyte, true> warnings(
|
||||
cl::desc("Warnings:"), cl::ZeroOrMore,
|
||||
clEnumValues(
|
||||
|
@ -133,27 +139,31 @@ static cl::opt<unsigned, true>
|
|||
cl::opt<bool> noAsm("noasm", cl::desc("Disallow use of inline assembler"));
|
||||
|
||||
// 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"),
|
||||
cl::ZeroOrMore);
|
||||
|
||||
cl::opt<std::string> objectFile("of", cl::value_desc("filename"), cl::Prefix,
|
||||
cl::desc("Use <filename> as output file name"));
|
||||
cl::desc("Use <filename> as output file name"),
|
||||
cl::ZeroOrMore);
|
||||
|
||||
cl::opt<std::string>
|
||||
objectDir("od", cl::value_desc("objdir"), cl::Prefix,
|
||||
cl::desc("Write object files to directory <objdir>"));
|
||||
objectDir("od", cl::value_desc("directory"), cl::Prefix, cl::ZeroOrMore,
|
||||
cl::desc("Write object files to <directory>"));
|
||||
|
||||
cl::opt<std::string>
|
||||
soname("soname", cl::value_desc("soname"), cl::Hidden, cl::Prefix,
|
||||
cl::desc("Use <soname> as output shared library soname"));
|
||||
|
||||
// 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"),
|
||||
cl::ZeroOrMore);
|
||||
|
||||
cl::opt<bool> output_ll("output-ll", cl::desc("Write LLVM IR"));
|
||||
cl::opt<bool> output_ll("output-ll", cl::desc("Write LLVM IR"), cl::ZeroOrMore);
|
||||
|
||||
cl::opt<bool> output_s("output-s", cl::desc("Write native assembly"));
|
||||
cl::opt<bool> output_s("output-s", cl::desc("Write native assembly"),
|
||||
cl::ZeroOrMore);
|
||||
|
||||
cl::opt<cl::boolOrDefault> output_o("output-o",
|
||||
cl::opt<cl::boolOrDefault> output_o("output-o", cl::ZeroOrMore,
|
||||
cl::desc("Write native object"));
|
||||
|
||||
static cl::opt<bool, true>
|
||||
|
@ -170,33 +180,36 @@ cl::opt<bool, true>
|
|||
|
||||
// DDoc options
|
||||
static cl::opt<bool, true> doDdoc("D", cl::desc("Generate documentation"),
|
||||
cl::location(global.params.doDocComments));
|
||||
cl::location(global.params.doDocComments),
|
||||
cl::ZeroOrMore);
|
||||
|
||||
cl::opt<std::string>
|
||||
ddocDir("Dd", cl::desc("Write documentation file to <docdir> directory"),
|
||||
cl::value_desc("docdir"), cl::Prefix);
|
||||
ddocDir("Dd", cl::desc("Write documentation file to <directory>"),
|
||||
cl::value_desc("directory"), cl::Prefix, cl::ZeroOrMore);
|
||||
|
||||
cl::opt<std::string>
|
||||
ddocFile("Df", cl::desc("Write documentation file to <filename>"),
|
||||
cl::value_desc("filename"), cl::Prefix);
|
||||
cl::value_desc("filename"), cl::Prefix, cl::ZeroOrMore);
|
||||
|
||||
// Json options
|
||||
static cl::opt<bool, true> doJson("X", cl::desc("Generate JSON file"),
|
||||
cl::ZeroOrMore,
|
||||
cl::location(global.params.doJsonGeneration));
|
||||
|
||||
cl::opt<std::string> jsonFile("Xf", cl::desc("Write JSON file to <filename>"),
|
||||
cl::value_desc("filename"), cl::Prefix);
|
||||
cl::value_desc("filename"), cl::Prefix,
|
||||
cl::ZeroOrMore);
|
||||
|
||||
// Header generation options
|
||||
static cl::opt<bool, true>
|
||||
doHdrGen("H", cl::desc("Generate 'header' file"),
|
||||
doHdrGen("H", cl::desc("Generate 'header' file"), cl::ZeroOrMore,
|
||||
cl::location(global.params.doHdrGeneration));
|
||||
|
||||
cl::opt<std::string>
|
||||
hdrDir("Hd", cl::desc("Write 'header' file to <hdrdir> directory"),
|
||||
cl::value_desc("hdrdir"), cl::Prefix);
|
||||
hdrDir("Hd", cl::desc("Write 'header' file to <directory>"),
|
||||
cl::value_desc("directory"), cl::Prefix, cl::ZeroOrMore);
|
||||
|
||||
cl::opt<std::string> hdrFile("Hf",
|
||||
cl::opt<std::string> hdrFile("Hf", cl::ZeroOrMore,
|
||||
cl::desc("Write 'header' file to <filename>"),
|
||||
cl::value_desc("filename"), cl::Prefix);
|
||||
|
||||
|
@ -205,7 +218,7 @@ cl::opt<bool>
|
|||
cl::desc("Keep all function bodies in .di files"),
|
||||
cl::ZeroOrMore);
|
||||
|
||||
static cl::opt<bool, true> unittest("unittest",
|
||||
static cl::opt<bool, true> unittest("unittest", cl::ZeroOrMore,
|
||||
cl::desc("Compile in unit tests"),
|
||||
cl::location(global.params.useUnitTests));
|
||||
|
||||
|
@ -215,10 +228,9 @@ cl::opt<std::string>
|
|||
cl::value_desc("cache dir"));
|
||||
|
||||
static StringsAdapter strImpPathStore("J", global.params.fileImppath);
|
||||
static cl::list<std::string, StringsAdapter>
|
||||
stringImportPaths("J", cl::desc("Where to look for string imports"),
|
||||
cl::value_desc("path"), cl::location(strImpPathStore),
|
||||
cl::Prefix);
|
||||
static cl::list<std::string, StringsAdapter> stringImportPaths(
|
||||
"J", cl::desc("Look for string imports also in <directory>"),
|
||||
cl::value_desc("directory"), cl::location(strImpPathStore), cl::Prefix);
|
||||
|
||||
static cl::opt<bool, true>
|
||||
addMain("main", cl::desc("Add default main() (e.g. for unittesting)"),
|
||||
|
@ -252,7 +264,7 @@ static D_DebugStorage dds;
|
|||
// so we need to be a bit more verbose.
|
||||
static cl::list<std::string, D_DebugStorage> debugVersionsOption(
|
||||
"d-debug",
|
||||
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::ValueOptional);
|
||||
|
||||
|
@ -264,7 +276,7 @@ cl::list<std::string> versions(
|
|||
|
||||
cl::list<std::string> transitions(
|
||||
"transition",
|
||||
cl::desc("help with language change identified by <idents>, use ? for list"),
|
||||
cl::desc("Help with language change identified by <idents>, use ? for list"),
|
||||
cl::value_desc("idents"), cl::CommaSeparated);
|
||||
|
||||
static StringsAdapter linkSwitchStore("L", global.params.linkswitches);
|
||||
|
@ -275,7 +287,9 @@ static cl::list<std::string, StringsAdapter>
|
|||
|
||||
cl::opt<std::string>
|
||||
moduleDeps("deps",
|
||||
cl::desc("Write module dependencies to filename (only imports)"),
|
||||
cl::desc("Write module dependencies to filename (only imports). "
|
||||
"'-deps' alone prints module dependencies "
|
||||
"(imports/file/version/debug/lib)"),
|
||||
cl::value_desc("filename"), cl::ValueOptional);
|
||||
|
||||
cl::opt<std::string> mArch("march",
|
||||
|
@ -345,7 +359,7 @@ cl::opt<FloatABI::Type> mFloatABI(
|
|||
"Hardware floating-point ABI and instructions")));
|
||||
|
||||
cl::opt<bool>
|
||||
disableFpElim("disable-fp-elim",
|
||||
disableFpElim("disable-fp-elim", cl::ZeroOrMore,
|
||||
cl::desc("Disable frame pointer elimination optimization"),
|
||||
cl::init(false));
|
||||
|
||||
|
@ -355,12 +369,11 @@ static cl::opt<bool, true, FlagParser<bool>>
|
|||
cl::init(true));
|
||||
|
||||
cl::opt<BOUNDSCHECK> boundsCheck(
|
||||
"boundscheck", cl::desc("Enable array bounds check"),
|
||||
clEnumValues(clEnumValN(BOUNDSCHECKoff, "off", "no array bounds checks"),
|
||||
"boundscheck", cl::desc("Array bounds check"),
|
||||
clEnumValues(clEnumValN(BOUNDSCHECKoff, "off", "Disabled"),
|
||||
clEnumValN(BOUNDSCHECKsafeonly, "safeonly",
|
||||
"array bounds checks for safe functions only"),
|
||||
clEnumValN(BOUNDSCHECKon, "on",
|
||||
"array bounds checks for all functions")),
|
||||
"Enabled for @safe functions only"),
|
||||
clEnumValN(BOUNDSCHECKon, "on", "Enabled for all functions")),
|
||||
cl::init(BOUNDSCHECKdefault));
|
||||
|
||||
static cl::opt<bool, true, FlagParser<bool>>
|
||||
|
@ -401,7 +414,7 @@ cl::opt<bool, true>
|
|||
|
||||
cl::opt<uint32_t, true> hashThreshold(
|
||||
"hash-threshold",
|
||||
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(
|
||||
|
@ -428,24 +441,23 @@ void setDefaultMathOptions(llvm::TargetMachine &target) {
|
|||
}
|
||||
|
||||
cl::opt<bool, true>
|
||||
allinst("allinst",
|
||||
cl::desc("generate code for all template instantiations"),
|
||||
allinst("allinst", cl::ZeroOrMore,
|
||||
cl::desc("Generate code for all template instantiations"),
|
||||
cl::location(global.params.allInst));
|
||||
|
||||
cl::opt<unsigned, true> nestedTemplateDepth(
|
||||
"template-depth",
|
||||
"template-depth", cl::location(global.params.nestedTmpl), cl::init(500),
|
||||
cl::desc(
|
||||
"(experimental) set maximum number of nested template instantiations"),
|
||||
cl::location(global.params.nestedTmpl), cl::init(500));
|
||||
"Set maximum number of nested template instantiations (experimental)"));
|
||||
|
||||
cl::opt<bool, true>
|
||||
useDIP25("dip25",
|
||||
cl::desc("implement http://wiki.dlang.org/DIP25 (experimental)"),
|
||||
useDIP25("dip25", cl::ZeroOrMore,
|
||||
cl::desc("Implement http://wiki.dlang.org/DIP25 (experimental)"),
|
||||
cl::location(global.params.useDIP25));
|
||||
|
||||
cl::opt<bool, true> betterC(
|
||||
"betterC",
|
||||
cl::desc("omit generating some runtime information and helper functions"),
|
||||
"betterC", cl::ZeroOrMore,
|
||||
cl::desc("Omit generating some runtime information and helper functions"),
|
||||
cl::location(global.params.betterC));
|
||||
|
||||
cl::opt<unsigned char, true, CoverageParser> coverageAnalysis(
|
||||
|
@ -486,7 +498,7 @@ static cl::extrahelp footer(
|
|||
"\n"
|
||||
"-d-debug can also be specified without options, in which case it enables "
|
||||
"all\n"
|
||||
"debug checks (i.e. (asserts, boundchecks, contracts and invariants) as "
|
||||
"debug checks (i.e. (asserts, boundschecks, contracts and invariants) as "
|
||||
"well\n"
|
||||
"as acting as -d-debug=1\n\n"
|
||||
"Options marked with (*) also have a -disable-FOO variant with inverted\n"
|
||||
|
|
822
driver/ldmd.cpp
822
driver/ldmd.cpp
File diff suppressed because it is too large
Load diff
|
@ -87,8 +87,8 @@ static cl::opt<bool>
|
|||
|
||||
static StringsAdapter impPathsStore("I", global.params.imppath);
|
||||
static cl::list<std::string, StringsAdapter>
|
||||
importPaths("I", cl::desc("Where to look for imports"),
|
||||
cl::value_desc("path"), cl::location(impPathsStore),
|
||||
importPaths("I", cl::desc("Look for imports also in <directory>"),
|
||||
cl::value_desc("directory"), cl::location(impPathsStore),
|
||||
cl::Prefix);
|
||||
|
||||
static cl::opt<std::string>
|
||||
|
@ -959,21 +959,16 @@ int cppmain(int argc, char **argv) {
|
|||
}
|
||||
|
||||
// Set up the TargetMachine.
|
||||
ExplicitBitness::Type bitness = ExplicitBitness::None;
|
||||
if ((m32bits || m64bits) && (!mArch.empty() || !mTargetTriple.empty())) {
|
||||
error(Loc(), "-m32 and -m64 switches cannot be used together with -march "
|
||||
"and -mtriple switches");
|
||||
}
|
||||
|
||||
if (m32bits) {
|
||||
ExplicitBitness::Type bitness = ExplicitBitness::None;
|
||||
if (m32bits)
|
||||
bitness = ExplicitBitness::M32;
|
||||
}
|
||||
if (m64bits) {
|
||||
if (bitness != ExplicitBitness::None) {
|
||||
error(Loc(), "cannot use both -m32 and -m64 options");
|
||||
}
|
||||
if (m64bits && (!m32bits || m32bits.getPosition() < m64bits.getPosition()))
|
||||
bitness = ExplicitBitness::M64;
|
||||
}
|
||||
|
||||
if (global.errors) {
|
||||
fatal();
|
||||
|
|
|
@ -107,10 +107,10 @@ static cl::opt<bool> stripDebug(
|
|||
cl::opt<opts::SanitizerCheck> opts::sanitize(
|
||||
"sanitize", cl::desc("Enable runtime instrumentation for bug detection"),
|
||||
cl::init(opts::None),
|
||||
clEnumValues(clEnumValN(opts::AddressSanitizer, "address", "memory errors"),
|
||||
clEnumValN(opts::MemorySanitizer, "memory", "memory errors"),
|
||||
clEnumValues(clEnumValN(opts::AddressSanitizer, "address", "Memory errors"),
|
||||
clEnumValN(opts::MemorySanitizer, "memory", "Memory errors"),
|
||||
clEnumValN(opts::ThreadSanitizer, "thread",
|
||||
"race detection")));
|
||||
"Race detection")));
|
||||
|
||||
static cl::opt<bool> disableLoopUnrolling(
|
||||
"disable-loop-unrolling",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue