Lines Matching +full:path +full:- +full:map

1 //===- ModuleMap.cpp - Describe the layout of modules ---------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 //===----------------------------------------------------------------------===//
42 #include "llvm/Support/Path.h"
59 auto PendingLinkAs = PendingLinkAsModule.find(Mod->Name); in resolveLinkAsDependencies()
61 for (auto &Name : PendingLinkAs->second) { 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()
143 // Dig into the module path. in resolveModuleId()
149 << Id[I].first << Context->getFullModuleName() in resolveModuleId()
150 << SourceRange(Id[0].second, Id[I-1].second); in resolveModuleId()
164 SmallVectorImpl<char> &Path) { in appendSubframeworkPaths() argument
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()
177 llvm::sys::path::append(Path, "Frameworks", Framework + ".framework"); 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()
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()
202 llvm::sys::path::append(RelativePathName, "Headers", Header.FileName); in findHeader()
203 llvm::sys::path::append(FullPathName, RelativePathName); in findHeader()
212 // for private modules, make sure we find the right path in both cases. in findHeader()
213 if (M->IsFramework && M->Name == "Private") in findHeader()
218 llvm::sys::path::append(RelativePathName, "PrivateHeaders", in findHeader()
220 llvm::sys::path::append(FullPathName, RelativePathName); in findHeader()
224 if (llvm::sys::path::is_absolute(Header.FileName)) { in findHeader()
230 if (M->isPartOfFramework()) in findHeader()
234 llvm::sys::path::append(RelativePathName, Header.FileName); in findHeader()
235 llvm::sys::path::append(FullPathName, RelativePathName); in findHeader()
238 if (!NormalHdrFile && Directory->getName().ends_with(".framework")) { in findHeader()
241 // framework style path. 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()
336 llvm::sys::path::is_absolute(Header.FileName) || in resolveAsBuiltinHeader()
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()
345 SmallString<128> Path; in resolveAsBuiltinHeader() local
346 llvm::sys::path::append(Path, BuiltinIncludeDir->getName(), Header.FileName); in resolveAsBuiltinHeader()
347 auto File = SourceMgr.getFileManager().getOptionalFileRef(Path); in resolveAsBuiltinHeader()
373 assert((!this->Target || this->Target == &Target) && in setTarget()
375 this->Target = &Target; in setTarget()
417 isBuiltinHeaderName(llvm::sys::path::filename(File.getName())); in isBuiltinHeader()
423 Module->IsSystem && !Module->isPartOfFramework() && in shouldImportRelativeToBuiltinIncludeDir()
445 // Note: as an egregious but useful hack we use the real path here, because in findHeaderInUmbrellaDirs()
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()
456 return KnownHeader(KnownDir->second, NormalHeader); in findHeaderInUmbrellaDirs()
460 // Retrieve our parent path. in findHeaderInUmbrellaDirs()
461 DirName = llvm::sys::path::parent_path(DirName); in findHeaderInUmbrellaDirs()
465 // Resolve the parent path to a directory entry. in findHeaderInUmbrellaDirs()
481 &Header.getModule()->Headers[Module::HK_Private], in violatesPrivateInclude()
482 &Header.getModule()->Headers[Module::HK_PrivateTextual]}; 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()
662 llvm::sys::path::stem(SkippedDir.getName()), NameBuf); 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()
680 llvm::sys::path::stem(File.getName()), NameBuf); 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()
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()
749 // header is part a module by only looking into the module map. This is in isHeaderUnavailableInModule()
753 if (!RequestingModule && I->getRole() == ModuleMap::TextualHeader) in isHeaderUnavailableInModule()
763 StringRef DirName = Dir->getName(); in isHeaderUnavailableInModule()
766 return !M->isAvailable() && (!RequestingModule || in isHeaderUnavailableInModule()
767 M->isSubModuleOf(RequestingModule)); 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()
791 llvm::sys::path::stem(SkippedDir.getName()), NameBuf); in isHeaderUnavailableInModule()
802 llvm::sys::path::stem(Header.getName()), in isHeaderUnavailableInModule()
814 // Retrieve our parent path. in isHeaderUnavailableInModule()
815 DirName = llvm::sys::path::parent_path(DirName); in isHeaderUnavailableInModule()
819 // Resolve the parent path to a directory entry. in isHeaderUnavailableInModule()
829 return Known->getValue(); in findModule()
836 for(; Context; Context = Context->Parent) { in lookupModuleUnqualified()
848 return Context->findSubmodule(Name); in lookupModuleQualified()
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()
894 Result->Kind = Module::ImplicitGlobalModuleFragment; in createImplicitGlobalModuleFragmentForModuleUnit()
904 Result->Kind = Module::PrivateModuleFragment; in createPrivateModuleFragmentForInterfaceUnit()
913 Result->Kind = Kind; in createModuleUnitWithKind()
917 Submodule->setParent(Result); in createModuleUnitWithKind()
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()
946 assert(Modules[Name] && Modules[Name]->Kind == Module::ModuleInterfaceUnit && in createModuleForImplementationUnit()
949 // Create an entry in the modules map to own the implementation unit module. in createModuleForImplementationUnit()
951 // with any legal user-defined module name). in createModuleForImplementationUnit()
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()
1001 // Note: as an egregious but useful hack we use the real path here, because in inferFrameworkModule()
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()
1013 llvm::sys::path::stem(FrameworkDirName), ModuleNameStorage); in inferFrameworkModule()
1021 // If the framework has a parent path from which we're allowed to infer in inferFrameworkModule()
1025 // Determine whether we're allowed to infer a module map. in inferFrameworkModule()
1027 if (llvm::sys::path::has_parent_path(FrameworkDirName)) { in inferFrameworkModule()
1028 // Figure out the parent path. in inferFrameworkModule()
1029 StringRef Parent = llvm::sys::path::parent_path(FrameworkDirName); in inferFrameworkModule()
1032 // for a module map. in inferFrameworkModule()
1036 // We haven't looked here before. Load a module map, if there is in inferFrameworkModule()
1050 if (inferred->second.InferModules) { in inferFrameworkModule()
1053 StringRef Name = llvm::sys::path::stem(FrameworkDirName); 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()
1076 llvm::sys::path::append(UmbrellaName, "Headers", ModuleName + ".h"); 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()
1106 RelativePath = llvm::sys::path::relative_path(RelativePath); 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()
1122 llvm::sys::path::append(SubframeworksDirName, "Frameworks"); in inferFrameworkModule()
1123 llvm::sys::path::native(SubframeworksDirName); in inferFrameworkModule()
1129 if (!StringRef(Dir->path()).ends_with(".framework")) in inferFrameworkModule()
1132 if (auto SubframeworkDir = FileMgr.getOptionalDirectoryRef(Dir->path())) { in inferFrameworkModule()
1133 // Note: as an egregious but useful hack, we use the real path here and in inferFrameworkModule()
1136 // out to a top-level framework. in inferFrameworkModule()
1143 = llvm::sys::path::parent_path(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()
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()
1294 Mod->Headers[headerRoleToKind(Role)].push_back(Header); in addHeader()
1296 bool isCompilingModuleHeader = Mod->isForBuilding(LangOpts); 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()
1323 assert(InferredModuleAllowedBy.count(M) && "missing inferred module map"); in getModuleMapFileIDForUniquing()
1324 return InferredModuleAllowedBy.find(M)->second; in getModuleMapFileIDForUniquing()
1335 assert(M->IsInferred && "module not inferred"); in setInferredModuleAllowedBy()
1340 ModuleMap::canonicalizeModuleMapPath(SmallVectorImpl<char> &Path) { in canonicalizeModuleMapPath() argument
1341 StringRef Dir = llvm::sys::path::parent_path({Path.data(), Path.size()}); in canonicalizeModuleMapPath()
1343 // Do not canonicalize within the framework; the module map parser expects in canonicalizeModuleMapPath()
1345 if (llvm::sys::path::filename(Dir) == "Modules") { in canonicalizeModuleMapPath()
1346 StringRef Parent = llvm::sys::path::parent_path(Dir); in canonicalizeModuleMapPath()
1359 llvm::sys::path::replace_path_prefix(Path, Dir, CanonicalDir); in canonicalizeModuleMapPath()
1362 // on a case-insensitive filesystem. However, the extra canonicalization is in canonicalizeModuleMapPath()
1367 llvm::sys::path::remove_dots(Path); 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()
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()
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()
1434 Mod->Conflicts.push_back(Conflict); in resolveConflicts()
1436 Mod->UnresolvedConflicts.push_back(UC); in resolveConflicts()
1438 return !Mod->UnresolvedConflicts.empty(); in resolveConflicts()
1441 //----------------------------------------------------------------------------//
1442 // Module map file parser
1443 //----------------------------------------------------------------------------//
1447 /// A token in a module map file.
1522 ModuleMap &Map; member in clang::ModuleMapParser
1524 /// The current module map file.
1530 /// The directory that file names in this module map file should
1534 /// Whether this module map is in a system header directory.
1555 /// non-modular headers. For backwards compatibility, we continue to
1556 /// support this idiom for just these modules, and map the headers to
1582 /// module map search logic to find the appropriate private module when PCH
1595 ModuleMap &Map, FileID ModuleMapFID, in ModuleMapParser() argument
1597 : L(L), SourceMgr(SourceMgr), Target(Target), Diags(Diags), Map(Map), in ModuleMapParser()
1713 Lexer::getSpelling(LToken, Start, SourceMgr, Map.LangOpts); in consumeToken()
1730 // A module map can be terminated prematurely by in consumeToken()
1735 auto NextIsIdent = [&](StringRef Str) -> bool { in consumeToken()
1781 --braceDepth; in skipUntil()
1788 --squareDepth; in skipUntil()
1803 /// Parse a module-id.
1805 /// module-id:
1807 /// identifier '.' module-id
1854 /// module map search logic to find the appropriate private module when PCH
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()
1997 // This module map defines a submodule. Go find the module of which it in parseModuleDecl()
2001 for (unsigned I = 0, N = Id.size() - 1; I != N; ++I) { in parseModuleDecl()
2002 if (Module *Next = Map.lookupModuleQualified(Id[I].first, ActiveModule)) { in parseModuleDecl()
2012 ? ActiveModule->getTopLevelModule()->getFullModuleName() in parseModuleDecl()
2018 ModuleMapFID != Map.getContainingModuleMapFileID(TopLevelModule)) { in parseModuleDecl()
2020 Map.getModuleMapFileIDForUniquing(TopLevelModule) && in parseModuleDecl()
2022 "top-level module"); in parseModuleDecl()
2023 Map.addAdditionalModuleMapFile( in parseModuleDecl()
2047 if (Module *Existing = Map.lookupModuleQualified(ModuleName, ActiveModule)) { in parseModuleDecl()
2050 // - If we loaded one definition from an AST file and we've just found a in parseModuleDecl()
2051 // corresponding definition in a module map file, or 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()
2058 // FIXME: If we're parsing module map file that looks like this: 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()
2072 // module map file from which it was created. in parseModuleDecl()
2074 Map.LangOpts.getCompilingModule() == LangOptions::CMK_ModuleMap && in parseModuleDecl()
2075 Map.LangOpts.CurrentModule == ModuleName && 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()
2113 Map.createShadowedModule(ModuleName, Framework, ShadowingModule); in parseModuleDecl()
2116 Map.findOrCreateModule(ModuleName, ActiveModule, Framework, Explicit) 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()
2132 MapFileName.ends_with("module_private.map")) { in parseModuleDecl()
2133 ActiveModule->ModuleMapIsPrivate = true; in parseModuleDecl()
2141 if (Map.HeaderInfo.getHeaderSearchOpts().ImplicitModuleMaps && 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
2275 // Parse the referenced module map file name. in parseExternModuleDecl()
2286 if (llvm::sys::path::is_relative(FileNameRef)) { in parseExternModuleDecl()
2288 llvm::sys::path::append(ModuleMapFileName, FileName); in parseExternModuleDecl()
2292 Map.parseModuleMapFile( in parseExternModuleDecl()
2294 Map.HeaderInfo.getHeaderSearchOpts().ModuleMapFileHomeIsCwd in parseExternModuleDecl()
2296 : File->getDir(), in parseExternModuleDecl()
2303 /// module map files:
2305 /// 1. The use of 'requires excluded' to make headers non-modular, which
2308 /// true. Later, this bit will be used to map all the headers inside this
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()
2374 *Map.Target); 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
2441 Header.Kind = Map.headerRoleToKind(Role); in parseHeaderDecl()
2445 !std::holds_alternative<std::monostate>(ActiveModule->Umbrella)) { in parseHeaderDecl()
2447 << ActiveModule->getFullModuleName(); in parseHeaderDecl()
2511 if (!Map.LangOpts.BuiltinHeadersInSystemModules || in parseHeaderDecl()
2512 !isBuiltInModuleName(ActiveModule->getTopLevelModuleName()) || in parseHeaderDecl()
2513 ActiveModule->fullModuleNameIs({"_Builtin_stddef", "max_align_t"})) in parseHeaderDecl()
2514 Map.addUnresolvedHeader(ActiveModule, std::move(Header), NeedsFramework); 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()
2554 if (llvm::sys::path::is_absolute(DirName)) { in parseUmbrellaDirDecl()
2559 llvm::sys::path::append(PathName, DirName); 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()
2590 Map.addHeader(ActiveModule, std::move(Header), ModuleMap::TextualHeader); in parseUmbrellaDirDecl()
2594 if (Module *OwningModule = Map.UmbrellaDirs[*Dir]) { in parseUmbrellaDirDecl()
2596 << OwningModule->getFullModuleName(); in parseUmbrellaDirDecl()
2602 Map.setUmbrellaDirAsWritten(ActiveModule, *Dir, DirNameAsWritten, DirName); 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()
2685 Map.addLinkAsDependency(ActiveModule); in parseExportAsDecl()
2692 /// use-declaration:
2693 /// 'use' wildcard-module-id
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()
2914 Map.InferredDirectories[Directory].InferModules = true; in parseInferredModuleDecl()
2915 Map.InferredDirectories[Directory].Attrs = Attrs; in parseInferredModuleDecl()
2916 Map.InferredDirectories[Directory].ModuleMapFID = ModuleMapFID; in parseInferredModuleDecl()
2946 // FIXME: Support string-literal module names here. in parseInferredModuleDecl()
2952 Map.InferredDirectories[Directory].ExcludedModules.push_back( in parseInferredModuleDecl()
2967 ActiveModule->InferExportWildcard = true; in parseInferredModuleDecl()
3071 /// Parse a module map file.
3073 /// module-map-file:
3074 /// module-declaration*
3127 return Known->second; in parseModuleMapFile()
3129 // If the module map file wasn't already entered, do so now. in parseModuleMapFile()
3140 assert((!Offset || *Offset <= Buffer->getBufferSize()) && in parseModuleMapFile()
3143 // Parse this module map file. in parseModuleMapFile()
3145 Buffer->getBufferStart(), in parseModuleMapFile()
3146 Buffer->getBufferStart() + (Offset ? *Offset : 0), in parseModuleMapFile()
3147 Buffer->getBufferEnd()); in parseModuleMapFile()
3161 Cb->moduleMapFileRead(Start, File, IsSystem); in parseModuleMapFile()