[llvm] [Support] Accept -no-<name> to negate cl::opt<bool> (PR #224978)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 21 20:47:34 PDT 2026
MaskRay wrote:
> I'm not really convinced by this change. Maybe I'm just too used to things, but I like the current syntax, and wouldn't want it to go away.
>
> If we really want to align cl::opt with other CLI option parsing libraries, the first thing to do would probably be to stop supporting `-foo` and require `--foo` instead -- I kinda hope that's not the plan!
This PR is addition, `-x=false|0` is not taking away. Given the objection I will not remove them. However, I do hope that we make `--no-foo` canonical (linkers, nodejs, curl, v8, python argparse, ruby, perl, etc).
We have a few `cl::opt NoFoo("no-foo")`. With this change, they can become `cl::opt Foo("foo")`.
```
- no- is the majority spelling and the unanimous one among LLVM's peers: every compiler driver, linker, VCS and package manager in the list. -no-x is the right canonical form.
- =false is not a cl:: eccentricity: it's the only form in the Go and rustc worlds, and rustc's own -C foo=off idiom is what -Cllvm-args=-x=0 users are copying. The kernel/Chromium =1/=true usage comes from the same habit.
- The libraries closest to cl::'s niche — developer knobs in large C++ codebases, thousands of options, mostly hidden — are gflags, Abseil and Bazel, and all three deliberately accept both.
- The one library that rejects a value (V8) pairs the rejection with a pointed error message. If cl:: ever rejects -x=false for migrated bools, the error must say "use -no-x".
So the recommendation is unchanged and now has precedent behind it: -no-x canonical, -x=true|false|1|0 accepted as an alias implemented once (gflags/Abseil/Bazel model), no removal plan. If you prefer to keep the door open, the V8 model — reject with a message naming -no-x — is the defensible alternative, but it costs the ~8100 RUN lines and the downstream fixes for no behavior gain.
```
https://github.com/llvm/llvm-project/pull/224978
More information about the llvm-commits
mailing list