[clang-tools-extra] r347460 - [clangd] Fix use-after-scope in unit test

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 22 04:54:25 PST 2018


Author: d0k
Date: Thu Nov 22 04:54:25 2018
New Revision: 347460

URL: http://llvm.org/viewvc/llvm-project?rev=347460&view=rev
Log:
[clangd] Fix use-after-scope in unit test

The scheduler holds a reference to `Proceed`, so it has to be destroyed
after the scheduler. Found by asan.

Modified:
    clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp

Modified: clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp?rev=347460&r1=347459&r2=347460&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp Thu Nov 22 04:54:25 2018
@@ -221,6 +221,7 @@ TEST_F(TUSchedulerTests, Cancellation) {
   //    R3               <-- cancelled
   std::vector<std::string> DiagsSeen, ReadsSeen, ReadsCanceled;
   {
+    Notification Proceed; // Ensure we schedule everything.
     TUScheduler S(
         getDefaultAsyncThreadsCount(), /*StorePreamblesInMemory=*/true,
         /*ASTCallbacks=*/nullptr,
@@ -255,7 +256,6 @@ TEST_F(TUSchedulerTests, Cancellation) {
       return std::move(T.second);
     };
 
-    Notification Proceed; // Ensure we schedule everything.
     S.update(Path, getInputs(Path, ""), WantDiagnostics::Yes,
              [&](std::vector<Diag> Diags) { Proceed.wait(); });
     // The second parens indicate cancellation, where present.




More information about the cfe-commits mailing list