[clang-tools-extra] r345973 - [clangd] Add fallbackFlags initialization extension.
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 2 07:07:51 PDT 2018
Author: sammccall
Date: Fri Nov 2 07:07:51 2018
New Revision: 345973
URL: http://llvm.org/viewvc/llvm-project?rev=345973&view=rev
Log:
[clangd] Add fallbackFlags initialization extension.
Summary:
This allows customizing the flags used when no compile database is
available. It addresses some uses of the old extraFlags extension.
Reviewers: ilya-biryukov
Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits
Differential Revision: https://reviews.llvm.org/D53688
Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=345973&r1=345972&r2=345973&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Fri Nov 2 07:07:51 2018
@@ -308,7 +308,7 @@ void ClangdLSPServer::onInitialize(const
if (UseDirBasedCDB)
BaseCDB = llvm::make_unique<DirectoryBasedGlobalCompilationDatabase>(
CompileCommandsDir);
- CDB.emplace(BaseCDB.get());
+ CDB.emplace(BaseCDB.get(), Params.initializationOptions.fallbackFlags);
Server.emplace(*CDB, FSProvider, static_cast<DiagnosticsConsumer &>(*this),
ClangdServerOpts);
applyConfiguration(Params.initializationOptions.ConfigSettings);
@@ -664,9 +664,10 @@ void ClangdLSPServer::applyConfiguration
tooling::CompileCommand(std::move(Entry.second.workingDirectory), File,
std::move(Entry.second.compilationCommand),
/*Output=*/"");
- if (Old != New)
+ if (Old != New) {
CDB->setCompileCommand(File, std::move(New));
- ShouldReparseOpenFiles = true;
+ ShouldReparseOpenFiles = true;
+ }
}
if (ShouldReparseOpenFiles)
reparseOpenedFiles();
Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=345973&r1=345972&r2=345973&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Fri Nov 2 07:07:51 2018
@@ -669,6 +669,7 @@ bool fromJSON(const json::Value &Params,
fromJSON(Params, Opts.ConfigSettings);
O.map("compilationDatabasePath", Opts.compilationDatabasePath);
+ O.map("fallbackFlags", Opts.fallbackFlags);
return true;
}
Modified: clang-tools-extra/trunk/clangd/Protocol.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.h?rev=345973&r1=345972&r2=345973&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/Protocol.h (original)
+++ clang-tools-extra/trunk/clangd/Protocol.h Fri Nov 2 07:07:51 2018
@@ -368,6 +368,10 @@ struct InitializationOptions {
ConfigurationSettings ConfigSettings;
llvm::Optional<std::string> compilationDatabasePath;
+ // Additional flags to be included in the "fallback command" used when
+ // the compilation database doesn't describe an opened file.
+ // The command used will be approximately `clang $FILE $fallbackFlags`.
+ std::vector<std::string> fallbackFlags;
};
bool fromJSON(const llvm::json::Value &, InitializationOptions &);
More information about the cfe-commits
mailing list