Change behavior when invoking LDC/LDMD without source files

Only display the appropriate usage help (and then fail) if invoked
without any explicit cmdline options. Otherwise emit an error about
missing source files and fail immediately, without displaying the usage
help.

Besides making LDC and LDMD behave identically in this regard, it makes
just more sense IMO (when forgetting to specify a file, LDC previously
just printed the cmdline help without any error message).

It also makes `ldmd2 -transition=?` and `ldmd2 -preview=help` etc. print
the expected help without LDMD special cases.
This commit is contained in:
Martin Kinkelin 2019-02-21 22:11:08 +01:00
parent 12d6193b9a
commit 6765e51799
3 changed files with 14 additions and 28 deletions

View file

@ -896,6 +896,11 @@ int cppmain(int argc, char **argv) {
Strings files;
parseCommandLine(argc, argv, files);
if (argc == 1) {
cl::PrintHelpMessage(/*Hidden=*/false, /*Categorized=*/true);
exit(EXIT_FAILURE);
}
if (global.errors) {
fatal();
}
@ -977,10 +982,6 @@ int cppmain(int argc, char **argv) {
return mars_mainBody(global.params, files, libmodules);
}
void printLDCUsage() {
cl::PrintHelpMessage(/*Hidden=*/false, /*Categorized=*/true);
}
void codegenModules(Modules &modules) {
// Generate one or more object/IR/bitcode files/dcompute kernels.
if (global.params.obj && !modules.empty()) {