================ @@ -633,13 +633,30 @@ class InlayHintVisitor : public RecursiveASTVisitor<InlayHintVisitor> { } if (auto *AT = D->getType()->getContainedAutoType()) { - if (AT->isDeduced() && !D->getType()->isDependentType()) { - // Our current approach is to place the hint on the variable - // and accordingly print the full type - // (e.g. for `const auto& x = 42`, print `const int&`). - // Alternatively, we could place the hint on the `auto` - // (and then just print the type deduced for the `auto`). - addTypeHint(D->getLocation(), D->getType(), /*Prefix=*/": "); + if (AT->isDeduced()) { + QualType T; + // If the type is dependent, HeuristicResolver *may* be able to + // resolve it to something that's useful to print. In other + // cases, it can't, and the resultng type would just be printed + // as "<dependent type>", in which case don't hint it at all. + if (D->getType()->isDependentType()) { + if (D->hasInit()) { + QualType Resolved = Resolver->resolveExprToType(D->getInit()); + if (Resolved != AST.DependentTy) { ---------------- HighCommander4 wrote:
The resolved type may still be dependent. For example, in the test case from the issue description: ```c++ template <typename T> void foo(T x) { auto y = x; } ``` the type will be `T`, which is a `TemplateTypeParmType` and thus still dependent. What I'm intending to check for here is whether this is a dependent type about which no information is known, i.e. it would be printed as `<dependent type>`. https://github.com/llvm/llvm-project/pull/156284 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits