diff options
author | Christian Sigg <chsigg@users.noreply.github.com> | 2023-09-10 12:25:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-10 12:25:19 +0200 |
commit | 710b5a12324e54d42632985c46a3071fc2504fc9 (patch) | |
tree | 49ed1600a6bf95a88c590ecb588db7dcb0d4528e /llvm/lib/Support/CommandLine.cpp | |
parent | 18b6e2139ff8520bb33c3057ae6794a4cf6822e9 (diff) | |
download | llvm-710b5a12324e54d42632985c46a3071fc2504fc9.zip llvm-710b5a12324e54d42632985c46a3071fc2504fc9.tar.gz llvm-710b5a12324e54d42632985c46a3071fc2504fc9.tar.bz2 |
Fix logic to detect cl::option equality. (#65754)
This is a new attempt of https://reviews.llvm.org/D159481, this time as
GitHub PR.
`GenericOptionValue::compare()` should return `true` for a match.
- `OptionValueBase::compare()` always returns `false` and shouldn't
match anything.
- `OptionValueCopy::compare()` returns `false` if not `Valid` which
corresponds to no match.
Also adding some tests.
Diffstat (limited to 'llvm/lib/Support/CommandLine.cpp')
-rw-r--r-- | llvm/lib/Support/CommandLine.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index d3efb8b..55633d7 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -2181,7 +2181,7 @@ void generic_parser_base::printGenericOptionDiff( unsigned NumOpts = getNumOptions(); for (unsigned i = 0; i != NumOpts; ++i) { - if (Value.compare(getOptionValue(i))) + if (!Value.compare(getOptionValue(i))) continue; outs() << "= " << getOption(i); @@ -2189,7 +2189,7 @@ void generic_parser_base::printGenericOptionDiff( size_t NumSpaces = MaxOptWidth > L ? MaxOptWidth - L : 0; outs().indent(NumSpaces) << " (default: "; for (unsigned j = 0; j != NumOpts; ++j) { - if (Default.compare(getOptionValue(j))) + if (!Default.compare(getOptionValue(j))) continue; outs() << getOption(j); break; |