diff options
author | Fangrui Song <maskray@google.com> | 2020-07-17 09:18:24 -0700 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2020-07-17 09:32:43 -0700 |
commit | f8a29b174a965acb942dd3ef5f8ef2c32620777b (patch) | |
tree | f0eeb3cb086784fa631014c88f75d8acd162b9d8 /clang/unittests/Tooling/CompilationDatabaseTest.cpp | |
parent | 9551ae22fca65d6e3bd2586472a5f4bce8cc25ac (diff) | |
download | llvm-f8a29b174a965acb942dd3ef5f8ef2c32620777b.zip llvm-f8a29b174a965acb942dd3ef5f8ef2c32620777b.tar.gz llvm-f8a29b174a965acb942dd3ef5f8ef2c32620777b.tar.bz2 |
[OptTable] Support grouped short options
POSIX.1-2017 12.2 Utility Syntax Guidelines, Guideline 5 says:
> One or more options without option-arguments, followed by at most one option that takes an option-argument, should be accepted when grouped behind one '-' delimiter.
i.e. -abc represents -a -b -c. The grouped short options are very common. Many
utilities extend the syntax by allowing (an option with an argument) following a
sequence of short options.
This patch adds the support to OptTable, similar to cl::Group for CommandLine
(D58711). llvm-symbolizer will use the feature (D83530). CommandLine is exotic
in some aspects. OptTable is preferred if the user wants to get rid of the
behaviors.
* `cl::opt<bool> i(...)` can be disabled via -i=false or -i=0, which is
different from conventional --no-i.
* Handling --foo & --no-foo requires a comparison of argument positions,
which is a bit clumsy in user code.
OptTable::parseOneArg (non-const reference InputArgList) is added along with
ParseOneArg (const ArgList &). The duplicate does not look great at first
glance. However, The implementation can be simpler if ArgList is mutable.
(ParseOneArg is used by clang-cl (FlagsToInclude/FlagsToExclude) and lld COFF
(case-insensitive). Adding grouped short options can make the function even more
complex.)
The implementation allows a long option following a group of short options. We
probably should refine the code to disallow this in the future. Allowing this
seems benign for now.
Reviewed By: grimar, jhenderson
Differential Revision: https://reviews.llvm.org/D83639
Diffstat (limited to 'clang/unittests/Tooling/CompilationDatabaseTest.cpp')
0 files changed, 0 insertions, 0 deletions