[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.
This commit is contained in:
Chuanqi Xu
2023-09-29 21:37:08 +08:00
parent c4e2fcff78
commit 7e8a0e4bdc
6 changed files with 17 additions and 16 deletions

View File

@@ -360,7 +360,7 @@ public:
/// Whether this C++20 named modules doesn't need an initializer.
/// This is only meaningful for C++20 modules.
unsigned NamedModuleHasNoInit : 1;
unsigned NamedModuleHasInit : 1;
/// Describes the visibility of the various names within a
/// particular module.
@@ -600,7 +600,7 @@ public:
return Kind == ModuleInterfaceUnit || Kind == ModulePartitionInterface;
}
bool isNamedModuleInterfaceHasNoInit() const { return NamedModuleHasNoInit; }
bool isNamedModuleInterfaceHasInit() const { return NamedModuleHasInit; }
/// Get the primary module interface name from a partition.
StringRef getPrimaryModuleInterfaceName() const {

View File

@@ -44,7 +44,7 @@ Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent,
InferSubmodules(false), InferExplicitSubmodules(false),
InferExportWildcard(false), ConfigMacrosExhaustive(false),
NoUndeclaredIncludes(false), ModuleMapIsPrivate(false),
NamedModuleHasNoInit(false), NameVisibility(Hidden) {
NamedModuleHasInit(true), NameVisibility(Hidden) {
if (Parent) {
IsAvailable = Parent->isAvailable();
IsUnimportable = Parent->isUnimportable();

View File

@@ -677,7 +677,7 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
continue; // TODO: warn of mixed use of module map modules and C++20?
// We're allowed to skip the initialization if we are sure it doesn't
// do any thing.
if (M->isNamedModuleInterfaceHasNoInit())
if (!M->isNamedModuleInterfaceHasInit())
continue;
llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
SmallString<256> FnName;

View File

@@ -1250,20 +1250,21 @@ void Sema::ActOnEndOfTranslationUnit() {
CurrentModule && CurrentModule->isInterfaceOrPartition()) {
auto DoesModNeedInit = [this](Module *M) {
if (!getASTContext().getModuleInitializers(M).empty())
return false;
return true;
for (auto [Exported, _] : M->Exports)
if (!Exported->isNamedModuleInterfaceHasNoInit())
return false;
if (Exported->isNamedModuleInterfaceHasInit())
return true;
for (Module *I : M->Imports)
if (!I->isNamedModuleInterfaceHasNoInit())
return false;
if (I->isNamedModuleInterfaceHasInit())
return true;
return true;
return false;
};
CurrentModule->NamedModuleHasNoInit = DoesModNeedInit(CurrentModule);
for (Module *SubModules : CurrentModule->submodules())
CurrentModule->NamedModuleHasNoInit &= DoesModNeedInit(SubModules);
CurrentModule->NamedModuleHasInit =
DoesModNeedInit(CurrentModule) ||
llvm::any_of(CurrentModule->submodules(),
[&](auto *SubM) { return DoesModNeedInit(SubM); });
}
// Warnings emitted in ActOnEndOfTranslationUnit() should be emitted for

View File

@@ -5685,7 +5685,7 @@ llvm::Error ASTReader::ReadSubmoduleBlock(ModuleFile &F,
bool InferExportWildcard = Record[Idx++];
bool ConfigMacrosExhaustive = Record[Idx++];
bool ModuleMapIsPrivate = Record[Idx++];
bool NamedModuleHasNoInit = Record[Idx++];
bool NamedModuleHasInit = Record[Idx++];
Module *ParentModule = nullptr;
if (Parent)
@@ -5736,7 +5736,7 @@ llvm::Error ASTReader::ReadSubmoduleBlock(ModuleFile &F,
CurrentModule->InferExportWildcard = InferExportWildcard;
CurrentModule->ConfigMacrosExhaustive = ConfigMacrosExhaustive;
CurrentModule->ModuleMapIsPrivate = ModuleMapIsPrivate;
CurrentModule->NamedModuleHasNoInit = NamedModuleHasNoInit;
CurrentModule->NamedModuleHasInit = NamedModuleHasInit;
if (DeserializationListener)
DeserializationListener->ModuleRead(GlobalID, CurrentModule);

View File

@@ -2890,7 +2890,7 @@ void ASTWriter::WriteSubmodules(Module *WritingModule) {
Mod->InferExportWildcard,
Mod->ConfigMacrosExhaustive,
Mod->ModuleMapIsPrivate,
Mod->NamedModuleHasNoInit};
Mod->NamedModuleHasInit};
Stream.EmitRecordWithBlob(DefinitionAbbrev, Record, Mod->Name);
}