[PATCH] D103789: [clangd] Type hints for C++14 return type deduction

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 7 06:04:56 PDT 2021


sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang-tools-extra/clangd/InlayHints.cpp:79
+      if (!Deduced.isNull()) {
+        SourceRange R = D->getReturnTypeSourceRange();
+        // For operator auto(), have to get location of `auto` a different way.
----------------
nit: bool TrailingReturnType = D->getReturnTypeSourceRange().isValid()?


================
Comment at: clang-tools-extra/clangd/unittests/InlayHintTests.cpp:505
+  )cpp",
+      ExpectedHint{": int", "ret1a"}, ExpectedHint{": int", "ret1b"},
+      ExpectedHint{": int &", "ret2"}, ExpectedHint{": int", "retConv"});
----------------
This reads as "auto[: int] f1(int x);", which doesn't look much like familiar syntax, C++ or otherwise.

I guess we could try `auto f1(int x)[-> int];`?

(From playing with these in vscode, I'm not sure I find the punctuation very useful)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103789/new/

https://reviews.llvm.org/D103789



More information about the cfe-commits mailing list