[clang] 2a14bc5 - [NFC] [C++20] [Modules] Update comments for handling friend

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 25 00:41:14 PST 2022


Author: Chuanqi Xu
Date: 2022-01-25T16:39:47+08:00
New Revision: 2a14bc55c547f0fc7285b783b5320338c3ffdc42

URL: https://github.com/llvm/llvm-project/commit/2a14bc55c547f0fc7285b783b5320338c3ffdc42
DIFF: https://github.com/llvm/llvm-project/commit/2a14bc55c547f0fc7285b783b5320338c3ffdc42.diff

LOG: [NFC] [C++20] [Modules] Update comments for handling friend

There is a comment contains a FIXME for the Module TS. And now the
Module TS is merged so we should update the comment. I've checked the
implementation.

Added: 
    

Modified: 
    clang/lib/Sema/SemaDecl.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index a29409461f575..e014500f2114f 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1586,10 +1586,13 @@ void Sema::FilterLookupForScope(LookupResult &R, DeclContext *Ctx, Scope *S,
 /// We've determined that \p New is a redeclaration of \p Old. Check that they
 /// have compatible owning modules.
 bool Sema::CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old) {
-  // FIXME: The Modules TS is not clear about how friend declarations are
-  // to be treated. It's not meaningful to have 
diff erent owning modules for
-  // linkage in redeclarations of the same entity, so for now allow the
-  // redeclaration and change the owning modules to match.
+  // [module.interface]p7:
+  // A declaration is attached to a module as follows:
+  // - If the declaration is a non-dependent friend declaration that nominates a
+  // function with a declarator-id that is a qualified-id or template-id or that
+  // nominates a class other than with an elaborated-type-specifier with neither
+  // a nested-name-specifier nor a simple-template-id, it is attached to the
+  // module to which the friend is attached ([basic.link]).
   if (New->getFriendObjectKind() &&
       Old->getOwningModuleForLinkage() != New->getOwningModuleForLinkage()) {
     New->setLocalOwningModule(Old->getOwningModule());


        


More information about the cfe-commits mailing list