summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang-tools-extra/clangd/ClangdUnit.cpp4
-rw-r--r--clang-tools-extra/clangd/ClangdUnitStore.h9
2 files changed, 8 insertions, 5 deletions
diff --git a/clang-tools-extra/clangd/ClangdUnit.cpp b/clang-tools-extra/clangd/ClangdUnit.cpp
index 43b5b7dd7dd..35765b7823b 100644
--- a/clang-tools-extra/clangd/ClangdUnit.cpp
+++ b/clang-tools-extra/clangd/ClangdUnit.cpp
@@ -245,6 +245,8 @@ void ClangdUnit::reparse(StringRef Contents,
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 Contents, Position Pos,
for (const auto &S : Command.CommandLine)
ArgStrs.push_back(S.c_str());
+ VFS->setCurrentWorkingDirectory(Command.Directory);
+
std::unique_ptr<CompilerInvocation> CI;
EmptyDiagsConsumer DummyDiagsConsumer;
{
diff --git a/clang-tools-extra/clangd/ClangdUnitStore.h b/clang-tools-extra/clangd/ClangdUnitStore.h
index c980ba7d51a..9dc82595f39 100644
--- a/clang-tools-extra/clangd/ClangdUnitStore.h
+++ b/clang-tools-extra/clangd/ClangdUnitStore.h
@@ -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,
OpenPOWER on IntegriCloud