Skip to content

Commit 79c265d

Browse files
author
Dimitri Ratz
committed
Simplify lambda capture by explicitly moving Item and parameters.
Fix code format.
1 parent f40d2c7 commit 79c265d

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

clang-tools-extra/clangd/ClangdServer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ void ClangdServer::resolveTypeHierarchy(
899899
PathRef File, TypeHierarchyItem Item, int Resolve,
900900
TypeHierarchyDirection Direction,
901901
Callback<std::optional<TypeHierarchyItem>> CB) {
902-
auto Action = [=, CB = std::move(CB),
902+
auto Action = [Item = std::move(Item), Resolve, Direction, CB = std::move(CB),
903903
this](llvm::Expected<InputsAndAST> InpAST) mutable {
904904
if (!InpAST)
905905
return CB(InpAST.takeError());

clang-tools-extra/clangd/FindSymbols.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
#include "Protocol.h"
1616
#include "index/Symbol.h"
17-
#include "llvm/ADT/StringRef.h"
1817
#include "clang/AST/Decl.h"
18+
#include "llvm/ADT/StringRef.h"
1919

2020
namespace clang {
2121
class NamedDecl;

clang-tools-extra/clangd/Protocol.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ bool fromJSON(const llvm::json::Value &Params, ChangeAnnotation &R,
209209
O.map("needsConfirmation", R.needsConfirmation) &&
210210
O.mapOptional("description", R.description);
211211
}
212-
llvm::json::Value toJSON(const ChangeAnnotation & CA) {
212+
llvm::json::Value toJSON(const ChangeAnnotation &CA) {
213213
llvm::json::Object Result{{"label", CA.label}};
214214
if (CA.needsConfirmation)
215215
Result["needsConfirmation"] = *CA.needsConfirmation;
@@ -859,7 +859,7 @@ llvm::json::Value toJSON(const SymbolInformation &P) {
859859
};
860860
if (P.score)
861861
O["score"] = *P.score;
862-
if(!P.tags.empty())
862+
if (!P.tags.empty())
863863
O["tags"] = P.tags;
864864
return std::move(O);
865865
}
@@ -1439,7 +1439,7 @@ llvm::json::Value toJSON(const TypeHierarchyItem &I) {
14391439

14401440
if (I.detail)
14411441
Result["detail"] = I.detail;
1442-
if(!I.tags.empty())
1442+
if (!I.tags.empty())
14431443
Result["tags"] = I.tags;
14441444
return std::move(Result);
14451445
}

clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,11 @@ TEST(CallHierarchy, OutgoingOneFile) {
305305
auto OugoingLevel1 = outgoingCalls(Items[0], Index.get(), AST);
306306
ASSERT_THAT(
307307
OugoingLevel1,
308-
ElementsAre(
309-
AllOf(to(AllOf(withName("Foo::caller1"), withDetail("ns::Foo::caller1"))),
310-
oFromRanges(Source.range("Caller1C"))),
311-
AllOf(to(AllOf(withName("caller2"), withDetail("caller2"))),
312-
oFromRanges(Source.range("Caller2")))));
308+
ElementsAre(AllOf(to(AllOf(withName("Foo::caller1"),
309+
withDetail("ns::Foo::caller1"))),
310+
oFromRanges(Source.range("Caller1C"))),
311+
AllOf(to(AllOf(withName("caller2"), withDetail("caller2"))),
312+
oFromRanges(Source.range("Caller2")))));
313313

314314
auto OutgoingLevel2 = outgoingCalls(OugoingLevel1[1].to, Index.get(), AST);
315315
ASSERT_THAT(
@@ -408,7 +408,8 @@ TEST(CallHierarchy, MultiFileCpp) {
408408
withDetail("nsa::caller1"))),
409409
iFromRanges(Caller1C.range()))));
410410

411-
auto IncomingLevel2 = incomingCalls(IncomingLevel1[0].from, Index.get(), AST);
411+
auto IncomingLevel2 =
412+
incomingCalls(IncomingLevel1[0].from, Index.get(), AST);
412413
ASSERT_THAT(
413414
IncomingLevel2,
414415
ElementsAre(
@@ -417,13 +418,15 @@ TEST(CallHierarchy, MultiFileCpp) {
417418
AllOf(from(AllOf(withName("caller3"), withDetail("nsa::caller3"))),
418419
iFromRanges(Caller3C.range("Caller1")))));
419420

420-
auto IncomingLevel3 = incomingCalls(IncomingLevel2[0].from, Index.get(), AST);
421+
auto IncomingLevel3 =
422+
incomingCalls(IncomingLevel2[0].from, Index.get(), AST);
421423
ASSERT_THAT(IncomingLevel3,
422424
ElementsAre(AllOf(from(AllOf(withName("caller3"),
423425
withDetail("nsa::caller3"))),
424426
iFromRanges(Caller3C.range("Caller2")))));
425427

426-
auto IncomingLevel4 = incomingCalls(IncomingLevel3[0].from, Index.get(), AST);
428+
auto IncomingLevel4 =
429+
incomingCalls(IncomingLevel3[0].from, Index.get(), AST);
427430
EXPECT_THAT(IncomingLevel4, IsEmpty());
428431
};
429432

@@ -564,20 +567,23 @@ TEST(CallHierarchy, IncomingMultiFileObjC) {
564567
ElementsAre(AllOf(from(withName("caller1")),
565568
iFromRanges(Caller1C.range()))));
566569

567-
auto IncomingLevel2 = incomingCalls(IncomingLevel1[0].from, Index.get(), AST);
570+
auto IncomingLevel2 =
571+
incomingCalls(IncomingLevel1[0].from, Index.get(), AST);
568572
ASSERT_THAT(IncomingLevel2,
569573
ElementsAre(AllOf(from(withName("caller2")),
570574
iFromRanges(Caller2C.range("A"),
571575
Caller2C.range("B"))),
572576
AllOf(from(withName("caller3")),
573577
iFromRanges(Caller3C.range("Caller1")))));
574578

575-
auto IncomingLevel3 = incomingCalls(IncomingLevel2[0].from, Index.get(), AST);
579+
auto IncomingLevel3 =
580+
incomingCalls(IncomingLevel2[0].from, Index.get(), AST);
576581
ASSERT_THAT(IncomingLevel3,
577582
ElementsAre(AllOf(from(withName("caller3")),
578583
iFromRanges(Caller3C.range("Caller2")))));
579584

580-
auto IncomingLevel4 = incomingCalls(IncomingLevel3[0].from, Index.get(), AST);
585+
auto IncomingLevel4 =
586+
incomingCalls(IncomingLevel3[0].from, Index.get(), AST);
581587
EXPECT_THAT(IncomingLevel4, IsEmpty());
582588
};
583589

0 commit comments

Comments
 (0)