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
nit: "of substituted template parameter" --> "a substituted template parmeter"
(or "of substituted template parameter type")