[PATCH] D53688: [clangd] Add fallbackFlags initialization extension.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 2 07:11:51 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE345973: [clangd] Add fallbackFlags initialization extension. (authored by sammccall, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D53688?vs=171036&id=172351#toc
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D53688
Files:
clangd/ClangdLSPServer.cpp
clangd/Protocol.cpp
clangd/Protocol.h
Index: clangd/Protocol.cpp
===================================================================
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -669,6 +669,7 @@
fromJSON(Params, Opts.ConfigSettings);
O.map("compilationDatabasePath", Opts.compilationDatabasePath);
+ O.map("fallbackFlags", Opts.fallbackFlags);
return true;
}
Index: clangd/Protocol.h
===================================================================
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -368,6 +368,10 @@
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 &);
Index: clangd/ClangdLSPServer.cpp
===================================================================
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -308,7 +308,7 @@
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 @@
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();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53688.172351.patch
Type: text/x-patch
Size: 2000 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181102/977313bf/attachment.bin>
More information about the cfe-commits
mailing list