[clang-tools-extra] r308970 - [clangd] Reuse compile commands during reparse
Krasimir Georgiev via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 25 04:37:44 PDT 2017
Author: krasimir
Date: Tue Jul 25 04:37:43 2017
New Revision: 308970
URL: http://llvm.org/viewvc/llvm-project?rev=308970&view=rev
Log:
[clangd] Reuse compile commands during reparse
Summary:
Previously we always queried the compilation database and discarded the results
if the file was already opened.
Reviewers: ilya-biryukov
Reviewed By: ilya-biryukov
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D35825
Modified:
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/clangd/ClangdUnitStore.h
Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=308970&r1=308969&r2=308970&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Tue Jul 25 04:37:43 2017
@@ -245,6 +245,8 @@ void ClangdUnit::reparse(StringRef Conte
for (const auto &S : Command.CommandLine)
ArgStrs.push_back(S.c_str());
+ VFS->setCurrentWorkingDirectory(Command.Directory);
+
std::unique_ptr<CompilerInvocation> CI;
{
// FIXME(ibiryukov): store diagnostics from CommandLine when we start
@@ -398,6 +400,8 @@ ClangdUnit::codeComplete(StringRef Conte
for (const auto &S : Command.CommandLine)
ArgStrs.push_back(S.c_str());
+ VFS->setCurrentWorkingDirectory(Command.Directory);
+
std::unique_ptr<CompilerInvocation> CI;
EmptyDiagsConsumer DummyDiagsConsumer;
{
Modified: clang-tools-extra/trunk/clangd/ClangdUnitStore.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnitStore.h?rev=308970&r1=308969&r2=308970&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/ClangdUnitStore.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnitStore.h Tue Jul 25 04:37:43 2017
@@ -79,13 +79,12 @@ private:
IntrusiveRefCntPtr<vfs::FileSystem> VFS, Func Action) {
std::lock_guard<std::mutex> Lock(Mutex);
- auto Commands = getCompileCommands(CDB, File);
- assert(!Commands.empty() &&
- "getCompileCommands should add default command");
- VFS->setCurrentWorkingDirectory(Commands.front().Directory);
-
auto It = OpenedFiles.find(File);
if (It == OpenedFiles.end()) {
+ auto Commands = getCompileCommands(CDB, File);
+ assert(!Commands.empty() &&
+ "getCompileCommands should add default command");
+
It = OpenedFiles
.insert(std::make_pair(File, ClangdUnit(File, FileContents,
ResourceDir, PCHs,
More information about the cfe-commits
mailing list