summaryrefslogtreecommitdiff
path: root/lld/MachO/Driver.cpp
diff options
context:
space:
mode:
authorFrederik Harwath <frederik.harwath@amd.com>2025-09-03 18:02:12 +0200
committerGitHub <noreply@github.com>2025-09-03 18:02:12 +0200
commite75f054d18c426b421d7d4cc58342fcb60047cfc (patch)
tree1631199fc7e6cca71474d209460506e2357f7208 /lld/MachO/Driver.cpp
parent527c8ff11e4b05e3502a46a5ad52bb7f0da5ed2a (diff)
[lld][MachO] Silence warnings about --read-workers parsing (#156608)
The parsing of the --read-workers argument v is implemented like this: unsigned threads = 0 if (!llvm::to_integer(v, threads, 0) || threads < 0) { ... As reported by a compiler warning, the value of the "threads < 0" expession is never going to be true. It could only evaluate to true if v represents a negative number, but in this case llvm::to_integer returns false since threads is unsigned and hence the second operand of the || operator will not be evaluated. This patch removes the useless || operand to silence compiler warnings. Since I had to first find out if --read-workers=0 is valid or not (it is), I also added a test to document the valid values for the option and I adjusted the error message on invalid values to clearly state that 0 is valid.
Diffstat (limited to 'lld/MachO/Driver.cpp')
-rw-r--r--lld/MachO/Driver.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index bcba759b2bbe..3db638e1ead9 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -1833,11 +1833,12 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
if (auto *arg = args.getLastArg(OPT_read_workers)) {
StringRef v(arg->getValue());
- unsigned threads = 0;
- if (!llvm::to_integer(v, threads, 0) || threads < 0)
- error(arg->getSpelling() + ": expected a positive integer, but got '" +
- arg->getValue() + "'");
- config->readWorkers = threads;
+ unsigned workers = 0;
+ if (!llvm::to_integer(v, workers, 0))
+ error(arg->getSpelling() +
+ ": expected a non-negative integer, but got '" + arg->getValue() +
+ "'");
+ config->readWorkers = workers;
}
if (auto *arg = args.getLastArg(OPT_threads_eq)) {
StringRef v(arg->getValue());