This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Parameter hints for dependent calls
ClosedPublic

Authored by nridge on Apr 19 2021, 12:36 AM.

Diff Detail

Event Timeline

nridge created this revision.Apr 19 2021, 12:36 AM
nridge requested review of this revision.Apr 19 2021, 12:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2021, 12:36 AM
nridge updated this revision to Diff 340439.Apr 25 2021, 11:36 PM

Add some more test cases

nridge added inline comments.
clang-tools-extra/clangd/unittests/InlayHintTests.cpp
267

This is an interesting case. Clang builds a CXXDependentScopeMemberExpr for this callee, but HeuristicResolver currently assumes that such expressions are only built for non-static member accesses (since, for static member accesses, clang usually builds a DependentScopeDeclRefExpr instead).

The CXXDependentScopeMemberExpr is created here, and I note the dependence on whether the enclosing context is an instance method. I guess it must think that, after instantiation, A<T> could turn out to be a base class, and thus this could be a "non-static member access with qualifier".

I don't see anything obvious on CXXDependentScopeMemberExpr that would let us tell apart "definitely a non-static member" from "maybe static, maybe non-static", so I guess the appropriate solution is to drop the NonStaticFilter here altogether?

sammccall accepted this revision.Apr 28 2021, 4:21 AM
sammccall added inline comments.
clang-tools-extra/clangd/InlayHints.cpp
56

should we conservatively make this size != 1?
e.g. if the callee ends up being an OverloadExpr of some kind, picking the first overload seems pretty arbitrary and maybe misleading.

clang-tools-extra/clangd/unittests/InlayHintTests.cpp
247

can we add a test involving overloads?

i think:

void foo(int anInt);
void foo(double aDouble);
template <class T> go {
  foo(T{}); // expect no hints
}
267

I guess it must think that, after instantiation, A<T> could turn out to be a base class, and thus this could be a "non-static member access with qualifier".

Argh, C++ is so tricky :-( That sounds plausible to me.

drop the NonStaticFilter here altogether

Yeah. The other thing is that some_instance.some_static_member is perfectly legal I think? So the NonStaticFilter is probably not correct anyway.

This revision is now accepted and ready to land.Apr 28 2021, 4:21 AM
nridge updated this revision to Diff 342314.May 2 2021, 10:38 PM

Address review comments

nridge added inline comments.May 2 2021, 10:40 PM
clang-tools-extra/clangd/unittests/InlayHintTests.cpp
267

This is sufficiently non-trivial to fix (requires more than just removing the filter) that I'll leave it for a separate patch / review.

nridge marked 2 inline comments as done.May 2 2021, 10:40 PM
This revision was landed with ongoing or failed builds.May 2 2021, 11:03 PM
This revision was automatically updated to reflect the committed changes.