This revision was automatically updated to reflect the committed changes.
Closed by commit rL308970: [clangd] Reuse compile commands during reparse 
(authored by krasimir).

Repository:
  rL LLVM

https://reviews.llvm.org/D35825

Files:
  clang-tools-extra/trunk/clangd/ClangdUnit.cpp
  clang-tools-extra/trunk/clangd/ClangdUnitStore.h


Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp
@@ -245,6 +245,8 @@
   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 @@
   for (const auto &S : Command.CommandLine)
     ArgStrs.push_back(S.c_str());
 
+  VFS->setCurrentWorkingDirectory(Command.Directory);
+
   std::unique_ptr<CompilerInvocation> CI;
   EmptyDiagsConsumer DummyDiagsConsumer;
   {
Index: clang-tools-extra/trunk/clangd/ClangdUnitStore.h
===================================================================
--- clang-tools-extra/trunk/clangd/ClangdUnitStore.h
+++ clang-tools-extra/trunk/clangd/ClangdUnitStore.h
@@ -79,13 +79,12 @@
                      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,


Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp
@@ -245,6 +245,8 @@
   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 @@
   for (const auto &S : Command.CommandLine)
     ArgStrs.push_back(S.c_str());
 
+  VFS->setCurrentWorkingDirectory(Command.Directory);
+
   std::unique_ptr<CompilerInvocation> CI;
   EmptyDiagsConsumer DummyDiagsConsumer;
   {
Index: clang-tools-extra/trunk/clangd/ClangdUnitStore.h
===================================================================
--- clang-tools-extra/trunk/clangd/ClangdUnitStore.h
+++ clang-tools-extra/trunk/clangd/ClangdUnitStore.h
@@ -79,13 +79,12 @@
                      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,
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to