[PATCH] D98110: [NFC][clangd] Use table to collect option aliases

Yuanfang Chen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 24 14:27:43 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG3b64ab574d98: [NFC][clangd] Use table to collect option aliases (authored by ychen).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98110/new/

https://reviews.llvm.org/D98110

Files:
  clang-tools-extra/clangd/CompileCommands.cpp


Index: clang-tools-extra/clangd/CompileCommands.cpp
===================================================================
--- clang-tools-extra/clangd/CompileCommands.cpp
+++ clang-tools-extra/clangd/CompileCommands.cpp
@@ -463,13 +463,26 @@
 #define PREFIX(NAME, VALUE) static const char *const NAME[] = VALUE;
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
                HELP, METAVAR, VALUES)                                          \
-  if (DriverID::OPT_##ALIAS != DriverID::OPT_INVALID && ALIASARGS == nullptr)  \
-    AddAlias(DriverID::OPT_##ID, DriverID::OPT_##ALIAS);                       \
   Prefixes[DriverID::OPT_##ID] = PREFIX;
 #include "clang/Driver/Options.inc"
 #undef OPTION
 #undef PREFIX
 
+    struct {
+      DriverID ID;
+      DriverID AliasID;
+      void *AliasArgs;
+    } AliasTable[] = {
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
+               HELP, METAVAR, VALUES)                                          \
+  {DriverID::OPT_##ID, DriverID::OPT_##ALIAS, (void *)ALIASARGS},
+#include "clang/Driver/Options.inc"
+#undef OPTION
+    };
+    for (auto &E : AliasTable)
+      if (E.AliasID != DriverID::OPT_INVALID && E.AliasArgs == nullptr)
+        AddAlias(E.ID, E.AliasID);
+
     auto Result = std::make_unique<TableTy>();
     // Iterate over distinct options (represented by the canonical alias).
     // Every spelling of this option will get the same set of rules.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98110.402665.patch
Type: text/x-patch
Size: 1484 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220124/2de88dcd/attachment.bin>


More information about the cfe-commits mailing list