[PATCH] D68768: Use error instead of fatal to report usage errors
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 10 02:51:01 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rG37bf9bb405ff: Use error instead of fatal to report usage errors (authored by ruiu).
Changed prior to commit:
https://reviews.llvm.org/D68768?vs=224282&id=224292#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68768/new/
https://reviews.llvm.org/D68768
Files:
lld/MinGW/Driver.cpp
lld/test/MinGW/driver.test
Index: lld/test/MinGW/driver.test
===================================================================
--- lld/test/MinGW/driver.test
+++ lld/test/MinGW/driver.test
@@ -214,3 +214,12 @@
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
Index: lld/MinGW/Driver.cpp
===================================================================
--- lld/MinGW/Driver.cpp
+++ lld/MinGW/Driver.cpp
@@ -103,9 +103,9 @@
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 @@
// 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 @@
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 @@
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 @@
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))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68768.224292.patch
Type: text/x-patch
Size: 2737 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191010/15c79bc1/attachment.bin>
More information about the llvm-commits
mailing list