llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lld-wasm

Author: Fangrui Song (MaskRay)

<details>
<summary>Changes</summary>

Each tool expands OPTION into an Info array and passes it with up to
five side tables to GenericOptTable or PrecomputedOptTable, so a new
side table touches every tool.

Emit the Info table from TableGen with numeric group and alias IDs and
bundle all tables into an OptTable::Tables aggregate under one
OPTTABLE_CODE block, so a tool just constructs OptTable(OptionTables).
Every table now uses the precomputed prefix union, which removes
GenericOptTable and PrecomputedOptTable.

Aided by Opus 5

---

Patch is 98.32 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/224508.diff


55 Files Affected:

- (modified) clang/lib/Options/DriverOptions.cpp (+4-20) 
- (modified) clang/tools/clang-installapi/Options.cpp (+4-21) 
- (modified) clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp (+4-15) 
- (modified) clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp (+4-15) 
- (modified) clang/tools/clang-scan-deps/ClangScanDeps.cpp (+4-17) 
- (modified) clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp (+4-15) 
- (modified) lld/COFF/Driver.h (+1-1) 
- (modified) lld/COFF/DriverUtils.cpp (+3-16) 
- (modified) lld/ELF/Driver.h (+1-1) 
- (modified) lld/ELF/DriverUtils.cpp (+3-16) 
- (modified) lld/MachO/Driver.h (+1-1) 
- (modified) lld/MachO/DriverUtils.cpp (+3-16) 
- (modified) lld/MinGW/Driver.cpp (+4-17) 
- (modified) lld/wasm/Driver.cpp (+4-16) 
- (modified) lldb/tools/driver/Driver.cpp (+4-15) 
- (modified) lldb/tools/lldb-dap/tool/lldb-dap.cpp (+4-16) 
- (modified) lldb/tools/lldb-server/lldb-gdbserver.cpp (+4-15) 
- (modified) lldb/tools/lldb-server/lldb-platform.cpp (+4-15) 
- (modified) llvm/examples/OptSubcommand/llvm-hello-sub.cpp (+4-25) 
- (modified) llvm/include/llvm/Option/OptTable.h (+46-85) 
- (modified) llvm/include/llvm/Option/Option.h (+7-24) 
- (modified) llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.cpp (+4-21) 
- (modified) llvm/lib/Option/OptTable.cpp (+15-41) 
- (modified) llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp (+4-16) 
- (modified) llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp (+4-16) 
- (modified) llvm/tools/dsymutil/dsymutil.cpp (+4-15) 
- (modified) llvm/tools/llvm-cas/llvm-cas.cpp (+4-15) 
- (modified) llvm/tools/llvm-cgdata/llvm-cgdata.cpp (+4-15) 
- (modified) llvm/tools/llvm-cvtres/llvm-cvtres.cpp (+4-16) 
- (modified) llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp (+4-15) 
- (modified) llvm/tools/llvm-debuginfod-find/llvm-debuginfod-find.cpp (+4-15) 
- (modified) llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp (+4-15) 
- (modified) llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp (+4-15) 
- (modified) llvm/tools/llvm-dwp/llvm-dwp.cpp (+4-15) 
- (modified) llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp (+4-17) 
- (modified) llvm/tools/llvm-ifs/llvm-ifs.cpp (+4-17) 
- (modified) llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp (+4-15) 
- (modified) llvm/tools/llvm-lipo/llvm-lipo.cpp (+4-16) 
- (modified) llvm/tools/llvm-ml/llvm-ml.cpp (+4-16) 
- (modified) llvm/tools/llvm-mt/llvm-mt.cpp (+4-16) 
- (modified) llvm/tools/llvm-nm/llvm-nm.cpp (+4-17) 
- (modified) llvm/tools/llvm-objcopy/ObjcopyOptions.cpp (+20-88) 
- (modified) llvm/tools/llvm-objdump/llvm-objdump.cpp (+13-40) 
- (modified) llvm/tools/llvm-rc/llvm-rc.cpp (+8-35) 
- (modified) llvm/tools/llvm-readobj/llvm-readobj.cpp (+4-15) 
- (modified) llvm/tools/llvm-readtapi/llvm-readtapi.cpp (+4-17) 
- (modified) llvm/tools/llvm-size/llvm-size.cpp (+4-17) 
- (modified) llvm/tools/llvm-strings/llvm-strings.cpp (+4-15) 
- (modified) llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp (+4-15) 
- (modified) llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp (+4-15) 
- (modified) llvm/tools/sancov/sancov.cpp (+4-15) 
- (modified) llvm/unittests/Option/OptionParsingTest.cpp (+71-91) 
- (modified) llvm/unittests/Option/OptionSubCommandsTest.cpp (+4-24) 
- (modified) llvm/unittests/Option/Opts.td (+5) 
- (modified) llvm/utils/TableGen/OptionParserEmitter.cpp (+143-128) 


``````````diff
diff --git a/clang/lib/Options/DriverOptions.cpp 
b/clang/lib/Options/DriverOptions.cpp
index 6f630843f7019..2f73b307dbdea 100644
--- a/clang/lib/Options/DriverOptions.cpp
+++ b/clang/lib/Options/DriverOptions.cpp
@@ -13,35 +13,19 @@
 using namespace clang::options;
 using namespace llvm::opt;
 
-#define OPTTABLE_STR_TABLE_CODE
-#include "clang/Options/Options.inc"
-#undef OPTTABLE_STR_TABLE_CODE
-
 #define OPTTABLE_VALUES_CODE
 #include "clang/Options/Options.inc"
 #undef OPTTABLE_VALUES_CODE
 
-#define OPTTABLE_PREFIXES_TABLE_CODE
-#include "clang/Options/Options.inc"
-#undef OPTTABLE_PREFIXES_TABLE_CODE
-
-#define OPTTABLE_PREFIXES_UNION_CODE
+#define OPTTABLE_CODE
 #include "clang/Options/Options.inc"
-#undef OPTTABLE_PREFIXES_UNION_CODE
-
-static constexpr OptTable::Info InfoTable[] = {
-#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
-#include "clang/Options/Options.inc"
-#undef OPTION
-};
+#undef OPTTABLE_CODE
 
 namespace {
 
-class DriverOptTable : public PrecomputedOptTable {
+class DriverOptTable : public OptTable {
 public:
-  DriverOptTable()
-      : PrecomputedOptTable(OptionStrTable, OptionPrefixesTable, InfoTable,
-                            OptionPrefixesUnion) {
+  DriverOptTable() : OptTable(OptionTables) {
     setValuesCodeFn(getOptionValuesCode);
   }
 };
diff --git a/clang/tools/clang-installapi/Options.cpp 
b/clang/tools/clang-installapi/Options.cpp
index f0ad4501a4593..99b495ad7eebb 100644
--- a/clang/tools/clang-installapi/Options.cpp
+++ b/clang/tools/clang-installapi/Options.cpp
@@ -30,33 +30,16 @@ using namespace llvm::MachO;
 namespace clang {
 namespace installapi {
 
-#define OPTTABLE_STR_TABLE_CODE
+#define OPTTABLE_CODE
 #include "InstallAPIOpts.inc"
-#undef OPTTABLE_STR_TABLE_CODE
-
-#define OPTTABLE_PREFIXES_TABLE_CODE
-#include "InstallAPIOpts.inc"
-#undef OPTTABLE_PREFIXES_TABLE_CODE
-
-#define OPTTABLE_PREFIXES_UNION_CODE
-#include "InstallAPIOpts.inc"
-#undef OPTTABLE_PREFIXES_UNION_CODE
-
-/// Create table mapping all options defined in InstallAPIOpts.td.
-static constexpr OptTable::Info InfoTable[] = {
-#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
-#include "InstallAPIOpts.inc"
-#undef OPTION
-};
+#undef OPTTABLE_CODE
 
 namespace {
 
 /// \brief Create OptTable class for parsing actual command line arguments.
-class DriverOptTable : public opt::PrecomputedOptTable {
+class DriverOptTable : public opt::OptTable {
 public:
-  DriverOptTable()
-      : PrecomputedOptTable(OptionStrTable, OptionPrefixesTable, InfoTable,
-                            OptionPrefixesUnion) {}
+  DriverOptTable() : OptTable(OptionTables) {}
 };
 
 } // end anonymous namespace.
diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 59faf38dda140..366cedcebddfa 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -174,24 +174,13 @@ enum ID {
 #undef OPTION
 };
 
-#define OPTTABLE_STR_TABLE_CODE
+#define OPTTABLE_CODE
 #include "LinkerWrapperOpts.inc"
-#undef OPTTABLE_STR_TABLE_CODE
+#undef OPTTABLE_CODE
 
-#define OPTTABLE_PREFIXES_TABLE_CODE
-#include "LinkerWrapperOpts.inc"
-#undef OPTTABLE_PREFIXES_TABLE_CODE
-
-static constexpr OptTable::Info InfoTable[] = {
-#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
-#include "LinkerWrapperOpts.inc"
-#undef OPTION
-};
-
-class WrapperOptTable : public opt::GenericOptTable {
+class WrapperOptTable : public opt::OptTable {
 public:
-  WrapperOptTable()
-      : opt::GenericOptTable(OptionStrTable, OptionPrefixesTable, InfoTable) {}
+  WrapperOptTable() : opt::OptTable(OptionTables) {}
 };
 
 const OptTable &getOptTable() {
diff --git a/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp 
b/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp
index 4e06d1c149bb6..61b5eb56eaa2f 100644
--- a/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp
+++ b/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp
@@ -111,24 +111,13 @@ enum ID {
 #undef OPTION
 };
 
-#define OPTTABLE_STR_TABLE_CODE
+#define OPTTABLE_CODE
 #include "NVLinkOpts.inc"
-#undef OPTTABLE_STR_TABLE_CODE
+#undef OPTTABLE_CODE
 
-#define OPTTABLE_PREFIXES_TABLE_CODE
-#include "NVLinkOpts.inc"
-#undef OPTTABLE_PREFIXES_TABLE_CODE
-
-static constexpr OptTable::Info InfoTable[] = {
-#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
-#include "NVLinkOpts.inc"
-#undef OPTION
-};
-
-class WrapperOptTable : public opt::GenericOptTable {
+class WrapperOptTable : public opt::OptTable {
 public:
-  WrapperOptTable()
-      : opt::GenericOptTable(OptionStrTable, OptionPrefixesTable, InfoTable) {}
+  WrapperOptTable() : opt::OptTable(OptionTables) {}
 };
 
 const OptTable &getOptTable() {
diff --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp 
b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index 83b4860c130c3..ac3c329707d0a 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -54,26 +54,13 @@ enum ID {
 #undef OPTION
 };
 
-#define OPTTABLE_STR_TABLE_CODE
+#define OPTTABLE_CODE
 #include "Opts.inc"
-#undef OPTTABLE_STR_TABLE_CODE
+#undef OPTTABLE_CODE
 
-#define OPTTABLE_PREFIXES_TABLE_CODE
-#include "Opts.inc"
-#undef OPTTABLE_PREFIXES_TABLE_CODE
-
-const llvm::opt::OptTable::Info InfoTable[] = {
-#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
-#include "Opts.inc"
-#undef OPTION
-};
-
-class ScanDepsOptTable : public llvm::opt::GenericOptTable {
+class ScanDepsOptTable : public llvm::opt::OptTable {
 public:
-  ScanDepsOptTable()
-      : GenericOptTable(OptionStrTable, OptionPrefixesTable, InfoTable) {
-    setGroupedShortOptions(true);
-  }
+  ScanDepsOptTable() : OptTable(OptionTables) { setGroupedShortOptions(true); }
 };
 
 enum ResourceDirRecipeKind {
diff --git a/clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp 
b/clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp
index 70afc6d6c4cea..f8c07b6eb9edd 100644
--- a/clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp
+++ b/clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp
@@ -98,24 +98,13 @@ enum ID {
 #undef OPTION
 };
 
-#define OPTTABLE_STR_TABLE_CODE
+#define OPTTABLE_CODE
 #include "SYCLLinkOpts.inc"
-#undef OPTTABLE_STR_TABLE_CODE
+#undef OPTTABLE_CODE
 
-#define OPTTABLE_PREFIXES_TABLE_CODE
-#include "SYCLLinkOpts.inc"
-#undef OPTTABLE_PREFIXES_TABLE_CODE
-
-constexpr OptTable::Info InfoTable[] = {
-#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
-#include "SYCLLinkOpts.inc"
-#undef OPTION
-};
-
-class LinkerOptTable : public opt::GenericOptTable {
+class LinkerOptTable : public opt::OptTable {
 public:
-  LinkerOptTable()
-      : opt::GenericOptTable(OptionStrTable, OptionPrefixesTable, InfoTable) {}
+  LinkerOptTable() : opt::OptTable(OptionTables) {}
 };
 } // namespace
 
diff --git a/lld/COFF/Driver.h b/lld/COFF/Driver.h
index 7eea9aee279a1..9f4f181379d2b 100644
--- a/lld/COFF/Driver.h
+++ b/lld/COFF/Driver.h
@@ -33,7 +33,7 @@ using llvm::COFF::MachineTypes;
 using llvm::COFF::WindowsSubsystem;
 using std::optional;
 
-class COFFOptTable : public llvm::opt::GenericOptTable {
+class COFFOptTable : public llvm::opt::OptTable {
 public:
   COFFOptTable();
 };
diff --git a/lld/COFF/DriverUtils.cpp b/lld/COFF/DriverUtils.cpp
index 3b69a6d9b3d14..2fb126a68f383 100644
--- a/lld/COFF/DriverUtils.cpp
+++ b/lld/COFF/DriverUtils.cpp
@@ -748,24 +748,11 @@ MemoryBufferRef 
LinkerDriver::convertResToCOFF(ArrayRef<MemoryBufferRef> mbs,
 
 // Create OptTable
 
-#define OPTTABLE_STR_TABLE_CODE
+#define OPTTABLE_CODE
 #include "Options.inc"
-#undef OPTTABLE_STR_TABLE_CODE
+#undef OPTTABLE_CODE
 
-// Create prefix string literals used in Options.td
-#define OPTTABLE_PREFIXES_TABLE_CODE
-#include "Options.inc"
-#undef OPTTABLE_PREFIXES_TABLE_CODE
-
-// Create table mapping all options defined in Options.td
-static constexpr llvm::opt::OptTable::Info infoTable[] = {
-#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
-#include "Options.inc"
-#undef OPTION
-};
-
-COFFOptTable::COFFOptTable()
-    : GenericOptTable(OptionStrTable, OptionPrefixesTable, infoTable, true) {}
+COFFOptTable::COFFOptTable() : OptTable(OptionTables, true) {}
 
 // Set color diagnostics according to --color-diagnostics={auto,always,never}
 // or --no-color-diagnostics flags.
diff --git a/lld/ELF/Driver.h b/lld/ELF/Driver.h
index b5d41633141e2..473b5eca77c52 100644
--- a/lld/ELF/Driver.h
+++ b/lld/ELF/Driver.h
@@ -18,7 +18,7 @@ namespace lld::elf {
 struct Ctx;
 
 // Parses command line options.
-class ELFOptTable : public llvm::opt::GenericOptTable {
+class ELFOptTable : public llvm::opt::OptTable {
 public:
   ELFOptTable();
   llvm::opt::InputArgList parse(Ctx &, ArrayRef<const char *> argv);
diff --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp
index 6d027c529c19e..03e568ac46acd 100644
--- a/lld/ELF/DriverUtils.cpp
+++ b/lld/ELF/DriverUtils.cpp
@@ -33,24 +33,11 @@ using namespace lld::elf;
 
 // Create OptTable
 
-#define OPTTABLE_STR_TABLE_CODE
+#define OPTTABLE_CODE
 #include "Options.inc"
-#undef OPTTABLE_STR_TABLE_CODE
+#undef OPTTABLE_CODE
 
-// Create prefix string literals used in Options.td
-#define OPTTABLE_PREFIXES_TABLE_CODE
-#include "Options.inc"
-#undef OPTTABLE_PREFIXES_TABLE_CODE
-
-// Create table mapping all options defined in Options.td
-static constexpr opt::OptTable::Info optInfo[] = {
-#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
-#include "Options.inc"
-#undef OPTION
-};
-
-ELFOptTable::ELFOptTable()
-    : GenericOptTable(OptionStrTable, OptionPrefixesTable, optInfo) {}
+ELFOptTable::ELFOptTable() : OptTable(OptionTables) {}
 
 // Set color diagnostics according to --color-diagnostics={auto,always,never}
 // or --no-color-diagnostics flags.
diff --git a/lld/MachO/Driver.h b/lld/MachO/Driver.h
index 9374dffffd8bd..8af7afdf45a93 100644
--- a/lld/MachO/Driver.h
+++ b/lld/MachO/Driver.h
@@ -29,7 +29,7 @@ namespace lld::macho {
 class DylibFile;
 class InputFile;
 
-class MachOOptTable : public llvm::opt::GenericOptTable {
+class MachOOptTable : public llvm::opt::OptTable {
 public:
   MachOOptTable();
   llvm::opt::InputArgList parse(CommonLinkerContext &ctx,
diff --git a/lld/MachO/DriverUtils.cpp b/lld/MachO/DriverUtils.cpp
index 46ad681ffaa5d..e9b59dd71263d 100644
--- a/lld/MachO/DriverUtils.cpp
+++ b/lld/MachO/DriverUtils.cpp
@@ -32,24 +32,11 @@ using namespace llvm::sys;
 using namespace lld;
 using namespace lld::macho;
 
-#define OPTTABLE_STR_TABLE_CODE
+#define OPTTABLE_CODE
 #include "Options.inc"
-#undef OPTTABLE_STR_TABLE_CODE
+#undef OPTTABLE_CODE
 
-// Create prefix string literals used in Options.td
-#define OPTTABLE_PREFIXES_TABLE_CODE
-#include "Options.inc"
-#undef OPTTABLE_PREFIXES_TABLE_CODE
-
-// Create table mapping all options defined in Options.td
-static constexpr OptTable::Info optInfo[] = {
-#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
-#include "Options.inc"
-#undef OPTION
-};
-
-MachOOptTable::MachOOptTable()
-    : GenericOptTable(OptionStrTable, OptionPrefixesTable, optInfo) {}
+MachOOptTable::MachOOptTable() : OptTable(OptionTables) {}
 
 // Set color diagnostics according to --color-diagnostics={auto,always,never}
 // or --no-color-diagnostics flags.
diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp
index 11ccb110f7684..3f4ac149eb341 100644
--- a/lld/MinGW/Driver.cpp
+++ b/lld/MinGW/Driver.cpp
@@ -58,27 +58,14 @@ enum {
 #undef OPTION
 };
 
-#define OPTTABLE_STR_TABLE_CODE
+#define OPTTABLE_CODE
 #include "Options.inc"
-#undef OPTTABLE_STR_TABLE_CODE
-
-#define OPTTABLE_PREFIXES_TABLE_CODE
-#include "Options.inc"
-#undef OPTTABLE_PREFIXES_TABLE_CODE
-
-// Create table mapping all options defined in Options.td
-static constexpr opt::OptTable::Info infoTable[] = {
-#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
-#include "Options.inc"
-#undef OPTION
-};
+#undef OPTTABLE_CODE
 
 namespace {
-class MinGWOptTable : public opt::GenericOptTable {
+class MinGWOptTable : public opt::OptTable {
 public:
-  MinGWOptTable()
-      : opt::GenericOptTable(OptionStrTable, OptionPrefixesTable, infoTable,
-                             false) {}
+  MinGWOptTable() : opt::OptTable(OptionTables, false) {}
   opt::InputArgList parse(ArrayRef<const char *> argv);
 };
 } // namespace
diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index e6b3bcc2d438a..380df3f7824dc 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -145,26 +145,14 @@ bool link(ArrayRef<const char *> args, llvm::raw_ostream 
&stdoutOS,
   return errorCount() == 0;
 }
 
-#define OPTTABLE_STR_TABLE_CODE
+#define OPTTABLE_CODE
 #include "Options.inc"
-#undef OPTTABLE_STR_TABLE_CODE
-
-#define OPTTABLE_PREFIXES_TABLE_CODE
-#include "Options.inc"
-#undef OPTTABLE_PREFIXES_TABLE_CODE
-
-// Create table mapping all options defined in Options.td
-static constexpr opt::OptTable::Info optInfo[] = {
-#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
-#include "Options.inc"
-#undef OPTION
-};
+#undef OPTTABLE_CODE
 
 namespace {
-class WasmOptTable : public opt::GenericOptTable {
+class WasmOptTable : public opt::OptTable {
 public:
-  WasmOptTable()
-      : opt::GenericOptTable(OptionStrTable, OptionPrefixesTable, optInfo) {}
+  WasmOptTable() : opt::OptTable(OptionTables) {}
   opt::InputArgList parse(ArrayRef<const char *> argv);
 };
 } // namespace
diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index a66552e0428bf..0ffe296eb274a 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -79,24 +79,13 @@ enum ID {
 #undef OPTION
 };
 
-#define OPTTABLE_STR_TABLE_CODE
+#define OPTTABLE_CODE
 #include "Options.inc"
-#undef OPTTABLE_STR_TABLE_CODE
+#undef OPTTABLE_CODE
 
-#define OPTTABLE_PREFIXES_TABLE_CODE
-#include "Options.inc"
-#undef OPTTABLE_PREFIXES_TABLE_CODE
-
-static constexpr opt::OptTable::Info InfoTable[] = {
-#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
-#include "Options.inc"
-#undef OPTION
-};
-
-class LLDBOptTable : public opt::GenericOptTable {
+class LLDBOptTable : public opt::OptTable {
 public:
-  LLDBOptTable()
-      : opt::GenericOptTable(OptionStrTable, OptionPrefixesTable, InfoTable) {}
+  LLDBOptTable() : opt::OptTable(OptionTables) {}
 };
 } // namespace
 
diff --git a/lldb/tools/lldb-dap/tool/lldb-dap.cpp 
b/lldb/tools/lldb-dap/tool/lldb-dap.cpp
index 0882e593dc330..370a029dbb221 100644
--- a/lldb/tools/lldb-dap/tool/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/tool/lldb-dap.cpp
@@ -110,24 +110,12 @@ enum ID {
 #undef OPTION
 };
 
-#define OPTTABLE_STR_TABLE_CODE
+#define OPTTABLE_CODE
 #include "Options.inc"
-#undef OPTTABLE_STR_TABLE_CODE
-
-#define OPTTABLE_PREFIXES_TABLE_CODE
-#include "Options.inc"
-#undef OPTTABLE_PREFIXES_TABLE_CODE
-
-static constexpr llvm::opt::OptTable::Info InfoTable[] = {
-#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
-#include "Options.inc"
-#undef OPTION
-};
-class LLDBDAPOptTable : public llvm::opt::GenericOptTable {
+#undef OPTTABLE_CODE
+class LLDBDAPOptTable : public llvm::opt::OptTable {
 public:
-  LLDBDAPOptTable()
-      : llvm::opt::GenericOptTable(OptionStrTable, OptionPrefixesTable,
-                                   InfoTable, true) {}
+  LLDBDAPOptTable() : llvm::opt::OptTable(OptionTables, true) {}
 };
 } // anonymous namespace
 
diff --git a/lldb/tools/lldb-server/lldb-gdbserver.cpp 
b/lldb/tools/lldb-server/lldb-gdbserver.cpp
index 91e0379f05585..ecf8ab10045f0 100644
--- a/lldb/tools/lldb-server/lldb-gdbserver.cpp
+++ b/lldb/tools/lldb-server/lldb-gdbserver.cpp
@@ -302,24 +302,13 @@ enum ID {
 #undef OPTION
 };
 
-#define OPTTABLE_STR_TABLE_CODE
+#define OPTTABLE_CODE
 #include "LLGSOptions.inc"
-#undef OPTTABLE_STR_TABLE_CODE
+#undef OPTTABLE_CODE
 
-#define OPTTABLE_PREFIXES_TABLE_CODE
-#include "LLGSOptions.inc"
-#undef OPTTABLE_PREFIXES_TABLE_CODE
-
-static constexpr opt::OptTable::Info InfoTable[] = {
-#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
-#include "LLGSOptions.inc"
-#undef OPTION
-};
-
-class LLGSOptTable : public opt::GenericOptTable {
+class LLGSOptTable : public opt::OptTable {
 public:
-  LLGSOptTable()
-      : opt::GenericOptTable(OptionStrTable, OptionPrefixesTable, InfoTable) {}
+  LLGSOptTable() : opt::OptTable(OptionTables) {}
 
   void PrintHelp(llvm::StringRef Name) {
     std::string Usage =
diff --git a/lldb/tools/lldb-server/lldb-platform.cpp 
b/lldb/tools/lldb-server/lldb-platform.cpp
index 1b13ca65b8318..2f44c306c6f3b 100644
--- a/lldb/tools/lldb-server/lldb-platform.cpp
+++ b/lldb/tools/lldb-server/lldb-platform.cpp
@@ -68,24 +68,13 @@ enum ID {
 #undef OPTION
 };
 
-#define OPTTABLE_STR_TABLE_CODE
+#define OPTTABLE_CODE
 #include "PlatformOptions.inc"
-#undef OPTTABLE_STR_TABLE_CODE
+#undef OPTTABLE_CODE
 
-#define OPTTABLE_PREFIXES_TABLE_CODE
-#include "PlatformOptions.inc"
-#undef OPTTABLE_PREFIXES_TABLE_CODE
-
-static constexpr opt::OptTable::Info InfoTable[] = {
-#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
-#include "PlatformOptions.inc"
-#undef OPTION
-};
-
-class PlatformOptTable : public opt::GenericOptTable {
+class PlatformOptTable : public opt::OptTable {
 public:
-  PlatformOptTable()
-      : opt::GenericOptTable(OptionStrTable, OptionPrefixesTable, InfoTable) {}
+  PlatformOptTable() : opt::OptTable(OptionTables) {}
 
   void PrintHelp(llvm::StringRef Name) {
     std::string Usage =
diff --git a/llvm/examples/OptSubcommand/llvm-hello-sub.cpp 
b/llvm/examples/OptSubcommand/llvm-hello-sub.cpp
index bcf433f2179c3..1777f30ed4174 100644
--- a/llvm/examples/OptSubcommand/llvm-hello-sub.cpp
+++ b/llvm/examples/OptSubcommand/llvm-hello-sub.cpp
@@ -19,34 +19,13 @@ enum ID {
 #include "Opts.inc"
 #undef OPTION
 };
-#define OPTTABLE_STR_TABLE_CODE
+#define OPTTABLE_CODE
 #include "Opts.inc"
-#undef OPTTABLE_STR_TABLE_CODE
+#undef OPTTABLE_CODE
 
-#define OPTTABLE_PREFIXES_TABLE_CODE
-#include "Opts.inc"
-#undef OPTTABLE_PREFIXES_TABLE_CODE
-
-#define OPTTABLE_SUBCOMMAND_IDS_TABLE_CODE
-#include "Opts.inc"
-#undef OPTTABLE_SUBCOMMAND_IDS_TABLE_CODE
-
-#define OPTTABLE_SUBCOMMANDS_CODE
-#include "Opts.inc"
-#undef OPTTABLE_SUBCOMMANDS_CODE
-
-static constexpr OptTable::Info InfoTable[] = {
-#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
-#include "Opts.inc"
-#undef OPTION
-};
-
-class HelloSubOptTable : public GenericOptTable {
+class HelloSubOptTable : public OptTable {
 public:
-  HelloSubOptTable()
-      : GenericOptTable(OptionStrTable, OptionPrefixesTable, InfoTable,
-                        /*IgnoreCase=*/false, OptionSubCommands,
-                        OptionSubCommandIDsTable) {};
+  HelloSubOptTable() : OptTable(OptionTables) {};
 };
 } // namespace
 
diff --git a/llvm/include/llvm/Option/OptTable.h 
b/llvm/include/llvm/Option/OptTable.h
index ceb22c68ccb3b..1532f18b105bd 100644
--- a/llvm/include/llvm/Option/OptTable.h
+++ b/llvm/include/llvm/Option/OptTable.h
@@ -65,38 +65,38 @@ class LLVM_ABI OptTable {
   /// table supplies getOptionValuesCode() for this.
   using ValuesCodeFnTy = StringRef (*)(unsigned);
 
-  /// Entry for a single option instance in the option data table.
+  /// Help text that replaces Info::HelpTextOffset when the visibility mask
+  /// being printed intersects Visibility. An option's variants form a run
+  /// ended by a zero Visibility.
+  struct HelpTextVariant {
+    unsigned Visibility;
+    StringTable::Offset HelpTextOffset;
+  };
+
+  /// Entry for a single option instance in the option data table. An option's
+  /// ID is its 1-based position in the table.
   struct Info {
-    unsigned PrefixesOffset;
     StringTable::Offset PrefixedNameOffset;
     /// Offset 0 means the .td supplied no HelpText. A HelpText<""> maps to a
     /// distinct empty string, marking the option deliberately undocumented.
     StringTable::Offset HelpTextOffset;
-    // Help text for specific visibilities. A list of pairs, where each pair
-    // is a list of visibilities and a specific help string for those
-    // visibilities. If no help text is found in this list for the visibility 
of
-    // the program, HelpTextOffset is used instead. This cannot use std::vector
-    // because OptTable is used in constexpr contexts. Increase the array sizes
-    // here if you need more entries and adjust the constants in
-    // OptionParserEmitter::EmitHelpTextsForVariants.
-    std::array<std::pair<std::array<unsigned int, 2 /*MaxVisibilityPerHelp*/>,
-                         StringT...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/224508
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to