summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2018-11-02 14:07:51 +0000
committerSam McCall <sam.mccall@gmail.com>2018-11-02 14:07:51 +0000
commit6980edb8fbf839724ba2356171dce387a6abb487 (patch)
treea1b3c98c5f201573a248d1494ae1a38651f1a945
parent8831ef7a16424e8584f807567c470f8f1ef46891 (diff)
downloadbcm5719-llvm-6980edb8fbf839724ba2356171dce387a6abb487.tar.gz
bcm5719-llvm-6980edb8fbf839724ba2356171dce387a6abb487.zip
[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 llvm-svn: 345973
-rw-r--r--clang-tools-extra/clangd/ClangdLSPServer.cpp7
-rw-r--r--clang-tools-extra/clangd/Protocol.cpp1
-rw-r--r--clang-tools-extra/clangd/Protocol.h4
3 files changed, 9 insertions, 3 deletions
diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 2d4a9cf5076..75a99a21b09 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -308,7 +308,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
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();
diff --git a/clang-tools-extra/clangd/Protocol.cpp b/clang-tools-extra/clangd/Protocol.cpp
index 765c3429848..d8369f3dcc1 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -669,6 +669,7 @@ bool fromJSON(const json::Value &Params, InitializationOptions &Opts) {
fromJSON(Params, Opts.ConfigSettings);
O.map("compilationDatabasePath", Opts.compilationDatabasePath);
+ O.map("fallbackFlags", Opts.fallbackFlags);
return true;
}
diff --git a/clang-tools-extra/clangd/Protocol.h b/clang-tools-extra/clangd/Protocol.h
index bfa7757b1b1..b62e57f5dda 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -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 &);
OpenPOWER on IntegriCloud