diff options
author | Younan Zhang <zyn7109@gmail.com> | 2023-05-31 14:49:32 +0800 |
---|---|---|
committer | Younan Zhang <zyn7109@gmail.com> | 2023-06-13 19:15:24 +0800 |
commit | 7d68f2ef411ea2188666c2f67a8ee8b923adb12d (patch) | |
tree | 7966f2d4b779f88ca7c1ac4468663999129a53d1 /llvm/lib/CodeGen/MachineScheduler.cpp | |
parent | 834cc88c5d08ca55664b7742590463de813d768f (diff) | |
download | llvm-7d68f2ef411ea2188666c2f67a8ee8b923adb12d.zip llvm-7d68f2ef411ea2188666c2f67a8ee8b923adb12d.tar.gz llvm-7d68f2ef411ea2188666c2f67a8ee8b923adb12d.tar.bz2 |
[clangd] Desugar template parameter aliases in type hints
This patch alleviates https://github.com/clangd/clangd/issues/1298.
Containers in C++ such as `std::vector` or `llvm::SmallVector`,
introduce a series of type aliases to adapt to generic algorithms.
Currently, If we write an declarator involving expressions with
these containers and `auto` placeholder, we probably obtain opaque
type alias like following:
```
std::vector<int> v = {1, 2, 3};
auto value = v[1]; // hint for `value`: value_type
auto *ptr = &v[0]; // hint for `ptr`: value_type *
```
These hints are useless for most of the time. It would be nice if we
desugar the type of `value_type` and print `int`, `int *` respectively
in this situation. But note we can't always prefer desugared type
since user might introduce type-aliases for brevity, where printing
sugared types makes more sense.
This patch introduces a heuristic method that displays the desugared
type that is an alias of template parameter. It merges
analogous method `shouldPrintCanonicalType` into `maybeDesugar` as well.
Previous commit for shouldPrintCanonicalType: dde8a0fe91cc
Reviewed By: nridge
Differential Revision: https://reviews.llvm.org/D151785
Diffstat (limited to 'llvm/lib/CodeGen/MachineScheduler.cpp')
0 files changed, 0 insertions, 0 deletions