[PATCH] D132014: [C++20] [Modules] Replace is ModuleMapModule with isHeaderLikeModules

Chuanqi Xu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 16 23:17:11 PDT 2022


ChuanqiXu created this revision.
ChuanqiXu added a reviewer: iains.
ChuanqiXu added a project: clang.
Herald added a project: All.
ChuanqiXu requested review of this revision.
Herald added a subscriber: cfe-commits.

I find that many places we should use `isHeaderLikeModules` instead of `isModuleMapModules` since the semantics of clang module map modules are similar to header units.

But the downside of the patch is that it misses test cases. Another alternative will be add the test case one by one, which will be more painful and slower but more stable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132014

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp


Index: clang/lib/Sema/SemaOverload.cpp
===================================================================
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -6402,7 +6402,7 @@
 
   // Functions with internal linkage are only viable in the same module unit.
   if (auto *MF = Function->getOwningModule()) {
-    if (getLangOpts().CPlusPlusModules && !MF->isModuleMapModule() &&
+    if (getLangOpts().CPlusPlusModules && !MF->isHeaderLikeModule() &&
         !isModuleUnitOfCurrentTU(MF)) {
       /// FIXME: Currently, the semantics of linkage in clang is slightly
       /// different from the semantics in C++ spec. In C++ spec, only names
Index: clang/lib/Sema/SemaLookup.cpp
===================================================================
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -1913,8 +1913,8 @@
   Module *DeclModule = SemaRef.getOwningModule(D);
   assert(DeclModule && "hidden decl has no owning module");
 
-  // Entities in module map modules are reachable only if they're visible.
-  if (DeclModule->isModuleMapModule())
+  // Entities in header like modules are reachable only if they're visible.
+  if (DeclModule->isHeaderLikeModule())
     return false;
 
   // If D comes from a module and SemaRef doesn't own a module, it implies D
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -9502,7 +9502,7 @@
     bool ImplicitInlineCXX20 = !getLangOpts().CPlusPlusModules ||
                                !NewFD->getOwningModule() ||
                                NewFD->getOwningModule()->isGlobalModule() ||
-                               NewFD->getOwningModule()->isModuleMapModule();
+                               NewFD->getOwningModule()->isHeaderLikeModule();
     bool isInline = D.getDeclSpec().isInlineSpecified();
     bool isVirtual = D.getDeclSpec().isVirtualSpecified();
     bool hasExplicit = D.getDeclSpec().hasExplicitSpecifier();
Index: clang/lib/CodeGen/CodeGenModule.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2981,7 +2981,7 @@
       // linkage later if it's redeclared outside the class.
       return false;
     if (CXX20ModuleInits && VD->getOwningModule() &&
-        !VD->getOwningModule()->isModuleMapModule()) {
+        !VD->getOwningModule()->isHeaderLikeModule()) {
       // For CXX20, module-owned initializers need to be deferred, since it is
       // not known at this point if they will be run for the current module or
       // as part of the initializer for an imported one.
@@ -6291,7 +6291,7 @@
     // initializer for imported modules, and that will likewise call those for
     // any imports it has.
     if (CXX20ModuleInits && Import->getImportedOwningModule() &&
-        !Import->getImportedOwningModule()->isModuleMapModule())
+        !Import->getImportedOwningModule()->isHeaderLikeModule())
       break;
 
     // For clang C++ module map modules the initializers for sub-modules are


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132014.453204.patch
Type: text/x-patch
Size: 3150 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220817/af002098/attachment.bin>


More information about the cfe-commits mailing list