Lines Matching +full:auto +full:- +full:retry
1 //===- ModuleMap.cpp - Describe the layout of modules ---------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 //===----------------------------------------------------------------------===//
59 auto PendingLinkAs = PendingLinkAsModule.find(Mod->Name); in resolveLinkAsDependencies()
61 for (auto &Name : PendingLinkAs->second) { in resolveLinkAsDependencies()
62 auto *M = findModule(Name.getKey()); in resolveLinkAsDependencies()
64 M->UseExportAsModuleLinkName = true; in resolveLinkAsDependencies()
70 if (findModule(Mod->ExportAsModule)) in addLinkAsDependency()
71 Mod->UseExportAsModuleLinkName = true; in addLinkAsDependency()
73 PendingLinkAsModule[Mod->ExportAsModule].insert(Mod->Name); in addLinkAsDependency()
123 // Resolve the module-id. in resolveExport()
138 << Id[0].first << Mod->getFullModuleName(); in resolveModuleId()
149 << Id[I].first << Context->getFullModuleName() in resolveModuleId()
150 << SourceRange(Id[0].second, Id[I-1].second); in resolveModuleId()
165 // Collect the framework names from the given module to the top-level module. in appendSubframeworkPaths()
167 for (; Mod; Mod = Mod->Parent) { in appendSubframeworkPaths()
168 if (Mod->IsFramework) in appendSubframeworkPaths()
169 Paths.push_back(Mod->Name); in appendSubframeworkPaths()
184 auto Directory = M->Directory; in findHeader()
185 SmallString<128> FullPathName(Directory->getName()); in findHeader()
187 auto GetFile = [&](StringRef Filename) -> OptionalFileEntryRef { in findHeader()
188 auto File = in findHeader()
190 if (!File || (Header.Size && File->getSize() != *Header.Size) || in findHeader()
191 (Header.ModTime && File->getModificationTime() != *Header.ModTime)) in findHeader()
196 auto GetFrameworkFile = [&]() -> OptionalFileEntryRef { in findHeader()
204 if (auto File = GetFile(FullPathName)) in findHeader()
213 if (M->IsFramework && M->Name == "Private") in findHeader()
230 if (M->isPartOfFramework()) in findHeader()
236 auto NormalHdrFile = GetFile(FullPathName); in findHeader()
238 if (!NormalHdrFile && Directory->getName().ends_with(".framework")) { in findHeader()
242 FullPathName.assign(Directory->getName()); in findHeader()
247 << Header.FileName << M->getFullModuleName(); in findHeader()
302 const DirectoryEntry *UmbrellaDir = &File->getDir().getDirEntry(); in resolveHeader()
305 << UmbrellaMod->getFullModuleName(); in resolveHeader()
316 // There's a builtin header but no corresponding on-disk header. Assume in resolveHeader()
323 Mod->MissingHeaders.push_back(Header); in resolveHeader()
329 Mod->markUnavailable(/*Unimportable=*/false); in resolveHeader()
337 Mod->isPartOfFramework() || !Mod->IsSystem || Header.IsUmbrella || in resolveAsBuiltinHeader()
338 !BuiltinIncludeDir || BuiltinIncludeDir == Mod->Directory || in resolveAsBuiltinHeader()
342 // This is a system module with a top-level header. This header in resolveAsBuiltinHeader()
346 llvm::sys::path::append(Path, BuiltinIncludeDir->getName(), Header.FileName); in resolveAsBuiltinHeader()
347 auto File = SourceMgr.getFileManager().getOptionalFileRef(Path); in resolveAsBuiltinHeader()
352 auto Role = headerKindToRole(Header.Kind); in resolveAsBuiltinHeader()
366 for (auto &M : Modules) in ~ModuleMap()
368 for (auto *M : ShadowModules) in ~ModuleMap()
373 assert((!this->Target || this->Target == &Target) && in setTarget()
375 this->Target = &Target; in setTarget()
423 Module->IsSystem && !Module->isPartOfFramework() && in shouldImportRelativeToBuiltinIncludeDir()
446 // frameworks moving from top-level frameworks to embedded frameworks tend in findHeaderInUmbrellaDirs()
447 // to be symlinked from the top-level location to the embedded location, in findHeaderInUmbrellaDirs()
454 auto KnownDir = UmbrellaDirs.find(*Dir); in findHeaderInUmbrellaDirs()
456 return KnownHeader(KnownDir->second, NormalHeader); in findHeaderInUmbrellaDirs()
481 &Header.getModule()->Headers[Module::HK_Private], in violatesPrivateInclude()
482 &Header.getModule()->Headers[Module::HK_PrivateTextual]}; in violatesPrivateInclude()
483 for (auto *Hs : HeaderList) in violatesPrivateInclude()
493 return M ? M->getTopLevelModule() : nullptr; in getTopLevelOrNull()
516 for (const KnownHeader &Header : Known->second) { in diagnoseHeaderInclusion()
532 !RequestingModule->directlyUses(Header.getModule())) { in diagnoseHeaderInclusion()
554 << RequestingModule->getTopLevelModule()->Name << Filename in diagnoseHeaderInclusion()
555 << NotUsed->Name; in diagnoseHeaderInclusion()
562 // At this point, only non-modular includes remain. in diagnoseHeaderInclusion()
566 << RequestingModule->getTopLevelModule()->Name << Filename; in diagnoseHeaderInclusion()
570 diag::kind DiagID = RequestingModule->getTopLevelModule()->IsFramework ? in diagnoseHeaderInclusion()
573 Diags.Report(FilenameLoc, DiagID) << RequestingModule->getFullModuleName() in diagnoseHeaderInclusion()
582 // importable is non-hermetic and can result in surprising behavior for in isBetterKnownHeader()
584 if (New.getModule()->isAvailable() && !Old.getModule()->isAvailable()) in isBetterKnownHeader()
592 // Prefer a non-textual header over a textual header. in isBetterKnownHeader()
597 // Prefer a non-excluded header over an excluded header. in isBetterKnownHeader()
609 auto MakeResult = [&](ModuleMap::KnownHeader R) -> ModuleMap::KnownHeader { in findModuleForHeader()
619 for (KnownHeader &H : Known->second) { in findModuleForHeader()
624 if (H.getModule()->getTopLevelModule() == SourceModule) in findModuleForHeader()
647 while (!UmbrellaModule->getEffectiveUmbrellaDir() && UmbrellaModule->Parent) in findOrCreateModuleForHeaderInUmbrellaDir()
648 UmbrellaModule = UmbrellaModule->Parent; in findOrCreateModuleForHeaderInUmbrellaDir()
650 if (UmbrellaModule->InferSubmodules) { in findOrCreateModuleForHeaderInUmbrellaDir()
656 bool Explicit = UmbrellaModule->InferExplicitSubmodules; in findOrCreateModuleForHeaderInUmbrellaDir()
666 Result->IsInferred = true; in findOrCreateModuleForHeaderInUmbrellaDir()
673 if (UmbrellaModule->InferExportWildcard && Result->Exports.empty()) in findOrCreateModuleForHeaderInUmbrellaDir()
674 Result->Exports.push_back(Module::ExportDecl(nullptr, true)); in findOrCreateModuleForHeaderInUmbrellaDir()
684 Result->IsInferred = true; in findOrCreateModuleForHeaderInUmbrellaDir()
685 Result->addTopHeader(File); in findOrCreateModuleForHeaderInUmbrellaDir()
689 if (UmbrellaModule->InferExportWildcard && Result->Exports.empty()) in findOrCreateModuleForHeaderInUmbrellaDir()
690 Result->Exports.push_back(Module::ExportDecl(nullptr, true)); in findOrCreateModuleForHeaderInUmbrellaDir()
710 return Known->second; in findAllModulesForHeader()
713 return Headers.find(File)->second; in findAllModulesForHeader()
722 auto It = Headers.find(File); in findResolvedModulesForHeader()
725 return It->second; in findResolvedModulesForHeader()
738 I = Known->second.begin(), in isHeaderUnavailableInModule()
739 E = Known->second.end(); in isHeaderUnavailableInModule()
742 if (I->getRole() == ModuleMap::ExcludedHeader) in isHeaderUnavailableInModule()
745 if (I->isAvailable() && in isHeaderUnavailableInModule()
747 I->getModule()->isSubModuleOf(RequestingModule))) { in isHeaderUnavailableInModule()
753 if (!RequestingModule && I->getRole() == ModuleMap::TextualHeader) in isHeaderUnavailableInModule()
763 StringRef DirName = Dir->getName(); in isHeaderUnavailableInModule()
765 auto IsUnavailable = [&](const Module *M) { in isHeaderUnavailableInModule()
766 return !M->isAvailable() && (!RequestingModule || in isHeaderUnavailableInModule()
767 M->isSubModuleOf(RequestingModule)); in isHeaderUnavailableInModule()
773 auto KnownDir = UmbrellaDirs.find(*Dir); in isHeaderUnavailableInModule()
775 Module *Found = KnownDir->second; in isHeaderUnavailableInModule()
782 while (!UmbrellaModule->getEffectiveUmbrellaDir() && in isHeaderUnavailableInModule()
783 UmbrellaModule->Parent) in isHeaderUnavailableInModule()
784 UmbrellaModule = UmbrellaModule->Parent; in isHeaderUnavailableInModule()
786 if (UmbrellaModule->InferSubmodules) { in isHeaderUnavailableInModule()
829 return Known->getValue(); in findModule()
836 for(; Context; Context = Context->Parent) { in lookupModuleUnqualified()
848 return Context->findSubmodule(Name); in lookupModuleQualified()
873 auto *Result = new Module("<global>", Loc, Parent, /*IsFramework*/ false, in createGlobalModuleFragmentForModuleUnit()
875 Result->Kind = Module::ExplicitGlobalModuleFragment; in createGlobalModuleFragmentForModuleUnit()
878 if (!Result->Parent) in createGlobalModuleFragmentForModuleUnit()
889 // modules. All the non-explicit submodules in clang modules will be exported in createImplicitGlobalModuleFragmentForModuleUnit()
891 auto *Result = in createImplicitGlobalModuleFragmentForModuleUnit()
894 Result->Kind = Module::ImplicitGlobalModuleFragment; in createImplicitGlobalModuleFragmentForModuleUnit()
901 auto *Result = in createPrivateModuleFragmentForInterfaceUnit()
904 Result->Kind = Module::PrivateModuleFragment; in createPrivateModuleFragmentForInterfaceUnit()
910 auto *Result = in createModuleUnitWithKind()
913 Result->Kind = Kind; in createModuleUnitWithKind()
916 for (auto &Submodule : PendingSubmodules) { in createModuleUnitWithKind()
917 Submodule->setParent(Result); in createModuleUnitWithKind()
929 auto *Result = in createModuleForInterfaceUnit()
933 // Mark the main source file as being within the newly-created module so that in createModuleForInterfaceUnit()
934 // declarations and macros are properly visibility-restricted to it. in createModuleForInterfaceUnit()
935 auto MainFile = SourceMgr.getFileEntryRefForID(SourceMgr.getMainFileID()); in createModuleForInterfaceUnit()
946 assert(Modules[Name] && Modules[Name]->Kind == Module::ModuleInterfaceUnit && in createModuleForImplementationUnit()
951 // with any legal user-defined module name). in createModuleForImplementationUnit()
955 auto *Result = in createModuleForImplementationUnit()
971 auto *Result = new Module(Name, Loc, nullptr, /*IsFramework*/ false, in createHeaderUnit()
973 Result->Kind = Module::ModuleHeaderUnit; in createHeaderUnit()
982 assert(Mod->IsFramework && "Can only infer linking for framework modules"); in inferFrameworkLink()
983 assert(!Mod->isSubFramework() && in inferFrameworkLink()
984 "Can only infer linking for top-level frameworks"); in inferFrameworkLink()
986 StringRef FrameworkName(Mod->Name); in inferFrameworkLink()
988 Mod->LinkLibraries.push_back(Module::LinkLibrary(FrameworkName.str(), in inferFrameworkLink()
1003 // top-level framework, and we need to infer as if we were naming the in inferFrameworkModule()
1004 // top-level framework. in inferFrameworkModule()
1008 // In case this is a case-insensitive filesystem, use the canonical in inferFrameworkModule()
1009 // directory name as the ModuleName, since modules are case-sensitive. in inferFrameworkModule()
1010 // FIXME: we should be able to give a fix-it hint for the correct spelling. in inferFrameworkModule()
1030 if (auto ParentDir = FileMgr.getOptionalDirectoryRef(Parent)) { in inferFrameworkModule()
1050 if (inferred->second.InferModules) { in inferFrameworkModule()
1055 !llvm::is_contained(inferred->second.ExcludedModules, Name); in inferFrameworkModule()
1057 Attrs.IsSystem |= inferred->second.Attrs.IsSystem; in inferFrameworkModule()
1058 Attrs.IsExternC |= inferred->second.Attrs.IsExternC; in inferFrameworkModule()
1059 Attrs.IsExhaustive |= inferred->second.Attrs.IsExhaustive; in inferFrameworkModule()
1061 inferred->second.Attrs.NoUndeclaredIncludes; in inferFrameworkModule()
1062 ModuleMapFID = inferred->second.ModuleMapFID; in inferFrameworkModule()
1077 auto UmbrellaHeader = FileMgr.getOptionalFileRef(UmbrellaName); in inferFrameworkModule()
1089 Result->IsInferred = true; in inferFrameworkModule()
1097 Result->IsSystem |= Attrs.IsSystem; in inferFrameworkModule()
1098 Result->IsExternC |= Attrs.IsExternC; in inferFrameworkModule()
1099 Result->ConfigMacrosExhaustive |= Attrs.IsExhaustive; in inferFrameworkModule()
1100 Result->NoUndeclaredIncludes |= Attrs.NoUndeclaredIncludes; in inferFrameworkModule()
1101 Result->Directory = FrameworkDir; in inferFrameworkModule()
1105 Result->getTopLevelModule()->Directory->getName().size()); in inferFrameworkModule()
1108 // umbrella header "umbrella-header-name" in inferFrameworkModule()
1113 Result->Exports.push_back(Module::ExportDecl(nullptr, true)); in inferFrameworkModule()
1116 Result->InferSubmodules = true; in inferFrameworkModule()
1117 Result->InferExportWildcard = true; in inferFrameworkModule()
1129 if (!StringRef(Dir->path()).ends_with(".framework")) in inferFrameworkModule()
1132 if (auto SubframeworkDir = FileMgr.getOptionalDirectoryRef(Dir->path())) { in inferFrameworkModule()
1136 // out to a top-level framework. in inferFrameworkModule()
1147 if (auto SubDir = FileMgr.getDirectory(SubframeworkDirName)) { in inferFrameworkModule()
1163 // If the module is a top-level framework, automatically link against the in inferFrameworkModule()
1165 if (!Result->isSubFramework()) in inferFrameworkModule()
1178 Result->ShadowingModule = ShadowingModule; in createShadowedModule()
1179 Result->markUnavailable(/*Unimportable*/true); in createShadowedModule()
1190 Mod->Umbrella = UmbrellaHeader; in setUmbrellaHeaderAsWritten()
1191 Mod->UmbrellaAsWritten = NameAsWritten.str(); in setUmbrellaHeaderAsWritten()
1192 Mod->UmbrellaRelativeToRootModuleDirectory = in setUmbrellaHeaderAsWritten()
1197 for (const auto &Cb : Callbacks) in setUmbrellaHeaderAsWritten()
1198 Cb->moduleMapAddUmbrellaHeader(UmbrellaHeader); in setUmbrellaHeaderAsWritten()
1204 Mod->Umbrella = UmbrellaDir; in setUmbrellaDirAsWritten()
1205 Mod->UmbrellaAsWritten = NameAsWritten.str(); in setUmbrellaDirAsWritten()
1206 Mod->UmbrellaRelativeToRootModuleDirectory = in setUmbrellaDirAsWritten()
1238 Mod->UnresolvedHeaders.push_back(Header); in addUnresolvedHeader()
1248 auto BySize = LazyHeadersBySize.find(File->getSize()); in resolveHeaderDirectives()
1250 for (auto *M : BySize->second) in resolveHeaderDirectives()
1255 auto ByModTime = LazyHeadersByModTime.find(File->getModificationTime()); in resolveHeaderDirectives()
1257 for (auto *M : ByModTime->second) in resolveHeaderDirectives()
1267 const auto Size = File ? (*File)->getSize() : 0; in resolveHeaderDirectives()
1268 const auto ModTime = File ? (*File)->getModificationTime() : 0; in resolveHeaderDirectives()
1270 for (auto &Header : Mod->UnresolvedHeaders) { in resolveHeaderDirectives()
1277 const_cast<ModuleMap *>(this)->resolveHeader(Mod, Header, NeedsFramework); in resolveHeaderDirectives()
1279 Mod->UnresolvedHeaders.swap(NewHeaders); in resolveHeaderDirectives()
1289 auto &HeaderList = Headers[Header.Entry]; in addHeader()
1294 Mod->Headers[headerRoleToKind(Role)].push_back(Header); in addHeader()
1296 bool isCompilingModuleHeader = Mod->isForBuilding(LangOpts); in addHeader()
1305 for (const auto &Cb : Callbacks) in addHeader()
1306 Cb->moduleMapAddHeader(Header.Entry.getName()); in addHeader()
1310 if (Module->DefinitionLoc.isInvalid()) in getContainingModuleMapFileID()
1313 return SourceMgr.getFileID(Module->DefinitionLoc); in getContainingModuleMapFileID()
1322 if (M->IsInferred) { in getModuleMapFileIDForUniquing()
1324 return InferredModuleAllowedBy.find(M)->second; in getModuleMapFileIDForUniquing()
1335 assert(M->IsInferred && "module not inferred"); in setInferredModuleAllowedBy()
1352 auto DirEntry = FM.getDirectoryRef(Dir.empty() ? "." : Dir); in canonicalizeModuleMapPath()
1362 // on a case-insensitive filesystem. However, the extra canonicalization is in canonicalizeModuleMapPath()
1382 M->getValue()->print(llvm::errs(), 2); in dump()
1387 llvm::errs() << " \"" << H->first.getName() << "\" -> "; in dump()
1388 for (SmallVectorImpl<KnownHeader>::const_iterator I = H->second.begin(), in dump()
1389 E = H->second.end(); in dump()
1391 if (I != H->second.begin()) in dump()
1393 llvm::errs() << I->getModule()->getFullModuleName(); in dump()
1400 auto Unresolved = std::move(Mod->UnresolvedExports); in resolveExports()
1401 Mod->UnresolvedExports.clear(); in resolveExports()
1402 for (auto &UE : Unresolved) { in resolveExports()
1405 Mod->Exports.push_back(Export); in resolveExports()
1407 Mod->UnresolvedExports.push_back(UE); in resolveExports()
1409 return !Mod->UnresolvedExports.empty(); in resolveExports()
1413 auto *Top = Mod->getTopLevelModule(); in resolveUses()
1414 auto Unresolved = std::move(Top->UnresolvedDirectUses); in resolveUses()
1415 Top->UnresolvedDirectUses.clear(); in resolveUses()
1416 for (auto &UDU : Unresolved) { in resolveUses()
1419 Top->DirectUses.push_back(DirectUse); in resolveUses()
1421 Top->UnresolvedDirectUses.push_back(UDU); in resolveUses()
1423 return !Top->UnresolvedDirectUses.empty(); in resolveUses()
1427 auto Unresolved = std::move(Mod->UnresolvedConflicts); in resolveConflicts()
1428 Mod->UnresolvedConflicts.clear(); in resolveConflicts()
1429 for (auto &UC : Unresolved) { in resolveConflicts()
1434 Mod->Conflicts.push_back(Conflict); in resolveConflicts()
1436 Mod->UnresolvedConflicts.push_back(UC); in resolveConflicts()
1438 return !Mod->UnresolvedConflicts.empty(); in resolveConflicts()
1441 //----------------------------------------------------------------------------//
1443 //----------------------------------------------------------------------------//
1555 /// non-modular headers. For backwards compatibility, we continue to
1614 retry: in consumeToken()
1685 goto retry; in consumeToken()
1692 goto retry; in consumeToken()
1718 goto retry; in consumeToken()
1727 goto retry; in consumeToken()
1735 auto NextIsIdent = [&](StringRef Str) -> bool { in consumeToken()
1751 goto retry; in consumeToken()
1781 --braceDepth; in skipUntil()
1788 --squareDepth; in skipUntil()
1803 /// Parse a module-id.
1805 /// module-id:
1807 /// identifier '.' module-id
1859 auto GenNoteAndFixIt = [&](StringRef BadName, StringRef Canonical, in diagnosePrivateModules()
1861 auto D = Diags.Report(ActiveModule->DefinitionLoc, in diagnosePrivateModules()
1863 D << BadName << M->Name; in diagnosePrivateModules()
1867 for (auto E = Map.module_begin(); E != Map.module_end(); ++E) { in diagnosePrivateModules()
1868 auto const *M = E->getValue(); in diagnosePrivateModules()
1869 if (M->Directory != ActiveModule->Directory) in diagnosePrivateModules()
1872 SmallString<128> FullName(ActiveModule->getFullModuleName()); in diagnosePrivateModules()
1873 if (!FullName.starts_with(M->Name) && !FullName.ends_with("Private")) in diagnosePrivateModules()
1876 SmallString<128> Canonical(M->Name); in diagnosePrivateModules()
1879 // Foo.Private -> Foo_Private in diagnosePrivateModules()
1880 if (ActiveModule->Parent && ActiveModule->Name == "Private" && !M->Parent && in diagnosePrivateModules()
1881 M->Name == ActiveModule->Parent->Name) { in diagnosePrivateModules()
1882 Diags.Report(ActiveModule->DefinitionLoc, in diagnosePrivateModules()
1892 if (FrameworkLoc.isValid() || ActiveModule->Parent->IsFramework) in diagnosePrivateModules()
1898 SourceRange(FixItInitBegin, ActiveModule->DefinitionLoc)); in diagnosePrivateModules()
1902 // FooPrivate and whatnots -> Foo_Private in diagnosePrivateModules()
1903 if (!ActiveModule->Parent && !M->Parent && M->Name != ActiveModule->Name && in diagnosePrivateModules()
1904 ActiveModule->Name != Canonical) { in diagnosePrivateModules()
1905 Diags.Report(ActiveModule->DefinitionLoc, in diagnosePrivateModules()
1907 << ActiveModule->Name; in diagnosePrivateModules()
1908 GenNoteAndFixIt(ActiveModule->Name, Canonical, M, in diagnosePrivateModules()
1909 SourceRange(ActiveModule->DefinitionLoc)); in diagnosePrivateModules()
1916 /// module-declaration:
1917 /// 'extern' 'module' module-id string-literal
1918 /// 'explicit'[opt] 'framework'[opt] 'module' module-id attributes[opt]
1919 /// { module-member* }
1921 /// module-member:
1922 /// requires-declaration
1923 /// header-declaration
1924 /// submodule-declaration
1925 /// export-declaration
1926 /// export-as-declaration
1927 /// link-declaration
1929 /// submodule-declaration:
1930 /// module-declaration
1931 /// inferred-submodule-declaration
1988 // Top-level modules can't be explicit. in parseModuleDecl()
2001 for (unsigned I = 0, N = Id.size() - 1; I != N; ++I) { in parseModuleDecl()
2012 ? ActiveModule->getTopLevelModule()->getFullModuleName() in parseModuleDecl()
2022 "top-level module"); in parseModuleDecl()
2050 // - If we loaded one definition from an AST file and we've just found a in parseModuleDecl()
2052 bool LoadedFromASTFile = Existing->IsFromModuleFile; in parseModuleDecl()
2053 // - If we previously inferred this module from different module map file. in parseModuleDecl()
2054 bool Inferred = Existing->IsInferred; in parseModuleDecl()
2055 // - If we're building a framework that vends a module map, we might've in parseModuleDecl()
2070 bool PartOfFramework = Framework || Existing->isPartOfFramework(); in parseModuleDecl()
2071 // - If we're building a (preprocessed) module and we've just loaded the in parseModuleDecl()
2077 SourceMgr.getDecomposedLoc(Existing->DefinitionLoc).first; in parseModuleDecl()
2092 if (!Existing->Parent && Map.mayShadowNewModule(Existing)) { in parseModuleDecl()
2098 Diags.Report(Existing->DefinitionLoc, diag::note_mmap_prev_definition); in parseModuleDecl()
2120 ActiveModule->DefinitionLoc = ModuleNameLoc; in parseModuleDecl()
2122 ActiveModule->IsSystem = true; in parseModuleDecl()
2124 ActiveModule->IsExternC = true; in parseModuleDecl()
2126 ActiveModule->NoUndeclaredIncludes = true; in parseModuleDecl()
2127 ActiveModule->Directory = Directory; in parseModuleDecl()
2130 SourceMgr.getFileEntryRefForID(ModuleMapFID)->getName()); in parseModuleDecl()
2133 ActiveModule->ModuleMapIsPrivate = true; in parseModuleDecl()
2146 ActiveModule->ModuleMapIsPrivate) in parseModuleDecl()
2232 // If the active module is a top-level framework, and there are no link in parseModuleDecl()
2234 if (ActiveModule->IsFramework && !ActiveModule->isSubFramework() && in parseModuleDecl()
2235 ActiveModule->LinkLibraries.empty()) in parseModuleDecl()
2240 if (!ActiveModule->IsAvailable && !ActiveModule->IsUnimportable && in parseModuleDecl()
2241 ActiveModule->Parent) { in parseModuleDecl()
2242 ActiveModule->getTopLevelModule()->markUnavailable(/*Unimportable=*/false); in parseModuleDecl()
2243 ActiveModule->getTopLevelModule()->MissingHeaders.append( in parseModuleDecl()
2244 ActiveModule->MissingHeaders.begin(), ActiveModule->MissingHeaders.end()); in parseModuleDecl()
2253 /// extern module-declaration:
2254 /// 'extern' 'module' module-id string-literal
2291 if (auto File = SourceMgr.getFileManager().getOptionalFileRef(FileNameRef)) in parseExternModuleDecl()
2296 : File->getDir(), in parseExternModuleDecl()
2305 /// 1. The use of 'requires excluded' to make headers non-modular, which
2318 (M->fullModuleNameIs({"Darwin", "C", "excluded"}) || in shouldAddRequirement()
2319 M->fullModuleNameIs({"Tcl", "Private"}))) { in shouldAddRequirement()
2322 } else if (Feature == "cplusplus" && M->fullModuleNameIs({"IOKit", "avc"})) { in shouldAddRequirement()
2331 /// requires-declaration:
2332 /// 'requires' feature-list
2334 /// feature-list:
2335 /// feature ',' feature-list
2346 // Parse the feature-list. in parseRequiresDecl()
2373 ActiveModule->addRequirement(Feature, RequiredState, Map.LangOpts, in parseRequiresDecl()
2387 /// header-declaration:
2388 /// 'textual'[opt] 'header' string-literal
2389 /// 'private' 'textual'[opt] 'header' string-literal
2390 /// 'exclude' 'header' string-literal
2391 /// 'umbrella' 'header' string-literal
2445 !std::holds_alternative<std::monostate>(ActiveModule->Umbrella)) { in parseHeaderDecl()
2447 << ActiveModule->getFullModuleName(); in parseHeaderDecl()
2512 !isBuiltInModuleName(ActiveModule->getTopLevelModuleName()) || in parseHeaderDecl()
2513 ActiveModule->fullModuleNameIs({"_Builtin_stddef", "max_align_t"})) in parseHeaderDecl()
2518 << ActiveModule->getFullModuleName() in parseHeaderDecl()
2529 /// umbrella-dir-declaration:
2530 /// umbrella string-literal
2545 if (!std::holds_alternative<std::monostate>(ActiveModule->Umbrella)) { in parseUmbrellaDirDecl()
2547 << ActiveModule->getFullModuleName(); in parseUmbrellaDirDecl()
2578 for (llvm::vfs::recursive_directory_iterator I(FS, Dir->getName(), EC), E; in parseUmbrellaDirDecl()
2580 if (auto FE = SourceMgr.getFileManager().getOptionalFileRef(I->path())) { in parseUmbrellaDirDecl()
2581 Module::Header Header = {"", std::string(I->path()), *FE}; in parseUmbrellaDirDecl()
2589 for (auto &Header : Headers) in parseUmbrellaDirDecl()
2596 << OwningModule->getFullModuleName(); in parseUmbrellaDirDecl()
2607 /// export-declaration:
2608 /// 'export' wildcard-module-id
2610 /// wildcard-module-id:
2613 /// identifier '.' wildcard-module-id
2618 // Parse the module-id with an optional wildcard at the end. in parseExportDecl()
2622 // FIXME: Support string-literal module names here. in parseExportDecl()
2650 ActiveModule->UnresolvedExports.push_back(Unresolved); in parseExportDecl()
2655 /// export-as-declaration:
2667 if (ActiveModule->Parent) { in parseExportAsDecl()
2673 if (!ActiveModule->ExportAsModule.empty()) { in parseExportAsDecl()
2674 if (ActiveModule->ExportAsModule == Tok.getString()) { in parseExportAsDecl()
2676 << ActiveModule->Name << Tok.getString(); in parseExportAsDecl()
2679 << ActiveModule->Name << ActiveModule->ExportAsModule in parseExportAsDecl()
2684 ActiveModule->ExportAsModule = std::string(Tok.getString()); in parseExportAsDecl()
2692 /// use-declaration:
2693 /// 'use' wildcard-module-id
2696 auto KWLoc = consumeToken(); in parseUseDecl()
2697 // Parse the module-id. in parseUseDecl()
2701 if (ActiveModule->Parent) in parseUseDecl()
2704 ActiveModule->UnresolvedDirectUses.push_back(ParsedModuleId); in parseUseDecl()
2709 /// module-declaration:
2710 /// 'link' 'framework'[opt] string-literal
2732 ActiveModule->LinkLibraries.push_back(Module::LinkLibrary(LibraryName, in parseLinkDecl()
2738 /// module-declaration:
2739 /// 'config_macros' attributes[opt] config-macro-list?
2741 /// config-macro-list:
2747 // Only top-level modules can have configuration macros. in parseConfigMacros()
2748 if (ActiveModule->Parent) { in parseConfigMacros()
2757 if (Attrs.IsExhaustive && !ActiveModule->Parent) { in parseConfigMacros()
2758 ActiveModule->ConfigMacrosExhaustive = true; in parseConfigMacros()
2767 if (!ActiveModule->Parent) { in parseConfigMacros()
2768 ActiveModule->ConfigMacros.push_back(Tok.getString().str()); in parseConfigMacros()
2786 if (!ActiveModule->Parent) { in parseConfigMacros()
2787 ActiveModule->ConfigMacros.push_back(Tok.getString().str()); in parseConfigMacros()
2793 /// Format a module-id into a string.
2811 /// module-declaration:
2812 /// 'conflict' module-id ',' string-literal
2818 // Parse the module-id. in parseConflict()
2840 ActiveModule->UnresolvedConflicts.push_back(Conflict); in parseConflict()
2845 /// module-declaration:
2847 /// { inferred-module-member* }
2849 /// inferred-module-member:
2865 if (!Failed && ActiveModule->IsAvailable && in parseInferredModuleDecl()
2866 !ActiveModule->getEffectiveUmbrellaDir()) { in parseInferredModuleDecl()
2872 if (!Failed && ActiveModule->InferSubmodules) { in parseInferredModuleDecl()
2874 if (ActiveModule->InferredSubmoduleLoc.isValid()) in parseInferredModuleDecl()
2875 Diags.Report(ActiveModule->InferredSubmoduleLoc, in parseInferredModuleDecl()
2909 ActiveModule->InferSubmodules = true; in parseInferredModuleDecl()
2910 ActiveModule->InferredSubmoduleLoc = StarLoc; in parseInferredModuleDecl()
2911 ActiveModule->InferExplicitSubmodules = Explicit; in parseInferredModuleDecl()
2946 // FIXME: Support string-literal module names here. in parseInferredModuleDecl()
2967 ActiveModule->InferExportWildcard = true; in parseInferredModuleDecl()
3073 /// module-map-file:
3074 /// module-declaration*
3127 return Known->second; in parseModuleMapFile()
3131 auto FileCharacter = in parseModuleMapFile()
3140 assert((!Offset || *Offset <= Buffer->getBufferSize()) && in parseModuleMapFile()
3145 Buffer->getBufferStart(), in parseModuleMapFile()
3146 Buffer->getBufferStart() + (Offset ? *Offset : 0), in parseModuleMapFile()
3147 Buffer->getBufferEnd()); in parseModuleMapFile()
3154 auto Loc = SourceMgr.getDecomposedLoc(Parser.getLocation()); in parseModuleMapFile()
3160 for (const auto &Cb : Callbacks) in parseModuleMapFile()
3161 Cb->moduleMapFileRead(Start, File, IsSystem); in parseModuleMapFile()