aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2020-06-29 21:41:57 +0200
committerSam McCall <sam.mccall@gmail.com>2020-06-29 21:41:57 +0200
commita3684dfc45c3a7bbdf72750d8a527e07e776b608 (patch)
tree38eb2e6288da1dff307aec28fc95af2aea41a4c5 /clang-tools-extra
parent8c288db2c69a2a9c75bfa629d54f80cf8953b11b (diff)
downloadllvm-a3684dfc45c3a7bbdf72750d8a527e07e776b608.zip
llvm-a3684dfc45c3a7bbdf72750d8a527e07e776b608.tar.gz
llvm-a3684dfc45c3a7bbdf72750d8a527e07e776b608.tar.bz2
Revert "[clangd] Config: config struct propagated through Context"
This reverts commit 9963d93b0731e21dd1c9c1cebf8baaecf2010330. Fails on mac/win: http://45.33.8.238/win/18704/step_9.txt http://45.33.8.238/mac/16341/step_9.txt
Diffstat (limited to 'clang-tools-extra')
-rw-r--r--clang-tools-extra/clangd/CMakeLists.txt1
-rw-r--r--clang-tools-extra/clangd/CompileCommands.cpp5
-rw-r--r--clang-tools-extra/clangd/Config.cpp25
-rw-r--r--clang-tools-extra/clangd/Config.h64
-rw-r--r--clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp22
5 files changed, 0 insertions, 117 deletions
diff --git a/clang-tools-extra/clangd/CMakeLists.txt b/clang-tools-extra/clangd/CMakeLists.txt
index 20a32d2..de3dd81 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -36,7 +36,6 @@ add_clang_library(clangDaemon
CollectMacros.cpp
CompileCommands.cpp
Compiler.cpp
- Config.cpp
ConfigYAML.cpp
Diagnostics.cpp
DraftStore.cpp
diff --git a/clang-tools-extra/clangd/CompileCommands.cpp b/clang-tools-extra/clangd/CompileCommands.cpp
index f9d5cccf..a2d704f 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "CompileCommands.h"
-#include "Config.h"
#include "support/Logger.h"
#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Tooling/ArgumentsAdjusters.h"
@@ -183,10 +182,6 @@ CommandMangler CommandMangler::forTests() {
}
void CommandMangler::adjust(std::vector<std::string> &Cmd) const {
- // FIXME: remove const_cast once unique_function is const-compatible.
- for (auto &Edit : const_cast<Config &>(config()).CompileFlags.Edits)
- Edit(Cmd);
-
// Check whether the flag exists, either as -flag or -flag=*
auto Has = [&](llvm::StringRef Flag) {
for (llvm::StringRef Arg : Cmd) {
diff --git a/clang-tools-extra/clangd/Config.cpp b/clang-tools-extra/clangd/Config.cpp
deleted file mode 100644
index 699b03e..0000000
--- a/clang-tools-extra/clangd/Config.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-//===--- Config.cpp - User configuration of clangd behavior ---------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "Config.h"
-#include "support/Context.h"
-
-namespace clang {
-namespace clangd {
-
-Key<Config> Config::Key;
-
-const Config &config() {
- if (const Config *C = Context::current().get(Config::Key))
- return *C;
- static Config Default;
- return Default;
-}
-
-} // namespace clangd
-} // namespace clang
diff --git a/clang-tools-extra/clangd/Config.h b/clang-tools-extra/clangd/Config.h
deleted file mode 100644
index c1c2cbb..0000000
--- a/clang-tools-extra/clangd/Config.h
+++ /dev/null
@@ -1,64 +0,0 @@
-//===--- Config.h - User configuration of clangd behavior --------*- C++-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Various clangd features have configurable behaviour (or can be disabled).
-// This file defines "resolved" configuration seen by features within clangd.
-// For example, settings may vary per-file, the resolved Config only contains
-// settings that apply to the current file.
-//
-// This is distinct from how the config is specified by the user (Fragment)
-// interpreted (CompiledFragment), and combined (Provider).
-// ConfigFragment.h describes the steps to add a new configuration option.
-//
-// Because this structure is shared throughout clangd, it's a potential source
-// of layering problems. Config should be expressed in terms of simple
-// vocubulary types where possible.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CONFIG_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CONFIG_H
-
-#include "support/Context.h"
-#include "llvm/ADT/FunctionExtras.h"
-#include <string>
-#include <vector>
-
-namespace clang {
-namespace clangd {
-
-/// Settings that express user/project preferences and control clangd behavior.
-///
-/// Generally, features should consume config() and the caller is responsible
-/// for setting it appropriately. In practice these callers are ClangdServer,
-/// TUScheduler, and BackgroundQueue.
-struct Config {
- /// Context key which can be used to set the current Config.
- static clangd::Key<Config> Key;
-
- Config() = default;
- Config(const Config &) = delete;
- Config &operator=(const Config &) = delete;
- Config(Config &&) = default;
- Config &operator=(Config &&) = default;
-
- /// Controls how the compile command for the current file is determined.
- struct {
- // Edits to apply to the compile command, in sequence.
- // FIXME: these functions need to be const-callable. For now, const_cast.
- std::vector<llvm::unique_function<void(std::vector<std::string> &)>> Edits;
- } CompileFlags;
-};
-
-/// Returns the Config of the current Context, or an empty configuration.
-const Config &config();
-
-} // namespace clangd
-} // namespace clang
-
-#endif
diff --git a/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp b/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
index ba656cd..d064c94 100644
--- a/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -7,9 +7,7 @@
//===----------------------------------------------------------------------===//
#include "CompileCommands.h"
-#include "Config.h"
#include "TestFS.h"
-#include "support/Context.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/StringExtras.h"
@@ -187,26 +185,6 @@ TEST(CommandMangler, ClangPathResolve) {
}
#endif
-TEST(CommandMangler, ConfigEdits) {
- auto Mangler = CommandMangler::forTests();
- std::vector<std::string> Cmd = {"clang++", "foo.cc"};
- {
- Config Cfg;
- Cfg.CompileFlags.Edits.push_back([](std::vector<std::string> &Argv) {
- for (auto &Arg : Argv)
- for (char &C : Arg)
- C = llvm::toUpper(C);
- });
- Cfg.CompileFlags.Edits.push_back(
- [](std::vector<std::string> &Argv) { Argv.push_back("--hello"); });
- WithContextValue WithConfig(Config::Key, std::move(Cfg));
- Mangler.adjust(Cmd);
- }
- // Edits are applied in given order and before other mangling.
- EXPECT_THAT(Cmd,
- ElementsAre("CLANG++", "FOO.CC", "--hello", "-fsyntax-only"));
-}
-
} // namespace
} // namespace clangd
} // namespace clang