================ @@ -125,6 +126,20 @@ TagDecl *HeuristicResolverImpl::resolveTypeToTagDecl(QualType QT) { if (!T) return nullptr; + // If T is the type of a template parameter, we can't get a useful TagDecl + // out of it. However, if the template parameter has a default argument, + // as a heuristic we can replace T with the default argument type. + if (const auto *TTPT = dyn_cast<TemplateTypeParmType>(T)) { + if (const auto *TTPD = TTPT->getDecl()) { + if (TTPD->hasDefaultArgument()) { + const auto &DefaultArg = TTPD->getDefaultArgument().getArgument(); + if (DefaultArg.getKind() == TemplateArgument::Type) { + T = DefaultArg.getAsType().getTypePtrOrNull(); ---------------- HighCommander4 wrote:
Thanks for the added testcases! The recursive case made me realize that application of this heuristic is probably better done in `simplifyType`. I updated the patch and added the testcase. For the template template parameter case, I agree that it would be nice to make this work as well, but I'd rather leave that to a follow-up patch. https://github.com/llvm/llvm-project/pull/131074 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits