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


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
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to