This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Map from a variable template specialization in a pattern to a variable template specialization in an instantiation properly
ClosedPublic

Authored by erik.pilkington on Jul 26 2019, 5:02 PM.

Details

Summary

Previously, when instantiating S<int>::mf below, we would emit a reference to the declaration of S<T2>::v<char>, when we really ought to make a new declaration for v in the template instantiation. This caused a variety of problems, since the variable template specialization that we were using was in a dependent context. The fix is to teach FindInstantiatedDecl to map the variable instantiation from the pattern to the instantiation.

Fixes llvm.org/PR42779.

template <class T2>
struct S {
  template <class T1>
  static constexpr int v = 0;

  void mf() { v<char>; }
};

S<int> x;

Thanks for taking a look!
Erik

Diff Detail

Repository
rL LLVM

Event Timeline

rsmith accepted this revision.Jul 26 2019, 5:14 PM
This revision is now accepted and ready to land.Jul 26 2019, 5:14 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 30 2019, 4:39 PM