[Modules] Don't check [temp.friend]p9 in ASTContext::isSameEntity
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>
Thu, 23 Feb 2023 09:04:42 +0000 (17:04 +0800)
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>
Thu, 23 Feb 2023 09:09:38 +0000 (17:09 +0800)
[temp.friend]p9 says

> Such a constrained friend function or function template declaration does
not declare the same function or function template as a declaration in
any other scope.

But the friend declaration in the same scope shouldn't fall into this
catagory. Although the logic is handled in 'FriendsDifferByConstraints',
the compiler may haven't merged the lexcial declcontext in time.
Also the code removed is not covered by test too.

Let's handle the logic in sema as we've done now.

clang/lib/AST/ASTContext.cpp

index d852ac5..11c0704 100644 (file)
@@ -6687,10 +6687,6 @@ bool ASTContext::isSameEntity(const NamedDecl *X, const NamedDecl *Y) const {
                               FuncY->getTrailingRequiresClause()))
       return false;
 
-    // Constrained friends are different in certain cases, see: [temp.friend]p9.
-    if (FriendsDifferByConstraints(FuncX, FuncY))
-      return false;
-
     auto GetTypeAsWritten = [](const FunctionDecl *FD) {
       // Map to the first declaration that we've already merged into this one.
       // The TSI of redeclarations might not match (due to calling conventions