llvm-project/llvm/test/tools/llvm-libtool-darwin
Fangrui Song bd0bddc1ea [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
2022-03-11 11:25:04 -08:00
..
Inputs [llvm-libtool-darwin] Fix crash with bitcode asm module 2022-02-04 10:54:27 -08:00
L-and-l.test Reapply "[llvm-libtool-darwin] Print a warning if object file names are repeated" 2022-01-28 10:19:33 -08:00
archive-flattening.test Reapply "[llvm-libtool-darwin] Print a warning if object file names are repeated" 2022-01-28 10:19:33 -08:00
arm64-asm.test [llvm-libtool-darwin] Fix crash with bitcode asm module 2022-02-04 10:54:27 -08:00
cpu-subtype-matching.test
create-static-lib.test [CommandLine] Remove `may only occur zero or one times!` error 2022-03-11 11:25:04 -08:00
deterministic-library.test [CommandLine] Remove `may only occur zero or one times!` error 2022-03-11 11:25:04 -08:00
filelist.test [CommandLine] Remove `may only occur zero or one times!` error 2022-03-11 11:25:04 -08:00
help-message.test
invalid-input-output-args.test [CommandLine] Remove `may only occur zero or one times!` error 2022-03-11 11:25:04 -08:00
missing-library-type.test
no-symbols-warning.test [llvm-libtool-darwin] Add -warnings_as_errors 2022-02-07 14:39:21 -08:00
universal-bitcode-flattening.test
universal-bitcode-output.test
universal-object-flattening.test
universal-object-output.test
version.test
x86_64-asm.test [llvm-libtool-darwin] Fix crash with bitcode asm module 2022-02-04 10:54:27 -08:00