[PATCH] D52979: [clangd] Add removeFile interface in FileIndex.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 11 08:02:48 PDT 2018


hokein added inline comments.


================
Comment at: clangd/index/FileIndex.h:78
+  /// Remove all index data associated with the file \p Path.
+  void removeFile(PathRef Path);
+
----------------
ioeric wrote:
> hokein wrote:
> > ioeric wrote:
> > > should we use this somewhere? E.g. when file is closed in ClangdServer?
> > Yes, the usage of this method is not included in this patch. 
> > 
> > We probably use this function in `TUScheduler::remove`, the code path will be like
> > 
> > `TUScheduler::remove => ParsingCallback::onASTRemove => FileIndex::removeFile`.
> > 
> > We need to add a similar interface to `ParsingCallback`.
> Or maybe in `ClangdServer::removeDocument`?
It seems that we will have problems if calling it in `ClangdServer::removeDocument`.

When removing a file, we schedule a remove task in TUScheduler, and the AST thread will wait for all pending tasks to be finished and then exit.

An example like: 

1. The AST thread has a pending request of update AST task (which will update the FileIndex) in its task queue.
2. We remove the documentation,  FileIndex will be cleanup immediately in `ClangdServer::removeDocument`, and clangd schedules a remove task.
3. The AST thread processes all pending tasks (including update AST), and exits, Now the symbol comes back again.



Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52979





More information about the cfe-commits mailing list