[clangd] Handle dependent call to function with explicit object parameter in InlayHintVisitor (#201264)

Dependent calls do not yet have the implicit object argument preprended
to the CallExpr's argument list, so the first argument should not be
expected to be present and dropped in this case.

Fixes https://github.com/llvm/llvm-project/issues/198588
This commit is contained in:
Nathan Ridge 2026-06-03 00:46:45 -04:00 committed by GitHub
parent 6d7962db93
commit a47bddccec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 1 deletions

View file

@ -492,7 +492,8 @@ public:
// either.
if (const CXXMethodDecl *Method =
dyn_cast_or_null<CXXMethodDecl>(Callee.Decl))
if (IsFunctor || Method->hasCXXExplicitFunctionObjectParameter())
if (IsFunctor || (!E->isTypeDependent() &&
Method->hasCXXExplicitFunctionObjectParameter()))
Args = Args.drop_front(1);
processCall(Callee, E->getRParenLoc(), Args);
return true;

View file

@ -890,6 +890,21 @@ TEST(ParameterHints, DeducingThis) {
ExpectedHint{"Param: ", "3"}, ExpectedHint{"C: ", "4"});
}
TEST(ParameterHints, DependentDeducingThis) {
assertParameterHints(R"cpp(
template <typename T>
struct S {
void f1(this S& obj);
void f2(this S& obj, int x, int y);
void g(S s) {
s.f1(); // no crash
s.f2($x[[42]], $y[[43]]);
}
};
)cpp",
ExpectedHint{"x: ", "x"}, ExpectedHint{"y: ", "y"});
}
TEST(ParameterHints, Macros) {
// Handling of macros depends on where the call's argument list comes from.