From 2d014b72ccb51de9a9627c31667a3edf8cca7616 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Mon, 25 Apr 2022 16:35:58 -0700 Subject: [PATCH] [test][clangd] Use StringRef instead of std::string runWithAST stores the first parameters as StringRef, so we can't use temporarily std::string from parameter ID. --- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp index 1aaac829d628..919f69c37840 100644 --- a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp +++ b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp @@ -281,22 +281,22 @@ TEST_F(TUSchedulerTests, Cancellation) { // R2B // U3(WantDiags=Yes) // R3 <-- cancelled - std::vector DiagsSeen, ReadsSeen, ReadsCanceled; + std::vector DiagsSeen, ReadsSeen, ReadsCanceled; { Notification Proceed; // Ensure we schedule everything. TUScheduler S(CDB, optsForTest(), captureDiags()); auto Path = testPath("foo.cpp"); // Helper to schedule a named update and return a function to cancel it. - auto Update = [&](std::string ID) -> Canceler { + auto Update = [&](StringRef ID) -> Canceler { auto T = cancelableTask(); WithContext C(std::move(T.first)); updateWithDiags( - S, Path, "//" + ID, WantDiagnostics::Yes, + S, Path, ("//" + ID).str(), WantDiagnostics::Yes, [&, ID](std::vector Diags) { DiagsSeen.push_back(ID); }); return std::move(T.second); }; // Helper to schedule a named read and return a function to cancel it. - auto Read = [&](std::string ID) -> Canceler { + auto Read = [&](StringRef ID) -> Canceler { auto T = cancelableTask(); WithContext C(std::move(T.first)); S.runWithAST(ID, Path, [&, ID](llvm::Expected E) {