[clang-tools-extra] 3b64ab5 - [NFC][clangd] Use table to collect option aliases
Yuanfang Chen via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 24 14:27:35 PST 2022
Author: Yuanfang Chen
Date: 2022-01-24T14:27:14-08:00
New Revision: 3b64ab574d985b70cb4ec0f69c1fc1c1c4527cde
URL: https://github.com/llvm/llvm-project/commit/3b64ab574d985b70cb4ec0f69c1fc1c1c4527cde
DIFF: https://github.com/llvm/llvm-project/commit/3b64ab574d985b70cb4ec0f69c1fc1c1c4527cde.diff
LOG: [NFC][clangd] Use table to collect option aliases
* Suppress a lot of `-Wtautological-compare` warning
* Speed up file build a little bit
Reviewed By: kadircet
Differential Revision: https://reviews.llvm.org/D98110
Added:
Modified:
clang-tools-extra/clangd/CompileCommands.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/CompileCommands.cpp b/clang-tools-extra/clangd/CompileCommands.cpp
index 7d6f612cb8b96..df5f84c894e7b 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -463,13 +463,26 @@ llvm::ArrayRef<ArgStripper::Rule> ArgStripper::rulesFor(llvm::StringRef Arg) {
#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.
More information about the cfe-commits
mailing list