[lld][MachO] Silence warnings about --read-workers parsing #156608
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 seems to be), 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.