diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2023-08-04 11:19:09 -0700 |
---|---|---|
committer | Jan Svoboda <jan_svoboda@apple.com> | 2023-08-04 13:57:13 -0700 |
commit | 3f092f37b7362447cbb13f5502dae4bdd5762afd (patch) | |
tree | 9dc8c612f223fddbb3b4e029e86ae7a2a1cbd1f0 /llvm/tools/llvm-ifs | |
parent | e6b2e1b88248c1f5b34fde4e51aaeb99f849b580 (diff) | |
download | llvm-3f092f37b7362447cbb13f5502dae4bdd5762afd.zip llvm-3f092f37b7362447cbb13f5502dae4bdd5762afd.tar.gz llvm-3f092f37b7362447cbb13f5502dae4bdd5762afd.tar.bz2 |
[llvm] Extract common `OptTable` bits into macros
All command-line tools using `llvm::opt` create an enum of option IDs and a table of `OptTable::Info` object. Most of the tools use the same ID (`OPT_##ID`), kind (`Option::KIND##Class`), group ID (`OPT_##GROUP`) and alias ID (`OPT_##ALIAS`). This patch extracts that common code into canonical macros. This results in fewer changes when tweaking the `OPTION` macros emitted by the TableGen backend.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D157028
Diffstat (limited to 'llvm/tools/llvm-ifs')
-rw-r--r-- | llvm/tools/llvm-ifs/llvm-ifs.cpp | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/llvm/tools/llvm-ifs/llvm-ifs.cpp b/llvm/tools/llvm-ifs/llvm-ifs.cpp index 0d2744f..ed660bc 100644 --- a/llvm/tools/llvm-ifs/llvm-ifs.cpp +++ b/llvm/tools/llvm-ifs/llvm-ifs.cpp @@ -54,9 +54,7 @@ enum class FileFormat { IFS, ELF, TBD }; using namespace llvm::opt; enum ID { OPT_INVALID = 0, // This is not an option ID. -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - OPT_##ID, +#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__), #include "Opts.inc" #undef OPTION }; @@ -69,13 +67,7 @@ enum ID { #undef PREFIX static constexpr opt::OptTable::Info InfoTable[] = { -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - { \ - PREFIX, NAME, HELPTEXT, \ - METAVAR, OPT_##ID, opt::Option::KIND##Class, \ - PARAM, FLAGS, OPT_##GROUP, \ - OPT_##ALIAS, ALIASARGS, VALUES}, +#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__), #include "Opts.inc" #undef OPTION }; |