Use error instead of fatal to report usage errors
Differential Revision: https://reviews.llvm.org/D68768 llvm-svn: 374297
This commit is contained in:
parent
9d9ac46a08
commit
37bf9bb405
|
@ -103,9 +103,9 @@ opt::InputArgList MinGWOptTable::parse(ArrayRef<const char *> argv) {
|
|||
opt::InputArgList args = this->ParseArgs(vec, missingIndex, missingCount);
|
||||
|
||||
if (missingCount)
|
||||
fatal(StringRef(args.getArgString(missingIndex)) + ": missing argument");
|
||||
error(StringRef(args.getArgString(missingIndex)) + ": missing argument");
|
||||
for (auto *arg : args.filtered(OPT_UNKNOWN))
|
||||
fatal("unknown argument: " + arg->getAsString(args));
|
||||
error("unknown argument: " + arg->getAsString(args));
|
||||
return args;
|
||||
}
|
||||
|
||||
|
@ -160,9 +160,14 @@ searchLibrary(StringRef name, ArrayRef<StringRef> searchPaths, bool bStatic) {
|
|||
// Convert Unix-ish command line arguments to Windows-ish ones and
|
||||
// then call coff::link.
|
||||
bool mingw::link(ArrayRef<const char *> argsArr, raw_ostream &diag) {
|
||||
enableColors(diag.has_colors());
|
||||
|
||||
MinGWOptTable parser;
|
||||
opt::InputArgList args = parser.parse(argsArr.slice(1));
|
||||
|
||||
if (errorCount())
|
||||
return false;
|
||||
|
||||
if (args.hasArg(OPT_help)) {
|
||||
printHelp(argsArr[0]);
|
||||
return true;
|
||||
|
@ -183,8 +188,10 @@ bool mingw::link(ArrayRef<const char *> argsArr, raw_ostream &diag) {
|
|||
if (args.hasArg(OPT_version))
|
||||
return true;
|
||||
|
||||
if (!args.hasArg(OPT_INPUT) && !args.hasArg(OPT_l))
|
||||
fatal("no input files");
|
||||
if (!args.hasArg(OPT_INPUT) && !args.hasArg(OPT_l)) {
|
||||
error("no input files");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> linkArgs;
|
||||
auto add = [&](const Twine &s) { linkArgs.push_back(s.str()); };
|
||||
|
@ -290,7 +297,7 @@ bool mingw::link(ArrayRef<const char *> argsArr, raw_ostream &diag) {
|
|||
else if (s == "safe" || s == "none")
|
||||
add("-opt:noicf");
|
||||
else
|
||||
fatal("unknown parameter: --icf=" + s);
|
||||
error("unknown parameter: --icf=" + s);
|
||||
} else {
|
||||
add("-opt:noicf");
|
||||
}
|
||||
|
@ -306,7 +313,7 @@ bool mingw::link(ArrayRef<const char *> argsArr, raw_ostream &diag) {
|
|||
else if (s == "arm64pe")
|
||||
add("-machine:arm64");
|
||||
else
|
||||
fatal("unknown parameter: -m" + s);
|
||||
error("unknown parameter: -m" + s);
|
||||
}
|
||||
|
||||
for (auto *a : args.filtered(OPT_mllvm))
|
||||
|
|
|
@ -214,3 +214,12 @@ HELP: --enable-auto-import
|
|||
RUN: ld.lld -### -m i386pep foo.o -delayload user32.dll --delayload shell32.dll | FileCheck -check-prefix DELAYLOAD %s
|
||||
RUN: ld.lld -### -m i386pep foo.o -delayload=user32.dll --delayload=shell32.dll | FileCheck -check-prefix DELAYLOAD %s
|
||||
DELAYLOAD: -delayload:user32.dll -delayload:shell32.dll
|
||||
|
||||
RUN: not ld.lld -m i386pep -entry 2>&1 | FileCheck -check-prefix MISSING_ARG %s
|
||||
MISSING_ARG: error: -entry: missing argument
|
||||
|
||||
RUN: not ld.lld -m i386pep --foo 2>&1 | FileCheck -check-prefix UNKNOWN_ARG %s
|
||||
UNKNOWN_ARG: error: unknown argument: --foo
|
||||
|
||||
RUN: not ld.lld -m i386pep 2>&1 | FileCheck -check-prefix NO_INPUT_FILES %s
|
||||
NO_INPUT_FILES: error: no input files
|
||||
|
|
Loading…
Reference in New Issue