[PATCH] D53688: [clangd] Add fallbackFlags initialization extension.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 24 20:54:48 PDT 2018
sammccall created this revision.
sammccall added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, ioeric.
This allows customizing the flags used when no compile database is
available. It addresses some uses of the old extraFlags extension.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D53688
Files:
clangd/ClangdLSPServer.cpp
clangd/Protocol.cpp
clangd/Protocol.h
Index: clangd/Protocol.h
===================================================================
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -367,6 +367,10 @@
ClangdConfigurationParamsChange ParamsChange;
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 &, ClangdInitializationOptions &);
Index: clangd/Protocol.cpp
===================================================================
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -667,7 +667,10 @@
}
json::ObjectMapper O(Params);
- return O && O.map("compilationDatabasePath", Opts.compilationDatabasePath);
+ if (!O && !O.map("compilationDatabasePath", Opts.compilationDatabasePath))
+ return false;
+ O.map("fallbackFlags", Opts.fallbackFlags);
+ return true;
}
bool fromJSON(const json::Value &Params, ReferenceParams &R) {
Index: clangd/ClangdLSPServer.cpp
===================================================================
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -303,12 +303,15 @@
if (Server)
return Reply(make_error<LSPError>("server already initialized",
ErrorCode::InvalidRequest));
- if (Params.initializationOptions)
+ std::vector<std::string> FallbackFlags;
+ if (Params.initializationOptions) {
CompileCommandsDir = Params.initializationOptions->compilationDatabasePath;
+ FallbackFlags = Params.initializationOptions->fallbackFlags;
+ }
if (UseDirBasedCDB)
BaseCDB = llvm::make_unique<DirectoryBasedGlobalCompilationDatabase>(
CompileCommandsDir);
- CDB.emplace(BaseCDB.get());
+ CDB.emplace(BaseCDB.get(), std::move(FallbackFlags));
Server.emplace(*CDB, FSProvider, static_cast<DiagnosticsConsumer &>(*this),
ClangdServerOpts);
if (Params.initializationOptions)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53688.171036.patch
Type: text/x-patch
Size: 2091 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181025/cd18c580/attachment.bin>
More information about the cfe-commits
mailing list