sammccall created this revision. sammccall added a reviewer: ilya-biryukov. Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, ioeric.
It doesn't make much sense: setting them is not coupled to opening the file, it's an asynchronous notification. I don't think this is a breaking change - this behavior is hard to observe! 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.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/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/ClangdLSPServer.cpp =================================================================== --- clangd/ClangdLSPServer.cpp +++ clangd/ClangdLSPServer.cpp @@ -354,7 +354,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; } @@ -450,7 +449,6 @@ PathRef File = Params.textDocument.uri.file(); DraftMgr.removeDraft(File); Server->removeDocument(File); - CDB->invalidate(File); } void ClangdLSPServer::onDocumentOnTypeFormatting( @@ -765,11 +763,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.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/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/ClangdLSPServer.cpp =================================================================== --- clangd/ClangdLSPServer.cpp +++ clangd/ClangdLSPServer.cpp @@ -354,7 +354,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; } @@ -450,7 +449,6 @@ PathRef File = Params.textDocument.uri.file(); DraftMgr.removeDraft(File); Server->removeDocument(File); - CDB->invalidate(File); } void ClangdLSPServer::onDocumentOnTypeFormatting( @@ -765,11 +763,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