rsmith added inline comments.

================
Comment at: clang/lib/Sema/SemaTemplate.cpp:1899-1907
     // Canonicalize the type. This (for instance) replaces references to
     // typedef members of the current instantiations with the definitions of
     // those typedefs, avoiding triggering instantiation of the deduced type
     // during deduction.
     // FIXME: It would be preferable to retain type sugar and source
     // information here (and handle this in substitution instead).
     NewDI = SemaRef.Context.getTrivialTypeSourceInfo(
----------------
This is really the problem: we shouldn't be doing a full canonicalization step 
here. I expect that even with your patch applied we'll still see problems for 
cases like:
```
template<unsigned long> struct X {};
template<typename T> struct A {
  A(T t, X<sizeof(t)>);
};
A a(0, {});
template<typename U> struct B {
  B(U u, X<sizeof(u)>);
};
B b(0, {});
```
... because we'll canonicalize the second parameter of `B`'s deduction guide to 
have type `X<sizeof(t)>` (where that's the `t` from `A`'s deduction guide).

So I think we should look at fixing the FIXME here properly. There seem to be 
at least two viable options:

1) don't canonicalize the type; instead, extend template instantiation to be 
able to cope with one template referring to members of another template 
directly, without instantiating the class containing those members, or
2) add a custom `TreeTransform` to do the canonicalization we want to do here, 
and to avoid the canonicalization we don't want to do

Both of these seem pretty tricky to get right, though, which is why we 
currently use the canonicalization hack :(


Repository:
  rC Clang

https://reviews.llvm.org/D49439



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D49439: [... Erik Pilkington via Phabricator via cfe-commits
    • [PATCH] D494... Richard Smith - zygoloid via Phabricator via cfe-commits
    • [PATCH] D494... Erik Pilkington via Phabricator via cfe-commits
    • [PATCH] D494... Erik Pilkington via Phabricator via cfe-commits
    • [PATCH] D494... Richard Smith - zygoloid via Phabricator via cfe-commits
    • [PATCH] D494... Phabricator via Phabricator via cfe-commits

Reply via email to