diff options
author | David Spickett <david.spickett@linaro.org> | 2024-04-05 09:03:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-05 09:03:16 +0100 |
commit | 7e958f64efea6cb824e96ace51e021afbc150922 (patch) | |
tree | 108701500b751fbb414e3a45bc22421018d2f502 /lld/MinGW/Driver.cpp | |
parent | 73fa6685c43ef61f5f5babb14f734097af6dc702 (diff) | |
download | llvm-7e958f64efea6cb824e96ace51e021afbc150922.zip llvm-7e958f64efea6cb824e96ace51e021afbc150922.tar.gz llvm-7e958f64efea6cb824e96ace51e021afbc150922.tar.bz2 |
[flang][clang] Add Visibility specific help text for options (#81869)
And use it to print the correct default OpenMP version for flang and
flang -fc1.
This change adds an optional `HelpTextsForVariants` to options. This
allows you to change the help text that gets shown in documentation and
`--help` based on the program its being generated for.
As `OptTable` needs to be constexpr compatible, I have used a std::array
of help text variants. Each entry is:
(list of visibilities) - > help text string
So for the OpenMP version we have (flang, fc1) -> "OpenMP version for
flang is...".
So you can have multiple visibilities use the same string. The number of
entries is currently set to 1, and the number of visibilities per entry
is 2, because that's the maximum we need for now. The code is written so
we can increase these numbers later, and the unused elements will be initialised.
I have not applied this to group descriptions just because I don't know
of one that needs changing. It could easily be enabled for those too if
needed. There are minor changes to them just to get it all to compile.
This approach of storing many help strings per option in the 1 driver
library seemed preferable to making a whole new library for Flang (even
if that would mostly be including stuff from Clang).
Diffstat (limited to 'lld/MinGW/Driver.cpp')
-rw-r--r-- | lld/MinGW/Driver.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp index bb08c77..0d55d5b 100644 --- a/lld/MinGW/Driver.cpp +++ b/lld/MinGW/Driver.cpp @@ -69,11 +69,21 @@ enum { // Create table mapping all options defined in Options.td static constexpr opt::OptTable::Info infoTable[] = { #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, \ - VISIBILITY, PARAM, HELPTEXT, METAVAR, VALUES) \ - {PREFIX, NAME, HELPTEXT, \ - METAVAR, OPT_##ID, opt::Option::KIND##Class, \ - PARAM, FLAGS, VISIBILITY, \ - OPT_##GROUP, OPT_##ALIAS, ALIASARGS, \ + VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, \ + VALUES) \ + {PREFIX, \ + NAME, \ + HELPTEXT, \ + HELPTEXTSFORVARIANTS, \ + METAVAR, \ + OPT_##ID, \ + opt::Option::KIND##Class, \ + PARAM, \ + FLAGS, \ + VISIBILITY, \ + OPT_##GROUP, \ + OPT_##ALIAS, \ + ALIASARGS, \ VALUES}, #include "Options.inc" #undef OPTION |