[PATCH] D80743: (PR46111) Desugar Elaborated types in Deduction Guides.

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 4 12:42:56 PDT 2020


erichkeane added a comment.

In D80743#2074121 <https://reviews.llvm.org/D80743#2074121>, @erichkeane wrote:

> @rsmith I think this implements what you've suggested? I'm struggling a little with the template instantiations here, I'm not terribly sure I understand them as well as I'd hope.
>
> This seems to 'work' for a small subset of works, but it doesn't properly register the typedef to the LocalInstantiationScope, so the normal template instantiation (like here https://github.com/llvm/llvm-project/blob/master/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp#L156) ends up hitting the 'findInstantiationOf' assert here: https://github.com/llvm/llvm-project/blob/master/clang/lib/Sema/SemaTemplateInstantiate.cpp#L3564
>
> I can see the parameter itself with the correct type being registered here: https://github.com/llvm/llvm-project/blob/master/clang/lib/Sema/SemaTemplate.cpp#L2249
>
> But I don't have a good idea on how I'm supposed to do this with the typedef.  Since it is a materialized typedef, it doesn't seem like we have the 'old' decl to register, nor access to the LocalInstantiationScope.
>
> Can you make a suggestion?  Am I missing something simple, or did I just not do what you suggested?  If thats the case, can you rephrase your thought?
>
> Thanks!
> -Erich


Hmm... so I tried to assign the typedef to the CXXRecordDecl inside the template instead (giving it an immediate parent), but it this error:

  llvm-project/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp:149:24: error: type 'int' cannot be used prior to '::' because it has no members
      using U = typename T::type;
                     ^
  llvm-project/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp:150:10: note: in instantiation of template class 'look_into_current_instantiation::C<int>' requested here
      C(T, U);
       ^
  llvm-project/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp:156:5: note: while substituting deduced template arguments into function template '<deduction guide for C>' [with T = int]
    C c = {1, 2};

Is that the intended error?  Or am I causing an instantiation we shouldn't be (and breaking the reason for this TreeTransform-er)?

This is the reproducer, including a comment that makes me think this is the intended behavior:

  // We should have a substitution failure in the immediate context of
  // deduction when using the C(T, U) constructor (probably; core wording
  // unclear).
  template<typename T> struct C {
    using U = typename T::type;
    C(T, U);
  };
  
  struct R { R(int); typedef R type; };
  C(...) -> C<R>;
  
  C c = {1, 2};


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80743/new/

https://reviews.llvm.org/D80743





More information about the cfe-commits mailing list