[clang] [clang] Improve heuristic resolution of template parameters reached indirectly (PR #223667)
Nathan Ridge via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 23 23:48:10 PDT 2026
================
@@ -136,8 +160,22 @@ TagDecl *HeuristicResolverImpl::resolveTypeToTagDecl(QualType QT) {
T = T->getCanonicalTypeInternal().getTypePtr();
if (const auto *DNT = T->getAs<DependentNameType>()) {
- T = resolveDeclsToType(resolveDependentNameType(DNT), Ctx)
- .getTypePtrOrNull();
+ auto Decls = resolveDependentNameType(DNT);
+ QualType Resolved = resolveDeclsToType(Decls, Ctx);
+ // `Resolved` is canonical, so if the name refers to a member typedef of a
+ // template parameter (as `vector<T>::allocator_type` does), it has lost the
+ // TemplateTypeParmDecl we would need to fall back to the parameter's
+ // default argument. Consult the typedef's underlying type as written
+ // instead.
+ if (Decls.size() == 1) {
----------------
HighCommander4 wrote:
This logic can be moved into `resolveDeclsToType`.
In fact, since `resolveDeclsToType` already checks `Decls.size() == 1`, it's sufficient to add the code inside this block (handling TypedefNameDecl) to the helper `resolveDeclToType`.
https://github.com/llvm/llvm-project/pull/223667
More information about the cfe-commits
mailing list