[AST] [Modules] Introduce Decl::getNonTransparentDeclContext to handle exported friends
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>
Thu, 11 Aug 2022 06:08:14 +0000 (14:08 +0800)
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>
Fri, 12 Aug 2022 03:50:35 +0000 (11:50 +0800)
commit0bc993edf4ec57993c8fc11ea511b3d62ffd3c93
tree7fad175e8b856bea94271d5c82cd180a6952e35d
parent4735104f09c5e7bcf1aff261ea0f3196941ce404
[AST] [Modules] Introduce Decl::getNonTransparentDeclContext to handle exported friends

Closing https://github.com/llvm/llvm-project/issues/56826.

The root cause for pr56826 is: when we collect the template args for the
friend, we need to judge if the friend lives in file context. However,
if the friend lives in ExportDecl lexically, the judgement here is
invalid.

The solution is easy. We should judge the non transparent context and
the ExportDecl is transparent context. So the solution should be good.

A main concern may be the patch doesn't handle all the places of the
same defect. I think it might not be bad since the patch itself should
be innocent.

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D131651
clang/include/clang/AST/DeclBase.h
clang/lib/AST/DeclBase.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/Modules/pr56826.cppm [new file with mode: 0644]
clang/unittests/AST/DeclTest.cpp