diff options
| author | Ilya Biryukov <ibiryukov@google.com> | 2018-03-14 17:46:52 +0000 |
|---|---|---|
| committer | Ilya Biryukov <ibiryukov@google.com> | 2018-03-14 17:46:52 +0000 |
| commit | f1f3d57eb2a6f8bf78e61ab15353651ac0849371 (patch) | |
| tree | c2cd7cc6a15280b485ef7ce047d8176da718a998 /clang-tools-extra/clangd/TUScheduler.cpp | |
| parent | 74acdfa6917816824166cd6bd8bf62d78b152524 (diff) | |
| download | bcm5719-llvm-f1f3d57eb2a6f8bf78e61ab15353651ac0849371.tar.gz bcm5719-llvm-f1f3d57eb2a6f8bf78e61ab15353651ac0849371.zip | |
[clangd] Don't expose vfs in TUScheduler::runWithPreamble.
Summary:
It was previously an easy way to concurrently access a mutable vfs,
which is a recipe for disaster.
Reviewers: sammccall
Reviewed By: sammccall
Subscribers: klimek, jkorous-apple, cfe-commits, ioeric
Differential Revision: https://reviews.llvm.org/D44463
llvm-svn: 327537
Diffstat (limited to 'clang-tools-extra/clangd/TUScheduler.cpp')
| -rw-r--r-- | clang-tools-extra/clangd/TUScheduler.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/clang-tools-extra/clangd/TUScheduler.cpp b/clang-tools-extra/clangd/TUScheduler.cpp index 15bb9c13dbe..51b13e2b7ba 100644 --- a/clang-tools-extra/clangd/TUScheduler.cpp +++ b/clang-tools-extra/clangd/TUScheduler.cpp @@ -407,7 +407,8 @@ unsigned getDefaultAsyncThreadsCount() { struct TUScheduler::FileData { /// Latest inputs, passed to TUScheduler::update(). - ParseInputs Inputs; + std::string Contents; + tooling::CompileCommand Command; ASTWorkerHandle Worker; }; @@ -456,9 +457,11 @@ void TUScheduler::update(PathRef File, ParseInputs Inputs, File, WorkerThreads ? WorkerThreads.getPointer() : nullptr, Barrier, CppFile(File, StorePreamblesInMemory, PCHOps, ASTCallback), UpdateDebounce); - FD = std::unique_ptr<FileData>(new FileData{Inputs, std::move(Worker)}); + FD = std::unique_ptr<FileData>(new FileData{ + Inputs.Contents, Inputs.CompileCommand, std::move(Worker)}); } else { - FD->Inputs = Inputs; + FD->Contents = Inputs.Contents; + FD->Command = Inputs.CompileCommand; } FD->Worker->update(std::move(Inputs), WantDiags, std::move(OnUpdated)); } @@ -500,26 +503,28 @@ void TUScheduler::runWithPreamble( SPAN_ATTACH(Tracer, "file", File); std::shared_ptr<const PreambleData> Preamble = It->second->Worker->getPossiblyStalePreamble(); - Action(InputsAndPreamble{It->second->Inputs, Preamble.get()}); + Action(InputsAndPreamble{It->second->Contents, It->second->Command, + Preamble.get()}); return; } - ParseInputs InputsCopy = It->second->Inputs; std::shared_ptr<const ASTWorker> Worker = It->second->Worker.lock(); - auto Task = [InputsCopy, Worker, this](std::string Name, std::string File, - Context Ctx, - decltype(Action) Action) mutable { + auto Task = [Worker, this](std::string Name, std::string File, + std::string Contents, + tooling::CompileCommand Command, Context Ctx, + decltype(Action) Action) mutable { std::lock_guard<Semaphore> BarrierLock(Barrier); WithContext Guard(std::move(Ctx)); trace::Span Tracer(Name); SPAN_ATTACH(Tracer, "file", File); std::shared_ptr<const PreambleData> Preamble = Worker->getPossiblyStalePreamble(); - Action(InputsAndPreamble{InputsCopy, Preamble.get()}); + Action(InputsAndPreamble{Contents, Command, Preamble.get()}); }; PreambleTasks->runAsync("task:" + llvm::sys::path::filename(File), Bind(Task, std::string(Name), std::string(File), + It->second->Contents, It->second->Command, Context::current().clone(), std::move(Action))); } |

