summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/TUScheduler.cpp
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2018-11-22 17:27:08 +0000
committerIlya Biryukov <ibiryukov@google.com>2018-11-22 17:27:08 +0000
commit16cc195e8d8f1dc5dcd2438a6282c143f1725fe9 (patch)
treed49f8bf9012e3f8ed45775cb814a2f9e28b579b5 /clang-tools-extra/clangd/TUScheduler.cpp
parent5b2605edc459e93afdc02170bc910ff6c2b71631 (diff)
downloadbcm5719-llvm-16cc195e8d8f1dc5dcd2438a6282c143f1725fe9.tar.gz
bcm5719-llvm-16cc195e8d8f1dc5dcd2438a6282c143f1725fe9.zip
[clangd] Cleanup: make the diags callback global in TUScheduler
Reviewers: sammccall Reviewed By: sammccall Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54760 llvm-svn: 347474
Diffstat (limited to 'clang-tools-extra/clangd/TUScheduler.cpp')
-rw-r--r--clang-tools-extra/clangd/TUScheduler.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/clang-tools-extra/clangd/TUScheduler.cpp b/clang-tools-extra/clangd/TUScheduler.cpp
index 8bd3b8b41da..c33e3a51b0d 100644
--- a/clang-tools-extra/clangd/TUScheduler.cpp
+++ b/clang-tools-extra/clangd/TUScheduler.cpp
@@ -176,8 +176,7 @@ public:
ParsingCallbacks &Callbacks);
~ASTWorker();
- void update(ParseInputs Inputs, WantDiagnostics,
- llvm::unique_function<void(std::vector<Diag>)> OnUpdated);
+ void update(ParseInputs Inputs, WantDiagnostics);
void runWithAST(StringRef Name,
unique_function<void(Expected<InputsAndAST>)> Action);
bool blockUntilIdle(Deadline Timeout) const;
@@ -231,7 +230,7 @@ private:
const Path FileName;
/// Whether to keep the built preambles in memory or on disk.
const bool StorePreambleInMemory;
- /// Callback, invoked when preamble or main file AST is built.
+ /// Callback invoked when preamble or main file AST is built.
ParsingCallbacks &Callbacks;
/// Helper class required to build the ASTs.
const std::shared_ptr<PCHContainerOperations> PCHs;
@@ -340,9 +339,8 @@ ASTWorker::~ASTWorker() {
#endif
}
-void ASTWorker::update(ParseInputs Inputs, WantDiagnostics WantDiags,
- unique_function<void(std::vector<Diag>)> OnUpdated) {
- auto Task = [=](decltype(OnUpdated) OnUpdated) mutable {
+void ASTWorker::update(ParseInputs Inputs, WantDiagnostics WantDiags) {
+ auto Task = [=]() mutable {
// Will be used to check if we can avoid rebuilding the AST.
bool InputsAreTheSame =
std::tie(FileInputs.CompileCommand, FileInputs.Contents) ==
@@ -436,7 +434,7 @@ void ASTWorker::update(ParseInputs Inputs, WantDiagnostics WantDiags,
{
std::lock_guard<std::mutex> Lock(DiagsMu);
if (ReportDiagnostics)
- OnUpdated((*AST)->getDiagnostics());
+ Callbacks.onDiagnostics(FileName, (*AST)->getDiagnostics());
}
trace::Span Span("Running main AST callback");
Callbacks.onMainAST(FileName, **AST);
@@ -446,7 +444,7 @@ void ASTWorker::update(ParseInputs Inputs, WantDiagnostics WantDiags,
IdleASTs.put(this, std::move(*AST));
};
- startTask("Update", Bind(Task, std::move(OnUpdated)), WantDiags);
+ startTask("Update", std::move(Task), WantDiags);
}
void ASTWorker::runWithAST(
@@ -742,8 +740,7 @@ bool TUScheduler::blockUntilIdle(Deadline D) const {
}
void TUScheduler::update(PathRef File, ParseInputs Inputs,
- WantDiagnostics WantDiags,
- unique_function<void(std::vector<Diag>)> OnUpdated) {
+ WantDiagnostics WantDiags) {
std::unique_ptr<FileData> &FD = Files[File];
if (!FD) {
// Create a new worker to process the AST-related tasks.
@@ -756,7 +753,7 @@ void TUScheduler::update(PathRef File, ParseInputs Inputs,
FD->Contents = Inputs.Contents;
FD->Command = Inputs.CompileCommand;
}
- FD->Worker->update(std::move(Inputs), WantDiags, std::move(OnUpdated));
+ FD->Worker->update(std::move(Inputs), WantDiags);
}
void TUScheduler::remove(PathRef File) {
OpenPOWER on IntegriCloud