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)
+ for (auto &Edit : const_cast<Config &>(Config::current()).CompileFlags.Edits)
Edit(Cmd);
// Check whether the flag exists, either as -flag or -flag=*
Key<Config> Config::Key;
-const Config &config() {
- if (const Config *C = Context::current().get(Config::Key))
+const Config &Config::current() {
+ if (const Config *C = Context::current().get(Key))
return *C;
static Config Default;
return Default;
/// 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.
+/// Generally, features should consume Config::current() and the caller is
+/// responsible for setting it appropriately. In practice these callers are
+/// ClangdServer, TUScheduler, and BackgroundQueue.
struct Config {
+ /// Returns the Config of the current Context, or an empty configuration.
+ static const Config ¤t();
/// Context key which can be used to set the current Config.
static clangd::Key<Config> Key;
} CompileFlags;
};
-/// Returns the Config of the current Context, or an empty configuration.
-const Config &config();
-
} // namespace clangd
} // namespace clang