This revision was automatically updated to reflect the committed changes. Closed by commit rCTE345231: [clangd] Don't invalidate LSP-set compile commands when closing a file. (authored by sammccall, committed by ).
Changed prior to commit: https://reviews.llvm.org/D53642?vs=170861&id=171033#toc Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53642 Files: clangd/ClangdLSPServer.cpp clangd/ClangdLSPServer.h clangd/GlobalCompilationDatabase.cpp clangd/GlobalCompilationDatabase.h Index: clangd/GlobalCompilationDatabase.cpp =================================================================== --- clangd/GlobalCompilationDatabase.cpp +++ clangd/GlobalCompilationDatabase.cpp @@ -135,10 +135,5 @@ return false; } -void InMemoryCompilationDb::invalidate(PathRef File) { - std::unique_lock<std::mutex> Lock(Mutex); - Commands.erase(File); -} - } // namespace clangd } // namespace clang Index: clangd/ClangdLSPServer.h =================================================================== --- clangd/ClangdLSPServer.h +++ clangd/ClangdLSPServer.h @@ -113,8 +113,6 @@ static CompilationDB makeDirectoryBased(llvm::Optional<Path> CompileCommandsDir); - void invalidate(PathRef File); - /// Sets the compilation command for a particular file. /// Only valid for in-memory CDB, no-op and error log on DirectoryBasedCDB. /// Index: clangd/GlobalCompilationDatabase.h =================================================================== --- clangd/GlobalCompilationDatabase.h +++ clangd/GlobalCompilationDatabase.h @@ -100,10 +100,6 @@ bool setCompilationCommandForFile(PathRef File, tooling::CompileCommand CompilationCommand); - /// Removes the compilation command for \p File if it's present in the - /// mapping. - void invalidate(PathRef File); - private: mutable std::mutex Mutex; llvm::StringMap<tooling::CompileCommand> Commands; /* GUARDED_BY(Mut) */ Index: clangd/ClangdLSPServer.cpp =================================================================== --- clangd/ClangdLSPServer.cpp +++ clangd/ClangdLSPServer.cpp @@ -393,7 +393,6 @@ // fail rather than giving wrong results. DraftMgr.removeDraft(File); Server->removeDocument(File); - CDB->invalidate(File); elog("Failed to update {0}: {1}", File, Contents.takeError()); return; } @@ -489,7 +488,6 @@ PathRef File = Params.textDocument.uri.file(); DraftMgr.removeDraft(File); Server->removeDocument(File); - CDB->invalidate(File); } void ClangdLSPServer::onDocumentOnTypeFormatting( @@ -804,11 +802,6 @@ /*IsDirectoryBased=*/true); } -void ClangdLSPServer::CompilationDB::invalidate(PathRef File) { - if (!IsDirectoryBased) - static_cast<InMemoryCompilationDb *>(CDB.get())->invalidate(File); -} - bool ClangdLSPServer::CompilationDB::setCompilationCommandForFile( PathRef File, tooling::CompileCommand CompilationCommand) { if (IsDirectoryBased) {
Index: clangd/GlobalCompilationDatabase.cpp =================================================================== --- clangd/GlobalCompilationDatabase.cpp +++ clangd/GlobalCompilationDatabase.cpp @@ -135,10 +135,5 @@ return false; } -void InMemoryCompilationDb::invalidate(PathRef File) { - std::unique_lock<std::mutex> Lock(Mutex); - Commands.erase(File); -} - } // namespace clangd } // namespace clang Index: clangd/ClangdLSPServer.h =================================================================== --- clangd/ClangdLSPServer.h +++ clangd/ClangdLSPServer.h @@ -113,8 +113,6 @@ static CompilationDB makeDirectoryBased(llvm::Optional<Path> CompileCommandsDir); - void invalidate(PathRef File); - /// Sets the compilation command for a particular file. /// Only valid for in-memory CDB, no-op and error log on DirectoryBasedCDB. /// Index: clangd/GlobalCompilationDatabase.h =================================================================== --- clangd/GlobalCompilationDatabase.h +++ clangd/GlobalCompilationDatabase.h @@ -100,10 +100,6 @@ bool setCompilationCommandForFile(PathRef File, tooling::CompileCommand CompilationCommand); - /// Removes the compilation command for \p File if it's present in the - /// mapping. - void invalidate(PathRef File); - private: mutable std::mutex Mutex; llvm::StringMap<tooling::CompileCommand> Commands; /* GUARDED_BY(Mut) */ Index: clangd/ClangdLSPServer.cpp =================================================================== --- clangd/ClangdLSPServer.cpp +++ clangd/ClangdLSPServer.cpp @@ -393,7 +393,6 @@ // fail rather than giving wrong results. DraftMgr.removeDraft(File); Server->removeDocument(File); - CDB->invalidate(File); elog("Failed to update {0}: {1}", File, Contents.takeError()); return; } @@ -489,7 +488,6 @@ PathRef File = Params.textDocument.uri.file(); DraftMgr.removeDraft(File); Server->removeDocument(File); - CDB->invalidate(File); } void ClangdLSPServer::onDocumentOnTypeFormatting( @@ -804,11 +802,6 @@ /*IsDirectoryBased=*/true); } -void ClangdLSPServer::CompilationDB::invalidate(PathRef File) { - if (!IsDirectoryBased) - static_cast<InMemoryCompilationDb *>(CDB.get())->invalidate(File); -} - bool ClangdLSPServer::CompilationDB::setCompilationCommandForFile( PathRef File, tooling::CompileCommand CompilationCommand) { if (IsDirectoryBased) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits