sammccall added a comment.

Another consideration I haven't mentioned: clangd parses files in a few 
different modes.

- code completion: this shouldn't run plugins I believe: latency is critical 
and we don't emit any diagnostics
- main file AST build: Important to run plugins here but it's critical they 
don't traverse the whole preamble (can degrade latency by orders of magnitude).
- preamble build: this is tricky, we *rarely* emit diagnostics from this step, 
and it's very performance-sensitive. It's a separate action from the main file 
AST build so plugins won't be able to see the results of analysis. I think we 
shouldn't run plugins here.
- background indexing: again, no reason to run plugins here

This is similar to clang-tidy, which we run on the main file AST build only.
ASTContext::TraversalScope was implemented to make clang-tidy run effectively 
in clangd (provide a way to avoid traversing and deserializing the preamble).
So:

- some plugins will need changes to run efficiently, but these changes are 
probably simple. e.g. CallSuperAttrInfo.cpp needs 
`Visitor.TraverseDecl(Context.getTranslationUnitDecl());` to be replaced by 
`Visitor.TraverseAST(Context)`.
- we need to ensure the traversal scope is already set by the time plugin hooks 
that may perform traversals (e.g. ASTConsumer::handleTranslationUnit) are called


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92155/new/

https://reviews.llvm.org/D92155

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to