diff options
Diffstat (limited to 'contrib/llvm-project/clang/lib/Basic/Module.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/Basic/Module.cpp | 51 |
1 files changed, 39 insertions, 12 deletions
diff --git a/contrib/llvm-project/clang/lib/Basic/Module.cpp b/contrib/llvm-project/clang/lib/Basic/Module.cpp index 8ec68237a0fc..925217431d4d 100644 --- a/contrib/llvm-project/clang/lib/Basic/Module.cpp +++ b/contrib/llvm-project/clang/lib/Basic/Module.cpp @@ -44,7 +44,7 @@ Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent, InferSubmodules(false), InferExplicitSubmodules(false), InferExportWildcard(false), ConfigMacrosExhaustive(false), NoUndeclaredIncludes(false), ModuleMapIsPrivate(false), - NameVisibility(Hidden) { + NamedModuleHasInit(true), NameVisibility(Hidden) { if (Parent) { IsAvailable = Parent->isAvailable(); IsUnimportable = Parent->isUnimportable(); @@ -89,7 +89,7 @@ static bool isPlatformEnvironment(const TargetInfo &Target, StringRef Feature) { // where both are valid examples of the same platform+environment but in the // variant (2) the simulator is hardcoded as part of the platform name. Both // forms above should match for "iossimulator" requirement. - if (Target.getTriple().isOSDarwin() && PlatformEnv.endswith("simulator")) + if (Target.getTriple().isOSDarwin() && PlatformEnv.ends_with("simulator")) return PlatformEnv == Feature || CmpPlatformEnv(PlatformEnv, Feature); return PlatformEnv == Feature; @@ -113,6 +113,7 @@ static bool hasFeature(StringRef Feature, const LangOptions &LangOpts, .Case("c99", LangOpts.C99) .Case("c11", LangOpts.C11) .Case("c17", LangOpts.C17) + .Case("c23", LangOpts.C23) .Case("freestanding", LangOpts.Freestanding) .Case("gnuinlineasm", LangOpts.GNUAsm) .Case("objc", LangOpts.ObjC) @@ -160,11 +161,13 @@ bool Module::isForBuilding(const LangOptions &LangOpts) const { StringRef TopLevelName = getTopLevelModuleName(); StringRef CurrentModule = LangOpts.CurrentModule; - // When building framework Foo, we want to make sure that Foo *and* - // Foo_Private are textually included and no modules are built for both. - if (getTopLevelModule()->IsFramework && + // When building the implementation of framework Foo, we want to make sure + // that Foo *and* Foo_Private are textually included and no modules are built + // for either. + if (!LangOpts.isCompilingModule() && getTopLevelModule()->IsFramework && CurrentModule == LangOpts.ModuleName && - !CurrentModule.endswith("_Private") && TopLevelName.endswith("_Private")) + !CurrentModule.ends_with("_Private") && + TopLevelName.ends_with("_Private")) TopLevelName = TopLevelName.drop_back(8); return TopLevelName == CurrentModule; @@ -264,10 +267,10 @@ bool Module::fullModuleNameIs(ArrayRef<StringRef> nameParts) const { } OptionalDirectoryEntryRef Module::getEffectiveUmbrellaDir() const { - if (Umbrella && Umbrella.is<FileEntryRef>()) - return Umbrella.get<FileEntryRef>().getDir(); - if (Umbrella && Umbrella.is<DirectoryEntryRef>()) - return Umbrella.get<DirectoryEntryRef>(); + if (const auto *Hdr = std::get_if<FileEntryRef>(&Umbrella)) + return Hdr->getDir(); + if (const auto *Dir = std::get_if<DirectoryEntryRef>(&Umbrella)) + return *Dir; return std::nullopt; } @@ -298,8 +301,10 @@ bool Module::directlyUses(const Module *Requested) { if (Requested->isSubModuleOf(Use)) return true; - // Anyone is allowed to use our builtin stddef.h and its accompanying module. - if (!Requested->Parent && Requested->Name == "_Builtin_stddef_max_align_t") + // Anyone is allowed to use our builtin stdarg.h and stddef.h and their + // accompanying modules. + if (Requested->getTopLevelModuleName() == "_Builtin_stdarg" || + Requested->getTopLevelModuleName() == "_Builtin_stddef") return true; if (NoUndeclaredIncludes) @@ -369,6 +374,28 @@ Module *Module::findOrInferSubmodule(StringRef Name) { return Result; } +Module *Module::getGlobalModuleFragment() const { + assert(isNamedModuleUnit() && "We should only query the global module " + "fragment from the C++ 20 Named modules"); + + for (auto *SubModule : SubModules) + if (SubModule->isExplicitGlobalModule()) + return SubModule; + + return nullptr; +} + +Module *Module::getPrivateModuleFragment() const { + assert(isNamedModuleUnit() && "We should only query the private module " + "fragment from the C++ 20 Named modules"); + + for (auto *SubModule : SubModules) + if (SubModule->isPrivateModule()) + return SubModule; + + return nullptr; +} + void Module::getExportedModules(SmallVectorImpl<Module *> &Exported) const { // All non-explicit submodules are exported. for (std::vector<Module *>::const_iterator I = SubModules.begin(), |