[PATCH] D90455: [clangd] Pass parameters to config apply functions
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 30 04:26:48 PDT 2020
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
kadircet requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
This will enable some fragments to apply their features selectively.
Depends on D90270 <https://reviews.llvm.org/D90270>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D90455
Files:
clang-tools-extra/clangd/ConfigCompile.cpp
Index: clang-tools-extra/clangd/ConfigCompile.cpp
===================================================================
--- clang-tools-extra/clangd/ConfigCompile.cpp
+++ clang-tools-extra/clangd/ConfigCompile.cpp
@@ -60,7 +60,8 @@
std::vector<llvm::unique_function<bool(const Params &) const>> Conditions;
// Mutations that this fragment will apply to the configuration.
// These are invoked only if the conditions are satisfied.
- std::vector<llvm::unique_function<void(Config &) const>> Apply;
+ std::vector<llvm::unique_function<void(const Params &, Config &) const>>
+ Apply;
bool operator()(const Params &P, Config &C) const {
for (const auto &C : Conditions) {
@@ -71,7 +72,7 @@
}
dlog("Config fragment {0}: applying {1} rules", this, Apply.size());
for (const auto &A : Apply)
- A(C);
+ A(P, C);
return true;
}
};
@@ -208,7 +209,7 @@
for (auto &A : F.Remove)
Remove->strip(*A);
Out.Apply.push_back([Remove(std::shared_ptr<const ArgStripper>(
- std::move(Remove)))](Config &C) {
+ std::move(Remove)))](const Params &, Config &C) {
C.CompileFlags.Edits.push_back(
[Remove](std::vector<std::string> &Args) {
Remove->process(Args);
@@ -220,7 +221,7 @@
std::vector<std::string> Add;
for (auto &A : F.Add)
Add.push_back(std::move(*A));
- Out.Apply.push_back([Add(std::move(Add))](Config &C) {
+ Out.Apply.push_back([Add(std::move(Add))](const Params &, Config &C) {
C.CompileFlags.Edits.push_back([Add](std::vector<std::string> &Args) {
Args.insert(Args.end(), Add.begin(), Add.end());
});
@@ -235,7 +236,8 @@
.map("Build", Config::BackgroundPolicy::Build)
.map("Skip", Config::BackgroundPolicy::Skip)
.value())
- Out.Apply.push_back([Val](Config &C) { C.Index.Background = *Val; });
+ Out.Apply.push_back(
+ [Val](const Params &, Config &C) { C.Index.Background = *Val; });
}
}
@@ -250,7 +252,8 @@
FullyQualifiedNamespaces.push_back(Namespace.str());
}
Out.Apply.push_back([FullyQualifiedNamespaces(
- std::move(FullyQualifiedNamespaces))](Config &C) {
+ std::move(FullyQualifiedNamespaces))](
+ const Params &, Config &C) {
C.Style.FullyQualifiedNamespaces.insert(
C.Style.FullyQualifiedNamespaces.begin(),
FullyQualifiedNamespaces.begin(), FullyQualifiedNamespaces.end());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90455.301856.patch
Type: text/x-patch
Size: 2674 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201030/a8397d05/attachment.bin>
More information about the cfe-commits
mailing list