[clang] [clang-tools-extra] [clangd] show lambda name instead of operator() in signature help (PR #101857)
Timothy Akintilo via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 8 19:10:18 PDT 2024
================
@@ -6292,11 +6298,16 @@ SemaCodeCompletion::ProduceCallSignatureHelp(Expr *Fn, ArrayRef<Expr *> Args,
SmallVector<Expr *, 12> ArgExprs(1, NakedFn);
ArgExprs.append(ArgsWithoutDependentTypes.begin(),
ArgsWithoutDependentTypes.end());
+ auto *const LambdaName =
+ DC->isLambda() ? cast<VarDecl>(NakedFn->getReferencedDeclOfCallee())
----------------
tilobyte wrote:
@erichkeane stepping through the test i added for a lambda returned from a function, `NakedFn->getReferencedDeclOfCallee()` returns `nullptr` in the case of a lambda returned from a function. i believe this is because `NakedFn` is an rvalue, so there is no referenced decl to get.
using `cast_if_present`/`dyn_cast_if_present` seems to cover that case.
@zyn0217 yes, you are correct that `NakedFn` is a `DeclRefExpr` referring to the `VarDecl` of the declaration. `dyn_cast_if_present` indeed works, though i wonder--if `NakedFn->getReferencedDeclOfCallee()` returns `nullptr` in the case of a lambda returned from a function, could we get away with just `cast_if_present`?
https://github.com/llvm/llvm-project/pull/101857
More information about the cfe-commits
mailing list