This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Simplify auto hover
ClosedPublic

Authored by ilya-biryukov on Oct 16 2018, 4:15 PM.

Details

Summary

Use helper from clang. Also fixes some weird corner cases, e.g.

auto (*foo)() = bar;

Diff Detail

Repository
rL LLVM

Event Timeline

ilya-biryukov created this revision.Oct 16 2018, 4:15 PM
kadircet accepted this revision.Oct 16 2018, 4:52 PM

LGTM, it bugs me that some part in the documentation says it doesn't go through decltype(This looks through declarators like pointer types, but not through decltype or typedefs) but since tests containing decltype didn't break it looks OK to me. I would still wait for @hokein to have another look as well.

This revision is now accepted and ready to land.Oct 16 2018, 4:52 PM
hokein accepted this revision.Oct 16 2018, 11:44 PM

looks good! didn't know this API before.

clangd/XRefs.cpp
592 ↗(On Diff #169917)

Maybe just

if (auto* DT = D->getType()->getContainedDeducedType())
   DeducedType = *DT;

?

620 ↗(On Diff #169917)

also expand this comment mentioning that decltype is not handled by the getContainedAutoType or getContainedDeducedType?

ilya-biryukov marked 2 inline comments as done.
  • Addressed review comments

LGTM, it bugs me that some part in the documentation says it doesn't go through decltype(This looks through declarators like pointer types, but not through decltype or typedefs) but since tests containing decltype didn't break it looks OK to me. I would still wait for @hokein to have another look as well.

The decltypes are handled separately in VisitDecltypeTypeLoc and typedefs are a decl, so they are handled even before the visitor runs. This is only about 'auto'. So I think we're covered here.

clangd/XRefs.cpp
592 ↗(On Diff #169917)

It feels like explicitly unwrapping auto from the deduced type instead of relying the printer to do that is a bit more straightforward.

Simplified code a bit per suggestions.

This revision was automatically updated to reflect the committed changes.