summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/TUScheduler.cpp
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
commitec9bd36f2d13d2afad0150d16e68039ec8511222 (patch)
treea5a024fac7a2d1d590f766a7198a081f3c101ed5 /clang-tools-extra/clangd/TUScheduler.cpp
parent70997f9a4e4064f5ce157c63313b6b9e09081ac3 (diff)
downloadbcm5719-llvm-ec9bd36f2d13d2afad0150d16e68039ec8511222.tar.gz
bcm5719-llvm-ec9bd36f2d13d2afad0150d16e68039ec8511222.zip
[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 llvm-svn: 338378
Diffstat (limited to 'clang-tools-extra/clangd/TUScheduler.cpp')
-rw-r--r--clang-tools-extra/clangd/TUScheduler.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/clang-tools-extra/clangd/TUScheduler.cpp b/clang-tools-extra/clangd/TUScheduler.cpp
index afc47602702..81a75bbc21a 100644
--- a/clang-tools-extra/clangd/TUScheduler.cpp
+++ b/clang-tools-extra/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;
}
OpenPOWER on IntegriCloud