[PATCH] D98110: [NFC][clangd] Use table to collect option aliases
Yuanfang Chen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 6 00:04:14 PST 2021
ychen created this revision.
ychen added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
ychen requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.
- Suppress a lot of `-Wtautological-compare` warning
- Speed up file build a little bit
Repository:
rG LLVM Github Monorepo
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
@@ -354,13 +354,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.328747.patch
Type: text/x-patch
Size: 1484 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210306/a37b9119/attachment.bin>
More information about the cfe-commits
mailing list