diff options
author | Fangrui Song <i@maskray.me> | 2022-03-11 11:25:04 -0800 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2022-03-11 11:25:04 -0800 |
commit | bd0bddc1ea72183813d49508c8b4e73920869ea5 (patch) | |
tree | 2e8e5c65307056b4e083136963997db0efdd0482 /llvm/lib/Support/CommandLine.cpp | |
parent | 68099b1d5c2c99ff79e56a9e183f1601835ea244 (diff) | |
download | llvm-bd0bddc1ea72183813d49508c8b4e73920869ea5.zip llvm-bd0bddc1ea72183813d49508c8b4e73920869ea5.tar.gz llvm-bd0bddc1ea72183813d49508c8b4e73920869ea5.tar.bz2 |
[CommandLine] Remove `may only occur zero or one times!` error
Early adoption of new technologies or adjusting certain code generation/IR optimization thresholds
is often available through some cl::opt options (which have unstable surfaces).
Specifying such an option twice will lead to an error.
```
% clang -c a.c -mllvm -disable-binop-extract-shuffle -mllvm -disable-binop-extract-shuffle
clang (LLVM option parsing): for the --disable-binop-extract-shuffle option: may only occur zero or one times!
% clang -c a.c -mllvm -hwasan-instrument-reads=0 -mllvm -hwasan-instrument-reads=0
clang (LLVM option parsing): for the --hwasan-instrument-reads option: may only occur zero or one times!
% clang -c a.c -mllvm --scalar-evolution-max-arith-depth=32 -mllvm --scalar-evolution-max-arith-depth=16
clang (LLVM option parsing): for the --scalar-evolution-max-arith-depth option: may only occur zero or one times!
```
The option is specified twice, because there is sometimes a global setting and
a specific file or project may need to override (or duplicately specify) the
value.
The error is contrary to the common practice of getopt/getopt_long command line
utilities that let the last option win and the `getLastArg` behavior used by
Clang driver options. I have seen such errors for several times. I think the
error just makes users inconvenient, while providing very little value on
discouraging production usage of unstable surfaces (this goal is itself
controversial, because developers might not want to commit to a stable surface
too early, or there is just some subtle codegen toggle which is infeasible to
have a driver option). Therefore, I suggest we drop the diagnostic, at least
before the diagnostic gets sufficiently better support for the overridding needs.
Removing the error is a degraded error checking experience. I think this error
checking behavior, if desirable, should be enabled explicitly by tools. Users
preferring the behavior can figure out a way to do so.
Reviewed By: jhenderson, rnk
Differential Revision: https://reviews.llvm.org/D120455
Diffstat (limited to 'llvm/lib/Support/CommandLine.cpp')
-rw-r--r-- | llvm/lib/Support/CommandLine.cpp | 15 |
1 files changed, 0 insertions, 15 deletions
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index fd9022c..4c92502 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -1737,21 +1737,6 @@ bool Option::addOccurrence(unsigned pos, StringRef ArgName, StringRef Value, if (!MultiArg) NumOccurrences++; // Increment the number of times we have been seen - switch (getNumOccurrencesFlag()) { - case Optional: - if (NumOccurrences > 1) - return error("may only occur zero or one times!", ArgName); - break; - case Required: - if (NumOccurrences > 1) - return error("must occur exactly one time!", ArgName); - LLVM_FALLTHROUGH; - case OneOrMore: - case ZeroOrMore: - case ConsumeAfter: - break; - } - return handleOccurrence(pos, ArgName, Value); } |