[PATCH] D102148: [clangd] Type hints for variables with 'auto' type
Nathan Ridge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun May 9 21:15:10 PDT 2021
nridge added a comment.
Here's a first draft of an implementation of type hints. It provided hints for variable declarations that use `auto` (possibly with const, &, etc.) as the type.
There are additional places in which type hints could be useful, such as:
- Functions with deduced return type (C++14)
- Structured bindings (either for the aggregate, or for the individual bindings)
- `decltype(expr)` in any context
- probably others I'm not thinking of
but I think it makes sense to pursue those in subsequent patches.
The patch also doesn't currently make an attempt to omit the type hint in cases where the type is obvious from the initializer. There's probably some low-hanging fruit to be had there:
- `= Foo(...)` or `= (Foo) (...)`
- `= static_cast<Foo>(...)`
- It might be nice to handle things like `make_unique<Foo>(...)` or `dyn_cast<Foo>(...)`, though I'm not sure if there's a general heuristic that would apply to things like this as a category.
Client-side patch for experimentation: https://github.com/clangd/vscode-clangd/pull/188
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102148/new/
https://reviews.llvm.org/D102148
More information about the cfe-commits
mailing list