[PATCH] D104617: [clangd] Type hints for structured bindings
Nathan Ridge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 21 00:26:30 PDT 2021
nridge added inline comments.
================
Comment at: clang-tools-extra/clangd/InlayHints.cpp:40
+ // types would be "tuple_element<I, A>::type".
+ TypeHintPolicy.PrintCanonicalTypes = true;
}
----------------
While playing around with this, it did occur to me that in some cases it's more helpful to print sugared types than canonical types, for example in a case like this:
```
template <typename, typename, typename>
struct SomeLongType {};
using ShortType = SomeLongType<int, float, double>;
ShortType func();
auto x = func(); // would prefer "ShortType" as hint
```
However, it turns out that `AutoType` doesn't retain the sugared type to begin with (there's a FIXME about that [here](https://searchfox.org/llvm/rev/e497b12a69604b6d691312a30f6b86da4f18f7f8/clang/include/clang/AST/Type.h#4953)), so setting `PrintCanonicalTypes=true` doesn't actually regress cases like this (they were already printing the canonical type).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104617/new/
https://reviews.llvm.org/D104617
More information about the cfe-commits
mailing list