Page MenuHomePhabricator

[clangd] Function return type hints: support lambdas, don't duplicate "->"
ClosedPublic

Authored by sammccall on Feb 23 2022, 7:59 AM.

Details

Summary

While here, fix an ugliness:

auto foo()->auto { return 42; }

This (silly) code gains a "-> int" hint. While correct and useful, it renders as

auto foo()->int->auto { return 42; }

which is confusing enough to do more harm than good I think.

Diff Detail

Event Timeline

sammccall created this revision.Feb 23 2022, 7:59 AM
sammccall requested review of this revision.Feb 23 2022, 7:59 AM
nridge accepted this revision.Feb 23 2022, 11:50 AM

Nice!

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

Maybe add a comment like "use digraphs to place a literal ] in an annotation range"

This revision is now accepted and ready to land.Feb 23 2022, 11:50 AM
Trass3r added inline comments.Feb 23 2022, 11:54 AM
clang-tools-extra/clangd/unittests/InlayHintTests.cpp
626

Should there be a test for void too or does it just work?

sammccall marked 2 inline comments as done.Feb 26 2022, 12:35 PM
sammccall added inline comments.
clang-tools-extra/clangd/unittests/InlayHintTests.cpp
626

Added a test verifying that an auto-typed function/lambda with no return statements gets a -> void hint.

This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.