Skip to content

Commit 7e8a0e4

Browse files
committed
[NFC] [C++20] [Modules] Rename NamedModuleHasInit to NamedModuleHasInit
Address comments in https://github.com/llvm/llvm-project/pull/67638/files#r1340342453 to rename the field variable.
1 parent c4e2fcf commit 7e8a0e4

File tree

6 files changed

+17
-16
lines changed

6 files changed

+17
-16
lines changed

clang/include/clang/Basic/Module.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ class alignas(8) Module {
360360

361361
/// Whether this C++20 named modules doesn't need an initializer.
362362
/// This is only meaningful for C++20 modules.
363-
unsigned NamedModuleHasNoInit : 1;
363+
unsigned NamedModuleHasInit : 1;
364364

365365
/// Describes the visibility of the various names within a
366366
/// particular module.
@@ -600,7 +600,7 @@ class alignas(8) Module {
600600
return Kind == ModuleInterfaceUnit || Kind == ModulePartitionInterface;
601601
}
602602

603-
bool isNamedModuleInterfaceHasNoInit() const { return NamedModuleHasNoInit; }
603+
bool isNamedModuleInterfaceHasInit() const { return NamedModuleHasInit; }
604604

605605
/// Get the primary module interface name from a partition.
606606
StringRef getPrimaryModuleInterfaceName() const {

clang/lib/Basic/Module.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent,
4444
InferSubmodules(false), InferExplicitSubmodules(false),
4545
InferExportWildcard(false), ConfigMacrosExhaustive(false),
4646
NoUndeclaredIncludes(false), ModuleMapIsPrivate(false),
47-
NamedModuleHasNoInit(false), NameVisibility(Hidden) {
47+
NamedModuleHasInit(true), NameVisibility(Hidden) {
4848
if (Parent) {
4949
IsAvailable = Parent->isAvailable();
5050
IsUnimportable = Parent->isUnimportable();

clang/lib/CodeGen/CGDeclCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
677677
continue; // TODO: warn of mixed use of module map modules and C++20?
678678
// We're allowed to skip the initialization if we are sure it doesn't
679679
// do any thing.
680-
if (M->isNamedModuleInterfaceHasNoInit())
680+
if (!M->isNamedModuleInterfaceHasInit())
681681
continue;
682682
llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
683683
SmallString<256> FnName;

clang/lib/Sema/Sema.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,20 +1250,21 @@ void Sema::ActOnEndOfTranslationUnit() {
12501250
CurrentModule && CurrentModule->isInterfaceOrPartition()) {
12511251
auto DoesModNeedInit = [this](Module *M) {
12521252
if (!getASTContext().getModuleInitializers(M).empty())
1253-
return false;
1253+
return true;
12541254
for (auto [Exported, _] : M->Exports)
1255-
if (!Exported->isNamedModuleInterfaceHasNoInit())
1256-
return false;
1255+
if (Exported->isNamedModuleInterfaceHasInit())
1256+
return true;
12571257
for (Module *I : M->Imports)
1258-
if (!I->isNamedModuleInterfaceHasNoInit())
1259-
return false;
1258+
if (I->isNamedModuleInterfaceHasInit())
1259+
return true;
12601260

1261-
return true;
1261+
return false;
12621262
};
12631263

1264-
CurrentModule->NamedModuleHasNoInit = DoesModNeedInit(CurrentModule);
1265-
for (Module *SubModules : CurrentModule->submodules())
1266-
CurrentModule->NamedModuleHasNoInit &= DoesModNeedInit(SubModules);
1264+
CurrentModule->NamedModuleHasInit =
1265+
DoesModNeedInit(CurrentModule) ||
1266+
llvm::any_of(CurrentModule->submodules(),
1267+
[&](auto *SubM) { return DoesModNeedInit(SubM); });
12671268
}
12681269

12691270
// Warnings emitted in ActOnEndOfTranslationUnit() should be emitted for

clang/lib/Serialization/ASTReader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5685,7 +5685,7 @@ llvm::Error ASTReader::ReadSubmoduleBlock(ModuleFile &F,
56855685
bool InferExportWildcard = Record[Idx++];
56865686
bool ConfigMacrosExhaustive = Record[Idx++];
56875687
bool ModuleMapIsPrivate = Record[Idx++];
5688-
bool NamedModuleHasNoInit = Record[Idx++];
5688+
bool NamedModuleHasInit = Record[Idx++];
56895689

56905690
Module *ParentModule = nullptr;
56915691
if (Parent)
@@ -5736,7 +5736,7 @@ llvm::Error ASTReader::ReadSubmoduleBlock(ModuleFile &F,
57365736
CurrentModule->InferExportWildcard = InferExportWildcard;
57375737
CurrentModule->ConfigMacrosExhaustive = ConfigMacrosExhaustive;
57385738
CurrentModule->ModuleMapIsPrivate = ModuleMapIsPrivate;
5739-
CurrentModule->NamedModuleHasNoInit = NamedModuleHasNoInit;
5739+
CurrentModule->NamedModuleHasInit = NamedModuleHasInit;
57405740
if (DeserializationListener)
57415741
DeserializationListener->ModuleRead(GlobalID, CurrentModule);
57425742

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2890,7 +2890,7 @@ void ASTWriter::WriteSubmodules(Module *WritingModule) {
28902890
Mod->InferExportWildcard,
28912891
Mod->ConfigMacrosExhaustive,
28922892
Mod->ModuleMapIsPrivate,
2893-
Mod->NamedModuleHasNoInit};
2893+
Mod->NamedModuleHasInit};
28942894
Stream.EmitRecordWithBlob(DefinitionAbbrev, Record, Mod->Name);
28952895
}
28962896

0 commit comments

Comments
 (0)