[clang] [clang-tools-extra] [clangd] show lambda name instead of operator() in signature help (PR #101857)

via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 9 06:29:36 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 1a9acd786d493b00c08d1611f51420d421b74cf1 d8140f9013f47094a159fd2918128d9252ca3280 --extensions cpp,h -- clang-tools-extra/clangd/CodeComplete.cpp clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp clang/include/clang/Sema/CodeCompleteConsumer.h clang/include/clang/Sema/Overload.h clang/include/clang/Sema/Sema.h clang/lib/Sema/CodeCompleteConsumer.cpp clang/lib/Sema/SemaCodeComplete.cpp clang/lib/Sema/SemaOverload.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index 9e9792f074..0b8523af61 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1450,8 +1450,9 @@ TEST(SignatureHelpTest, ShowOperatorParensForImmediatelyInvokedLambda) {
   const auto Results = signatures(R"cpp(
     auto foo = [](int x, int y){}(^);
   )cpp");
-  EXPECT_THAT(Results.signatures,
-              UnorderedElementsAre(sig("operator()([[int x]], [[int y]]) -> void")));
+  EXPECT_THAT(
+      Results.signatures,
+      UnorderedElementsAre(sig("operator()([[int x]], [[int y]]) -> void")));
 }
 
 TEST(SignatureHelpTest, ShowOperatorParensForLambdaReturnedFromFunction) {
@@ -1461,8 +1462,9 @@ TEST(SignatureHelpTest, ShowOperatorParensForLambdaReturnedFromFunction) {
     }
     int main() { returnsLambda()(^); }
   )cpp");
-  EXPECT_THAT(Results.signatures,
-              UnorderedElementsAre(sig("operator()([[int x]], [[int y]]) -> void")));
+  EXPECT_THAT(
+      Results.signatures,
+      UnorderedElementsAre(sig("operator()([[int x]], [[int y]]) -> void")));
 }
 
 TEST(SignatureHelpTest, FunctionPointers) {
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index 36a98a6ec0..935a5597bb 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -6298,9 +6298,10 @@ SemaCodeCompletion::ProduceCallSignatureHelp(Expr *Fn, ArrayRef<Expr *> Args,
         SmallVector<Expr *, 12> ArgExprs(1, NakedFn);
         ArgExprs.append(ArgsWithoutDependentTypes.begin(),
                         ArgsWithoutDependentTypes.end());
-        auto *const LambdaDecl =
-            DC->isLambda() ? dyn_cast_if_present<VarDecl>(NakedFn->getReferencedDeclOfCallee())
-                           : nullptr;
+        auto *const LambdaDecl = DC->isLambda()
+                                     ? dyn_cast_if_present<VarDecl>(
+                                           NakedFn->getReferencedDeclOfCallee())
+                                     : nullptr;
         SemaRef.AddFunctionCandidates(R.asUnresolvedSet(), ArgExprs,
                                       CandidateSet,
                                       /*ExplicitArgs=*/nullptr,

``````````

</details>


https://github.com/llvm/llvm-project/pull/101857


More information about the cfe-commits mailing list