[PATCH] D49991: [clangd] Do not build AST if no diagnostics were requested

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 30 08:40:02 PDT 2018


ilya-biryukov created this revision.
ilya-biryukov added a reviewer: ioeric.
Herald added subscribers: arphaman, jkorous, MaskRay, javed.absar.

It can be washed out from the cache before first access anyway, so
building it can just be a waste of time.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49991

Files:
  clangd/TUScheduler.cpp


Index: clangd/TUScheduler.cpp
===================================================================
--- clangd/TUScheduler.cpp
+++ clangd/TUScheduler.cpp
@@ -383,6 +383,14 @@
     // Remove the old AST if it's still in cache.
     IdleASTs.take(this);
 
+    if (WantDiags == WantDiagnostics::No) {
+      // If no diagnostics were requested, building it in advance might be a
+      // waste if it will be removed from the cache before it is first accessed.
+      // So we choose to avoid building it in the first place, the rebuild will
+      // happen on first access instead.
+      return;
+    }
+
     // Build the AST for diagnostics.
     llvm::Optional<ParsedAST> AST =
         buildAST(FileName, std::move(Invocation), Inputs, NewPreamble, PCHs);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49991.157971.patch
Type: text/x-patch
Size: 759 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180730/a1719391/attachment.bin>


More information about the cfe-commits mailing list