From 72379548ebdec95cd4d9cfa58c16c90b6db8173d Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Tue, 3 Sep 2019 13:56:03 +0000 Subject: [PATCH] [clangd] Fix a data race in test code Found by TSan, thanks bkramer for pointing this out. llvm-svn: 370758 --- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp index 274c07f99cd7..ff28cbbb416f 100644 --- a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp +++ b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp @@ -740,12 +740,14 @@ TEST_F(TUSchedulerTests, CommandLineErrors) { // We should see errors from command-line parsing inside the main file. CDB.ExtraClangFlags = {"-fsome-unknown-flag"}; + // (!) 'Ready' must live longer than TUScheduler. + Notification Ready; + TUScheduler S(CDB, /*AsyncThreadsCount=*/getDefaultAsyncThreadsCount(), /*StorePreambleInMemory=*/true, /*ASTCallbacks=*/captureDiags(), /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(), ASTRetentionPolicy()); - Notification Ready; std::vector Diagnostics; updateWithDiags(S, testPath("foo.cpp"), "void test() {}", WantDiagnostics::Yes, [&](std::vector D) {