summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2018-07-31 13:45:37 +0000
committerIlya Biryukov <ibiryukov@google.com>2018-07-31 13:45:37 +0000
commitd3baaef9d80dc1edecdab113a9f1b5410b4df5e5 (patch)
tree9b4a999bb8a1d72652272f17e6ef27c2b404f731
parentf9284c3bd964cd99455aee344133e5457e44b0e0 (diff)
[clangd] Do not build AST if no diagnostics were requested
Summary: It can be removed from the cache before the first access anyway, so building it can be a waste of time. Reviewers: ioeric Reviewed By: ioeric Subscribers: javed.absar, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D49991 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@338378 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--clangd/TUScheduler.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/clangd/TUScheduler.cpp b/clangd/TUScheduler.cpp
index afc47602..81a75bbc 100644
--- a/clangd/TUScheduler.cpp
+++ b/clangd/TUScheduler.cpp
@@ -391,6 +391,10 @@ void ASTWorker::update(
}
}
+ // We only need to build the AST if diagnostics were requested.
+ if (WantDiags == WantDiagnostics::No)
+ return;
+
// Get the AST for diagnostics.
llvm::Optional<std::unique_ptr<ParsedAST>> AST = IdleASTs.take(this);
if (!AST) {
@@ -398,12 +402,11 @@ void ASTWorker::update(
buildAST(FileName, std::move(Invocation), Inputs, NewPreamble, PCHs);
AST = NewAST ? llvm::make_unique<ParsedAST>(std::move(*NewAST)) : nullptr;
}
-
// We want to report the diagnostics even if this update was cancelled.
// It seems more useful than making the clients wait indefinitely if they
// spam us with updates.
// Note *AST can be still be null if buildAST fails.
- if (WantDiags != WantDiagnostics::No && *AST) {
+ if (*AST) {
OnUpdated((*AST)->getDiagnostics());
DiagsWereReported = true;
}