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:
```c++
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. However, things are complicated if user introducesBut note we can't always prefer desugared type-
alias for brevity: we don't want to make the length of hints be too long!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
type that is an alias of template parameter. It merges
for type-aliases that depend on some template parameters or simplyanalogous method `shouldPrintCanonicalType` into `maybeDesugar` as well.
reduce to builtin types e.g. int, double.
Previous commit for shouldPrintCanonicalType: dde8a0fe91cc