[PATCH] D35825: [clangd] Reuse compile commands during reparse

Krasimir Georgiev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 25 02:55:00 PDT 2017


krasimir updated this revision to Diff 108033.
krasimir added a comment.

- Address review comment


https://reviews.llvm.org/D35825

Files:
  clangd/ClangdUnit.cpp
  clangd/ClangdUnitStore.h


Index: clangd/ClangdUnitStore.h
===================================================================
--- clangd/ClangdUnitStore.h
+++ 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: clangd/ClangdUnit.cpp
===================================================================
--- clangd/ClangdUnit.cpp
+++ 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;
   {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35825.108033.patch
Type: text/x-patch
Size: 1604 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170725/2a22a7d6/attachment.bin>


More information about the cfe-commits mailing list