[Sema]Select correct lexical context during template instantiate
authorCongcong Cai <congcongcai0907@163.com>
Mon, 24 Apr 2023 22:30:58 +0000 (00:30 +0200)
committerCongcong Cai <congcongcai0907@163.com>
Wed, 26 Apr 2023 22:29:13 +0000 (00:29 +0200)
commit921b45a855f09afe99ea9c0c173794ee4ccd5872
tree119752a815ba333fc63a39f6b1ec9391f2458b9c
parentb6da4bf1f8ec245987cc4c8ac66e71ca2780d1dc
[Sema]Select correct lexical context during template instantiate

This patch wants to fix inline friend decl like
```
template <class F1> int foo(F1 X);
template <int A1> struct A {
  template <class F1> friend int foo(F1 X) { return A1; }
};

template struct A<1>;
int a = foo(1.0);
```

Differential Revision: https://reviews.llvm.org/D149009
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/SemaTemplate/template-friend-definition-in-template.cpp [new file with mode: 0644]