[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 llvm-svn: 308970
This commit is contained in:
parent
8f2b2f51f5
commit
e4130d52da
|
@ -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;
|
||||
{
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue