[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:09 PDT 2026
https://github.com/HighCommander4 requested changes to this pull request.
Thanks for improving HeuristicResolver :)
I realized while reviewing this patch that the existing default template argument heuristic is a bit over-eager. For example:
```c++
struct Default {
void foo();
};
struct Custom {
void foo();
};
template <class T, class A = Default>
struct S {
A bar();
};
template <class T>
void baz() {
S<T, Custom> s;
s.bar().foo(); // incorrectly targets Default::foo rather than Custom::foo
}
```
This patch will make that over-eagerness visible in more contexts, for example:
```c++
struct Default {
void foo();
};
struct Custom {
void foo();
};
template <class T, class A = Default>
struct S {
typedef A type;
};
template <class T>
void baz() {
typename S<T, Custom>::type t;
t.foo(); // previously didn't resolve, now incorrectly resolves to Default::foo
}
```
Making these examples have the desired behaviour would be a more involved change, so no need to block on that now, but let's maybe add the above examples to the test suite with FIXMEs.
https://github.com/llvm/llvm-project/pull/223667
More information about the cfe-commits
mailing list