[clang-tools-extra] cbb3a39 - Revert "[test][clangd] Fix use-after-return after 72142fbac4"

Vitaly Buka via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 11 11:47:15 PDT 2022


Author: Vitaly Buka
Date: 2022-09-11T11:46:58-07:00
New Revision: cbb3a39e4dfcac5ea0ff353b6f81b0ea14eec8e2

URL: https://github.com/llvm/llvm-project/commit/cbb3a39e4dfcac5ea0ff353b6f81b0ea14eec8e2
DIFF: https://github.com/llvm/llvm-project/commit/cbb3a39e4dfcac5ea0ff353b6f81b0ea14eec8e2.diff

LOG: Revert "[test][clangd] Fix use-after-return after 72142fbac4"

Will try another fix.

This reverts commit c3c930d573656a825523b7112891bd97eec7b64f.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
index b2ab97e4f2494..4e95fcfea91c1 100644
--- a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -1227,14 +1227,14 @@ TEST_F(TUSchedulerTests, IncluderCache) {
   auto GetFlags = [&](PathRef Header) {
     S.update(Header, getInputs(Header, ";"), WantDiagnostics::Yes);
     EXPECT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
-    auto Cmd = std::make_shared<tooling::CompileCommand>();
+    tooling::CompileCommand Cmd;
     S.runWithPreamble("GetFlags", Header, TUScheduler::StaleOrAbsent,
-                      [Cmd](llvm::Expected<InputsAndPreamble> Inputs) {
+                      [&](llvm::Expected<InputsAndPreamble> Inputs) {
                         ASSERT_FALSE(!Inputs) << Inputs.takeError();
-                        *Cmd = std::move(Inputs->Command);
+                        Cmd = std::move(Inputs->Command);
                       });
     EXPECT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
-    return Cmd->CommandLine;
+    return Cmd.CommandLine;
   };
 
   for (const auto &Path : {NoCmd, Unreliable, OK, NotIncluded})


        


More information about the cfe-commits mailing list