<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hey Hans, </div><div dir="ltr"><br></div><div dir="ltr">There is actually a parent for this patch at <a href="https://reviews.llvm.org/rC351531">https://reviews.llvm.org/rC351531</a> and it hasn't been merged.</div><div dir="ltr"><br></div><div>In addition to that not exactly as a follow-up, but there is <a href="https://reviews.llvm.org/rCTE351738">https://reviews.llvm.org/rCTE351738</a> which is kind of related to this two patches, you might also consider merging that but it is more of a NFC.</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 22, 2019 at 8:08 PM Hans Wennborg <<a href="mailto:hans@chromium.org">hans@chromium.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This has been merged to the 8.0 branch in r351860. Please let me know<br>
if there are any follow-ups so they can be merged too.<br>
<br>
Thanks,<br>
Hans<br>
<br>
On Tue, Jan 22, 2019 at 1:10 AM Kadir Cetinkaya via cfe-commits<br>
<<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="cremed">cfe-commits@lists.llvm.org</a>> wrote:<br>
><br>
> Author: kadircet<br>
> Date: Tue Jan 22 01:10:20 2019<br>
> New Revision: 351788<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=351788&view=rev" rel="noreferrer" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project?rev=351788&view=rev</a><br>
> Log:<br>
> [clangd] Filter out plugin related flags and move all commandline manipulations into OverlayCDB.<br>
><br>
> Summary:<br>
> Some projects make use of clang plugins when building, but clangd is<br>
> not aware of those plugins therefore can't work with the same compile command<br>
> arguments.<br>
><br>
> There were multiple places clangd performed commandline manipulations,<br>
> this one also moves them all into OverlayCDB.<br>
><br>
> Reviewers: ilya-biryukov<br>
><br>
> Subscribers: klimek, sammccall, ioeric, MaskRay, jkorous, arphaman, cfe-commits<br>
><br>
> Differential Revision: <a href="https://reviews.llvm.org/D56841" rel="noreferrer" target="_blank" class="cremed">https://reviews.llvm.org/D56841</a><br>
><br>
> Modified:<br>
> clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp<br>
> clang-tools-extra/trunk/clangd/ClangdServer.cpp<br>
> clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp<br>
> clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h<br>
> clang-tools-extra/trunk/clangd/index/Background.cpp<br>
> clang-tools-extra/trunk/clangd/index/Background.h<br>
> clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp<br>
> clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp<br>
> clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp<br>
><br>
> Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=351788&r1=351787&r2=351788&view=diff" rel="noreferrer" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=351788&r1=351787&r2=351788&view=diff</a><br>
> ==============================================================================<br>
> --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)<br>
> +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Tue Jan 22 01:10:20 2019<br>
> @@ -289,7 +289,8 @@ void ClangdLSPServer::onInitialize(const<br>
> if (UseDirBasedCDB)<br>
> BaseCDB = llvm::make_unique<DirectoryBasedGlobalCompilationDatabase>(<br>
> CompileCommandsDir);<br>
> - CDB.emplace(BaseCDB.get(), Params.initializationOptions.fallbackFlags);<br>
> + CDB.emplace(BaseCDB.get(), Params.initializationOptions.fallbackFlags,<br>
> + ClangdServerOpts.ResourceDir);<br>
> Server.emplace(*CDB, FSProvider, static_cast<DiagnosticsConsumer &>(*this),<br>
> ClangdServerOpts);<br>
> applyConfiguration(Params.initializationOptions.ConfigSettings);<br>
><br>
> Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=351788&r1=351787&r2=351788&view=diff" rel="noreferrer" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=351788&r1=351787&r2=351788&view=diff</a><br>
> ==============================================================================<br>
> --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)<br>
> +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Tue Jan 22 01:10:20 2019<br>
> @@ -37,11 +37,6 @@ namespace clang {<br>
> namespace clangd {<br>
> namespace {<br>
><br>
> -std::string getStandardResourceDir() {<br>
> - static int Dummy; // Just an address in this process.<br>
> - return CompilerInvocation::GetResourcesPath("clangd", (void *)&Dummy);<br>
> -}<br>
> -<br>
> class RefactoringResultCollector final<br>
> : public tooling::RefactoringResultConsumer {<br>
> public:<br>
> @@ -107,8 +102,6 @@ ClangdServer::ClangdServer(const GlobalC<br>
> DiagnosticsConsumer &DiagConsumer,<br>
> const Options &Opts)<br>
> : CDB(CDB), FSProvider(FSProvider),<br>
> - ResourceDir(Opts.ResourceDir ? *Opts.ResourceDir<br>
> - : getStandardResourceDir()),<br>
> DynamicIdx(Opts.BuildDynamicSymbolIndex<br>
> ? new FileIndex(Opts.HeavyweightDynamicSymbolIndex)<br>
> : nullptr),<br>
> @@ -136,7 +129,7 @@ ClangdServer::ClangdServer(const GlobalC<br>
> AddIndex(Opts.StaticIndex);<br>
> if (Opts.BackgroundIndex) {<br>
> BackgroundIdx = llvm::make_unique<BackgroundIndex>(<br>
> - Context::current().clone(), ResourceDir, FSProvider, CDB,<br>
> + Context::current().clone(), FSProvider, CDB,<br>
> BackgroundIndexStorage::createDiskBackedStorageFactory(),<br>
> Opts.BackgroundIndexRebuildPeriodMs);<br>
> AddIndex(BackgroundIdx.get());<br>
> @@ -461,10 +454,6 @@ tooling::CompileCommand ClangdServer::ge<br>
> llvm::Optional<tooling::CompileCommand> C = CDB.getCompileCommand(File);<br>
> if (!C) // FIXME: Suppress diagnostics? Let the user know?<br>
> C = CDB.getFallbackCommand(File);<br>
> -<br>
> - // Inject the resource dir.<br>
> - // FIXME: Don't overwrite it if it's already there.<br>
> - C->CommandLine.push_back("-resource-dir=" + ResourceDir);<br>
> return std::move(*C);<br>
> }<br>
><br>
><br>
> Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=351788&r1=351787&r2=351788&view=diff" rel="noreferrer" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=351788&r1=351787&r2=351788&view=diff</a><br>
> ==============================================================================<br>
> --- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp (original)<br>
> +++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Tue Jan 22 01:10:20 2019<br>
> @@ -8,12 +8,36 @@<br>
><br>
> #include "GlobalCompilationDatabase.h"<br>
> #include "Logger.h"<br>
> +#include "clang/Frontend/CompilerInvocation.h"<br>
> +#include "clang/Tooling/ArgumentsAdjusters.h"<br>
> #include "clang/Tooling/CompilationDatabase.h"<br>
> +#include "llvm/ADT/Optional.h"<br>
> #include "llvm/Support/FileSystem.h"<br>
> #include "llvm/Support/Path.h"<br>
><br>
> namespace clang {<br>
> namespace clangd {<br>
> +namespace {<br>
> +<br>
> +void adjustArguments(tooling::CompileCommand &Cmd,<br>
> + llvm::StringRef ResourceDir) {<br>
> + // Strip plugin related command line arguments. Clangd does<br>
> + // not support plugins currently. Therefore it breaks if<br>
> + // compiler tries to load plugins.<br>
> + Cmd.CommandLine =<br>
> + tooling::getStripPluginsAdjuster()(Cmd.CommandLine, Cmd.Filename);<br>
> + // Inject the resource dir.<br>
> + // FIXME: Don't overwrite it if it's already there.<br>
> + if (!ResourceDir.empty())<br>
> + Cmd.CommandLine.push_back(("-resource-dir=" + ResourceDir).str());<br>
> +}<br>
> +<br>
> +std::string getStandardResourceDir() {<br>
> + static int Dummy; // Just an address in this process.<br>
> + return CompilerInvocation::GetResourcesPath("clangd", (void *)&Dummy);<br>
> +}<br>
> +<br>
> +} // namespace<br>
><br>
> static std::string getFallbackClangPath() {<br>
> static int Dummy;<br>
> @@ -105,8 +129,11 @@ DirectoryBasedGlobalCompilationDatabase:<br>
> }<br>
><br>
> OverlayCDB::OverlayCDB(const GlobalCompilationDatabase *Base,<br>
> - std::vector<std::string> FallbackFlags)<br>
> - : Base(Base), FallbackFlags(std::move(FallbackFlags)) {<br>
> + std::vector<std::string> FallbackFlags,<br>
> + llvm::Optional<std::string> ResourceDir)<br>
> + : Base(Base), ResourceDir(ResourceDir ? std::move(*ResourceDir)<br>
> + : getStandardResourceDir()),<br>
> + FallbackFlags(std::move(FallbackFlags)) {<br>
> if (Base)<br>
> BaseChanged = Base->watch([this](const std::vector<std::string> Changes) {<br>
> OnCommandChanged.broadcast(Changes);<br>
> @@ -115,16 +142,22 @@ OverlayCDB::OverlayCDB(const GlobalCompi<br>
><br>
> llvm::Optional<tooling::CompileCommand><br>
> OverlayCDB::getCompileCommand(PathRef File, ProjectInfo *Project) const {<br>
> + llvm::Optional<tooling::CompileCommand> Cmd;<br>
> {<br>
> std::lock_guard<std::mutex> Lock(Mutex);<br>
> auto It = Commands.find(File);<br>
> if (It != Commands.end()) {<br>
> if (Project)<br>
> Project->SourceRoot = "";<br>
> - return It->second;<br>
> + Cmd = It->second;<br>
> }<br>
> }<br>
> - return Base ? Base->getCompileCommand(File, Project) : None;<br>
> + if (!Cmd && Base)<br>
> + Cmd = Base->getCompileCommand(File, Project);<br>
> + if (!Cmd)<br>
> + return llvm::None;<br>
> + adjustArguments(*Cmd, ResourceDir);<br>
> + return Cmd;<br>
> }<br>
><br>
> tooling::CompileCommand OverlayCDB::getFallbackCommand(PathRef File) const {<br>
><br>
> Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h?rev=351788&r1=351787&r2=351788&view=diff" rel="noreferrer" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h?rev=351788&r1=351787&r2=351788&view=diff</a><br>
> ==============================================================================<br>
> --- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h (original)<br>
> +++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h Tue Jan 22 01:10:20 2019<br>
> @@ -11,6 +11,7 @@<br>
><br>
> #include "Function.h"<br>
> #include "Path.h"<br>
> +#include "llvm/ADT/Optional.h"<br>
> #include "llvm/ADT/StringMap.h"<br>
> #include <memory><br>
> #include <mutex><br>
> @@ -97,7 +98,8 @@ public:<br>
> // Base may be null, in which case no entries are inherited.<br>
> // FallbackFlags are added to the fallback compile command.<br>
> OverlayCDB(const GlobalCompilationDatabase *Base,<br>
> - std::vector<std::string> FallbackFlags = {});<br>
> + std::vector<std::string> FallbackFlags = {},<br>
> + llvm::Optional<std::string> ResourceDir = llvm::None);<br>
><br>
> llvm::Optional<tooling::CompileCommand><br>
> getCompileCommand(PathRef File, ProjectInfo * = nullptr) const override;<br>
> @@ -112,6 +114,7 @@ private:<br>
> mutable std::mutex Mutex;<br>
> llvm::StringMap<tooling::CompileCommand> Commands; /* GUARDED_BY(Mut) */<br>
> const GlobalCompilationDatabase *Base;<br>
> + std::string ResourceDir;<br>
> std::vector<std::string> FallbackFlags;<br>
> CommandChanged::Subscription BaseChanged;<br>
> };<br>
><br>
> Modified: clang-tools-extra/trunk/clangd/index/Background.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Background.cpp?rev=351788&r1=351787&r2=351788&view=diff" rel="noreferrer" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Background.cpp?rev=351788&r1=351787&r2=351788&view=diff</a><br>
> ==============================================================================<br>
> --- clang-tools-extra/trunk/clangd/index/Background.cpp (original)<br>
> +++ clang-tools-extra/trunk/clangd/index/Background.cpp Tue Jan 22 01:10:20 2019<br>
> @@ -126,13 +126,12 @@ llvm::SmallString<128> getAbsolutePath(c<br>
> } // namespace<br>
><br>
> BackgroundIndex::BackgroundIndex(<br>
> - Context BackgroundContext, llvm::StringRef ResourceDir,<br>
> - const FileSystemProvider &FSProvider, const GlobalCompilationDatabase &CDB,<br>
> + Context BackgroundContext, const FileSystemProvider &FSProvider,<br>
> + const GlobalCompilationDatabase &CDB,<br>
> BackgroundIndexStorage::Factory IndexStorageFactory,<br>
> size_t BuildIndexPeriodMs, size_t ThreadPoolSize)<br>
> - : SwapIndex(llvm::make_unique<MemIndex>()), ResourceDir(ResourceDir),<br>
> - FSProvider(FSProvider), CDB(CDB),<br>
> - BackgroundContext(std::move(BackgroundContext)),<br>
> + : SwapIndex(llvm::make_unique<MemIndex>()), FSProvider(FSProvider),<br>
> + CDB(CDB), BackgroundContext(std::move(BackgroundContext)),<br>
> BuildIndexPeriodMs(BuildIndexPeriodMs),<br>
> SymbolsUpdatedSinceLastIndex(false),<br>
> IndexStorageFactory(std::move(IndexStorageFactory)),<br>
> @@ -229,7 +228,6 @@ void BackgroundIndex::enqueue(tooling::C<br>
> BackgroundIndexStorage *Storage) {<br>
> enqueueTask(Bind(<br>
> [this, Storage](tooling::CompileCommand Cmd) {<br>
> - Cmd.CommandLine.push_back("-resource-dir=" + ResourceDir);<br>
> // We can't use llvm::StringRef here since we are going to<br>
> // move from Cmd during the call below.<br>
> const std::string FileName = Cmd.Filename;<br>
><br>
> Modified: clang-tools-extra/trunk/clangd/index/Background.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Background.h?rev=351788&r1=351787&r2=351788&view=diff" rel="noreferrer" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Background.h?rev=351788&r1=351787&r2=351788&view=diff</a><br>
> ==============================================================================<br>
> --- clang-tools-extra/trunk/clangd/index/Background.h (original)<br>
> +++ clang-tools-extra/trunk/clangd/index/Background.h Tue Jan 22 01:10:20 2019<br>
> @@ -67,9 +67,7 @@ public:<br>
> /// If BuildIndexPeriodMs is greater than 0, the symbol index will only be<br>
> /// rebuilt periodically (one per \p BuildIndexPeriodMs); otherwise, index is<br>
> /// rebuilt for each indexed file.<br>
> - // FIXME: resource-dir injection should be hoisted somewhere common.<br>
> - BackgroundIndex(Context BackgroundContext, llvm::StringRef ResourceDir,<br>
> - const FileSystemProvider &,<br>
> + BackgroundIndex(Context BackgroundContext, const FileSystemProvider &,<br>
> const GlobalCompilationDatabase &CDB,<br>
> BackgroundIndexStorage::Factory IndexStorageFactory,<br>
> size_t BuildIndexPeriodMs = 0,<br>
> @@ -98,7 +96,6 @@ private:<br>
> BackgroundIndexStorage *IndexStorage);<br>
><br>
> // configuration<br>
> - std::string ResourceDir;<br>
> const FileSystemProvider &FSProvider;<br>
> const GlobalCompilationDatabase &CDB;<br>
> Context BackgroundContext;<br>
><br>
> Modified: clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp?rev=351788&r1=351787&r2=351788&view=diff" rel="noreferrer" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp?rev=351788&r1=351787&r2=351788&view=diff</a><br>
> ==============================================================================<br>
> --- clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp (original)<br>
> +++ clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp Tue Jan 22 01:10:20 2019<br>
> @@ -76,7 +76,7 @@ TEST_F(BackgroundIndexTest, NoCrashOnErr<br>
> size_t CacheHits = 0;<br>
> MemoryShardStorage MSS(Storage, CacheHits);<br>
> OverlayCDB CDB(/*Base=*/nullptr);<br>
> - BackgroundIndex Idx(Context::empty(), "", FS, CDB,<br>
> + BackgroundIndex Idx(Context::empty(), FS, CDB,<br>
> [&](llvm::StringRef) { return &MSS; });<br>
><br>
> tooling::CompileCommand Cmd;<br>
> @@ -113,7 +113,7 @@ TEST_F(BackgroundIndexTest, IndexTwoFile<br>
> size_t CacheHits = 0;<br>
> MemoryShardStorage MSS(Storage, CacheHits);<br>
> OverlayCDB CDB(/*Base=*/nullptr);<br>
> - BackgroundIndex Idx(Context::empty(), "", FS, CDB,<br>
> + BackgroundIndex Idx(Context::empty(), FS, CDB,<br>
> [&](llvm::StringRef) { return &MSS; });<br>
><br>
> tooling::CompileCommand Cmd;<br>
> @@ -168,7 +168,7 @@ TEST_F(BackgroundIndexTest, ShardStorage<br>
> // Check nothing is loaded from Storage, but A.cc and A.h has been stored.<br>
> {<br>
> OverlayCDB CDB(/*Base=*/nullptr);<br>
> - BackgroundIndex Idx(Context::empty(), "", FS, CDB,<br>
> + BackgroundIndex Idx(Context::empty(), FS, CDB,<br>
> [&](llvm::StringRef) { return &MSS; });<br>
> CDB.setCompileCommand(testPath("root/A.cc"), Cmd);<br>
> ASSERT_TRUE(Idx.blockUntilIdleForTest());<br>
> @@ -178,7 +178,7 @@ TEST_F(BackgroundIndexTest, ShardStorage<br>
><br>
> {<br>
> OverlayCDB CDB(/*Base=*/nullptr);<br>
> - BackgroundIndex Idx(Context::empty(), "", FS, CDB,<br>
> + BackgroundIndex Idx(Context::empty(), FS, CDB,<br>
> [&](llvm::StringRef) { return &MSS; });<br>
> CDB.setCompileCommand(testPath("root"), Cmd);<br>
> ASSERT_TRUE(Idx.blockUntilIdleForTest());<br>
> @@ -224,7 +224,7 @@ TEST_F(BackgroundIndexTest, DirectInclud<br>
> Cmd.CommandLine = {"clang++", testPath("root/A.cc")};<br>
> {<br>
> OverlayCDB CDB(/*Base=*/nullptr);<br>
> - BackgroundIndex Idx(Context::empty(), "", FS, CDB,<br>
> + BackgroundIndex Idx(Context::empty(), FS, CDB,<br>
> [&](llvm::StringRef) { return &MSS; });<br>
> CDB.setCompileCommand(testPath("root/A.cc"), Cmd);<br>
> ASSERT_TRUE(Idx.blockUntilIdleForTest());<br>
> @@ -262,7 +262,7 @@ TEST_F(BackgroundIndexTest, DISABLED_Per<br>
> MemoryShardStorage MSS(Storage, CacheHits);<br>
> OverlayCDB CDB(/*Base=*/nullptr);<br>
> BackgroundIndex Idx(<br>
> - Context::empty(), "", FS, CDB, [&](llvm::StringRef) { return &MSS; },<br>
> + Context::empty(), FS, CDB, [&](llvm::StringRef) { return &MSS; },<br>
> /*BuildIndexPeriodMs=*/500);<br>
><br>
> FS.Files[testPath("root/A.cc")] = "#include \"A.h\"";<br>
> @@ -310,7 +310,7 @@ TEST_F(BackgroundIndexTest, ShardStorage<br>
> // Check nothing is loaded from Storage, but A.cc and A.h has been stored.<br>
> {<br>
> OverlayCDB CDB(/*Base=*/nullptr);<br>
> - BackgroundIndex Idx(Context::empty(), "", FS, CDB,<br>
> + BackgroundIndex Idx(Context::empty(), FS, CDB,<br>
> [&](llvm::StringRef) { return &MSS; });<br>
> CDB.setCompileCommand(testPath("root/A.cc"), Cmd);<br>
> ASSERT_TRUE(Idx.blockUntilIdleForTest());<br>
> @@ -325,7 +325,7 @@ TEST_F(BackgroundIndexTest, ShardStorage<br>
> )cpp";<br>
> {<br>
> OverlayCDB CDB(/*Base=*/nullptr);<br>
> - BackgroundIndex Idx(Context::empty(), "", FS, CDB,<br>
> + BackgroundIndex Idx(Context::empty(), FS, CDB,<br>
> [&](llvm::StringRef) { return &MSS; });<br>
> CDB.setCompileCommand(testPath("root"), Cmd);<br>
> ASSERT_TRUE(Idx.blockUntilIdleForTest());<br>
> @@ -343,7 +343,7 @@ TEST_F(BackgroundIndexTest, ShardStorage<br>
> {<br>
> CacheHits = 0;<br>
> OverlayCDB CDB(/*Base=*/nullptr);<br>
> - BackgroundIndex Idx(Context::empty(), "", FS, CDB,<br>
> + BackgroundIndex Idx(Context::empty(), FS, CDB,<br>
> [&](llvm::StringRef) { return &MSS; });<br>
> CDB.setCompileCommand(testPath("root"), Cmd);<br>
> ASSERT_TRUE(Idx.blockUntilIdleForTest());<br>
> @@ -384,7 +384,7 @@ TEST_F(BackgroundIndexTest, ShardStorage<br>
> // Check that A.cc, A.h and B.h has been stored.<br>
> {<br>
> OverlayCDB CDB(/*Base=*/nullptr);<br>
> - BackgroundIndex Idx(Context::empty(), "", FS, CDB,<br>
> + BackgroundIndex Idx(Context::empty(), FS, CDB,<br>
> [&](llvm::StringRef) { return &MSS; });<br>
> CDB.setCompileCommand(testPath("root/A.cc"), Cmd);<br>
> ASSERT_TRUE(Idx.blockUntilIdleForTest());<br>
> @@ -400,7 +400,7 @@ TEST_F(BackgroundIndexTest, ShardStorage<br>
> {<br>
> CacheHits = 0;<br>
> OverlayCDB CDB(/*Base=*/nullptr);<br>
> - BackgroundIndex Idx(Context::empty(), "", FS, CDB,<br>
> + BackgroundIndex Idx(Context::empty(), FS, CDB,<br>
> [&](llvm::StringRef) { return &MSS; });<br>
> CDB.setCompileCommand(testPath("root/A.cc"), Cmd);<br>
> ASSERT_TRUE(Idx.blockUntilIdleForTest());<br>
> @@ -416,7 +416,7 @@ TEST_F(BackgroundIndexTest, ShardStorage<br>
> {<br>
> CacheHits = 0;<br>
> OverlayCDB CDB(/*Base=*/nullptr);<br>
> - BackgroundIndex Idx(Context::empty(), "", FS, CDB,<br>
> + BackgroundIndex Idx(Context::empty(), FS, CDB,<br>
> [&](llvm::StringRef) { return &MSS; });<br>
> CDB.setCompileCommand(testPath("root/A.cc"), Cmd);<br>
> ASSERT_TRUE(Idx.blockUntilIdleForTest());<br>
><br>
> Modified: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp?rev=351788&r1=351787&r2=351788&view=diff" rel="noreferrer" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp?rev=351788&r1=351787&r2=351788&view=diff</a><br>
> ==============================================================================<br>
> --- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp (original)<br>
> +++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp Tue Jan 22 01:10:20 2019<br>
> @@ -9,6 +9,7 @@<br>
> #include "Annotations.h"<br>
> #include "ClangdLSPServer.h"<br>
> #include "ClangdServer.h"<br>
> +#include "GlobalCompilationDatabase.h"<br>
> #include "Matchers.h"<br>
> #include "SyncAPI.h"<br>
> #include "TestFS.h"<br>
> @@ -1036,6 +1037,28 @@ TEST(ClangdTests, PreambleVFSStatCache)<br>
> }<br>
> #endif<br>
><br>
> +TEST_F(ClangdVFSTest, FlagsWithPlugins) {<br>
> + MockFSProvider FS;<br>
> + ErrorCheckingDiagConsumer DiagConsumer;<br>
> + MockCompilationDatabase CDB;<br>
> + CDB.ExtraClangFlags = {<br>
> + "-Xclang",<br>
> + "-add-plugin",<br>
> + "-Xclang",<br>
> + "random-plugin",<br>
> + };<br>
> + OverlayCDB OCDB(&CDB);<br>
> + ClangdServer Server(OCDB, FS, DiagConsumer, ClangdServer::optsForTest());<br>
> +<br>
> + auto FooCpp = testPath("foo.cpp");<br>
> + const auto SourceContents = "int main() { return 0; }";<br>
> + FS.Files[FooCpp] = FooCpp;<br>
> + Server.addDocument(FooCpp, SourceContents);<br>
> + auto Result = dumpASTWithoutMemoryLocs(Server, FooCpp);<br>
> + EXPECT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for diagnostics";<br>
> + EXPECT_NE(Result, "<no-ast>");<br>
> +}<br>
> +<br>
> } // namespace<br>
> } // namespace clangd<br>
> } // namespace clang<br>
><br>
> Modified: clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp?rev=351788&r1=351787&r2=351788&view=diff" rel="noreferrer" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp?rev=351788&r1=351787&r2=351788&view=diff</a><br>
> ==============================================================================<br>
> --- clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp (original)<br>
> +++ clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp Tue Jan 22 01:10:20 2019<br>
> @@ -64,7 +64,7 @@ protected:<br>
> };<br>
><br>
> TEST_F(OverlayCDBTest, GetCompileCommand) {<br>
> - OverlayCDB CDB(Base.get());<br>
> + OverlayCDB CDB(Base.get(), {}, std::string(""));<br>
> EXPECT_EQ(CDB.getCompileCommand(testPath("foo.cc")),<br>
> Base->getCompileCommand(testPath("foo.cc")));<br>
> EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), llvm::None);<br>
> @@ -84,7 +84,7 @@ TEST_F(OverlayCDBTest, GetFallbackComman<br>
> }<br>
><br>
> TEST_F(OverlayCDBTest, NoBase) {<br>
> - OverlayCDB CDB(nullptr, {"-DA=6"});<br>
> + OverlayCDB CDB(nullptr, {"-DA=6"}, std::string(""));<br>
> EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), None);<br>
> auto Override = cmd(testPath("bar.cc"), "-DA=5");<br>
> CDB.setCompileCommand(testPath("bar.cc"), Override);<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="cremed">cfe-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank" class="cremed">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div>