[clangd] Fix a data race in test code

Found by TSan, thanks bkramer for pointing this out.

llvm-svn: 370758
This commit is contained in:
Ilya Biryukov 2019-09-03 13:56:03 +00:00
parent 80195e7d1c
commit 72379548eb
1 changed files with 3 additions and 1 deletions

View File

@ -740,12 +740,14 @@ TEST_F(TUSchedulerTests, CommandLineErrors) {
// We should see errors from command-line parsing inside the main file. // We should see errors from command-line parsing inside the main file.
CDB.ExtraClangFlags = {"-fsome-unknown-flag"}; CDB.ExtraClangFlags = {"-fsome-unknown-flag"};
// (!) 'Ready' must live longer than TUScheduler.
Notification Ready;
TUScheduler S(CDB, /*AsyncThreadsCount=*/getDefaultAsyncThreadsCount(), TUScheduler S(CDB, /*AsyncThreadsCount=*/getDefaultAsyncThreadsCount(),
/*StorePreambleInMemory=*/true, /*ASTCallbacks=*/captureDiags(), /*StorePreambleInMemory=*/true, /*ASTCallbacks=*/captureDiags(),
/*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(), /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
ASTRetentionPolicy()); ASTRetentionPolicy());
Notification Ready;
std::vector<Diag> Diagnostics; std::vector<Diag> Diagnostics;
updateWithDiags(S, testPath("foo.cpp"), "void test() {}", updateWithDiags(S, testPath("foo.cpp"), "void test() {}",
WantDiagnostics::Yes, [&](std::vector<Diag> D) { WantDiagnostics::Yes, [&](std::vector<Diag> D) {