@@ -1051,7 +1051,7 @@ Module *ModuleMap::inferFrameworkModule(DirectoryEntryRef FrameworkDir,
10511051 bool IsFrameworkDir = Parent.ends_with (" .framework" );
10521052 if (OptionalFileEntryRef ModMapFile =
10531053 HeaderInfo.lookupModuleMapFile (*ParentDir, IsFrameworkDir)) {
1054- parseModuleMapFile (*ModMapFile, Attrs.IsSystem , *ParentDir);
1054+ loadModuleMapFile (*ModMapFile, Attrs.IsSystem , *ParentDir);
10551055 inferred = InferredDirectories.find (*ParentDir);
10561056 }
10571057
@@ -1354,7 +1354,7 @@ std::error_code
13541354ModuleMap::canonicalizeModuleMapPath (SmallVectorImpl<char > &Path) {
13551355 StringRef Dir = llvm::sys::path::parent_path ({Path.data (), Path.size ()});
13561356
1357- // Do not canonicalize within the framework; the module map parser expects
1357+ // Do not canonicalize within the framework; the module map loader expects
13581358 // Modules/ not Versions/A/Modules.
13591359 if (llvm::sys::path::filename (Dir) == " Modules" ) {
13601360 StringRef Parent = llvm::sys::path::parent_path (Dir);
@@ -1453,11 +1453,11 @@ bool ModuleMap::resolveConflicts(Module *Mod, bool Complain) {
14531453}
14541454
14551455// ----------------------------------------------------------------------------//
1456- // Module map file parser
1456+ // Module map file loader
14571457// ----------------------------------------------------------------------------//
14581458
14591459namespace clang {
1460- class ModuleMapParser {
1460+ class ModuleMapLoader {
14611461 modulemap::ModuleMapFile &MMF;
14621462 SourceManager &SourceMgr;
14631463
@@ -1467,7 +1467,7 @@ class ModuleMapParser {
14671467 // / The current module map file.
14681468 FileID ModuleMapFID;
14691469
1470- // / Source location of most recent parsed module declaration
1470+ // / Source location of most recent loaded module declaration
14711471 SourceLocation CurrModuleDeclLoc;
14721472
14731473 // / The directory that file names in this module map file should
@@ -1515,13 +1515,13 @@ class ModuleMapParser {
15151515 using Attributes = ModuleMap::Attributes;
15161516
15171517public:
1518- ModuleMapParser (modulemap::ModuleMapFile &MMF, SourceManager &SourceMgr,
1518+ ModuleMapLoader (modulemap::ModuleMapFile &MMF, SourceManager &SourceMgr,
15191519 DiagnosticsEngine &Diags, ModuleMap &Map, FileID ModuleMapFID,
15201520 DirectoryEntryRef Directory, bool IsSystem)
15211521 : MMF(MMF), SourceMgr(SourceMgr), Diags(Diags), Map(Map),
15221522 ModuleMapFID (ModuleMapFID), Directory(Directory), IsSystem(IsSystem) {}
15231523
1524- bool parseModuleMapFile ();
1524+ bool loadModuleMapFile ();
15251525};
15261526
15271527} // namespace clang
@@ -1530,7 +1530,7 @@ class ModuleMapParser {
15301530// / module map search logic to find the appropriate private module when PCH
15311531// / is used with implicit module maps. Warn when private modules are written
15321532// / in other ways (FooPrivate and Foo.Private), providing notes and fixits.
1533- void ModuleMapParser ::diagnosePrivateModules (SourceLocation StartLoc) {
1533+ void ModuleMapLoader ::diagnosePrivateModules (SourceLocation StartLoc) {
15341534 auto GenNoteAndFixIt = [&](StringRef BadName, StringRef Canonical,
15351535 const Module *M, SourceRange ReplLoc) {
15361536 auto D = Diags.Report (ActiveModule->DefinitionLoc ,
@@ -1584,7 +1584,7 @@ void ModuleMapParser::diagnosePrivateModules(SourceLocation StartLoc) {
15841584 }
15851585}
15861586
1587- void ModuleMapParser ::handleModuleDecl (const modulemap::ModuleDecl &MD) {
1587+ void ModuleMapLoader ::handleModuleDecl (const modulemap::ModuleDecl &MD) {
15881588 if (MD.Id .front ().first == " *" )
15891589 return handleInferredModuleDecl (MD);
15901590
@@ -1763,7 +1763,7 @@ void ModuleMapParser::handleModuleDecl(const modulemap::ModuleDecl &MD) {
17631763 ActiveModule = PreviousActiveModule;
17641764}
17651765
1766- void ModuleMapParser ::handleExternModuleDecl (
1766+ void ModuleMapLoader ::handleExternModuleDecl (
17671767 const modulemap::ExternModuleDecl &EMD) {
17681768 StringRef FileNameRef = EMD.Path ;
17691769 SmallString<128 > ModuleMapFileName;
@@ -1773,7 +1773,7 @@ void ModuleMapParser::handleExternModuleDecl(
17731773 FileNameRef = ModuleMapFileName;
17741774 }
17751775 if (auto File = SourceMgr.getFileManager ().getOptionalFileRef (FileNameRef))
1776- Map.parseModuleMapFile (
1776+ Map.loadModuleMapFile (
17771777 *File, IsSystem,
17781778 Map.HeaderInfo .getHeaderSearchOpts ().ModuleMapFileHomeIsCwd
17791779 ? Directory
@@ -1810,7 +1810,7 @@ static bool shouldAddRequirement(Module *M, StringRef Feature,
18101810 return true ;
18111811}
18121812
1813- void ModuleMapParser ::handleRequiresDecl (const modulemap::RequiresDecl &RD) {
1813+ void ModuleMapLoader ::handleRequiresDecl (const modulemap::RequiresDecl &RD) {
18141814
18151815 for (const modulemap::RequiresFeature &RF : RD.Features ) {
18161816 bool IsRequiresExcludedHack = false ;
@@ -1828,7 +1828,7 @@ void ModuleMapParser::handleRequiresDecl(const modulemap::RequiresDecl &RD) {
18281828 }
18291829}
18301830
1831- void ModuleMapParser ::handleHeaderDecl (const modulemap::HeaderDecl &HD) {
1831+ void ModuleMapLoader ::handleHeaderDecl (const modulemap::HeaderDecl &HD) {
18321832 // We've already consumed the first token.
18331833 ModuleMap::ModuleHeaderRole Role = ModuleMap::NormalHeader;
18341834
@@ -1887,7 +1887,7 @@ static bool compareModuleHeaders(const Module::Header &A,
18871887 return A.NameAsWritten < B.NameAsWritten ;
18881888}
18891889
1890- void ModuleMapParser ::handleUmbrellaDirDecl (
1890+ void ModuleMapLoader ::handleUmbrellaDirDecl (
18911891 const modulemap::UmbrellaDirDecl &UDD) {
18921892 std::string DirName = std::string (UDD.Path );
18931893 std::string DirNameAsWritten = DirName;
@@ -1919,7 +1919,7 @@ void ModuleMapParser::handleUmbrellaDirDecl(
19191919
19201920 if (UsesRequiresExcludedHack.count (ActiveModule)) {
19211921 // Mark this header 'textual' (see doc comment for
1922- // ModuleMapParser ::UsesRequiresExcludedHack). Although iterating over the
1922+ // ModuleMapLoader ::UsesRequiresExcludedHack). Although iterating over the
19231923 // directory is relatively expensive, in practice this only applies to the
19241924 // uncommonly used Tcl module on Darwin platforms.
19251925 std::error_code EC;
@@ -1953,12 +1953,12 @@ void ModuleMapParser::handleUmbrellaDirDecl(
19531953 Map.setUmbrellaDirAsWritten (ActiveModule, *Dir, DirNameAsWritten, DirName);
19541954}
19551955
1956- void ModuleMapParser ::handleExportDecl (const modulemap::ExportDecl &ED) {
1956+ void ModuleMapLoader ::handleExportDecl (const modulemap::ExportDecl &ED) {
19571957 Module::UnresolvedExportDecl Unresolved = {ED.Location , ED.Id , ED.Wildcard };
19581958 ActiveModule->UnresolvedExports .push_back (Unresolved);
19591959}
19601960
1961- void ModuleMapParser ::handleExportAsDecl (const modulemap::ExportAsDecl &EAD) {
1961+ void ModuleMapLoader ::handleExportAsDecl (const modulemap::ExportAsDecl &EAD) {
19621962 auto ModName = EAD.Id .front ();
19631963
19641964 if (!ActiveModule->ExportAsModule .empty ()) {
@@ -1976,19 +1976,19 @@ void ModuleMapParser::handleExportAsDecl(const modulemap::ExportAsDecl &EAD) {
19761976 Map.addLinkAsDependency (ActiveModule);
19771977}
19781978
1979- void ModuleMapParser ::handleUseDecl (const modulemap::UseDecl &UD) {
1979+ void ModuleMapLoader ::handleUseDecl (const modulemap::UseDecl &UD) {
19801980 if (ActiveModule->Parent )
19811981 Diags.Report (UD.Location , diag::err_mmap_use_decl_submodule);
19821982 else
19831983 ActiveModule->UnresolvedDirectUses .push_back (UD.Id );
19841984}
19851985
1986- void ModuleMapParser ::handleLinkDecl (const modulemap::LinkDecl &LD) {
1986+ void ModuleMapLoader ::handleLinkDecl (const modulemap::LinkDecl &LD) {
19871987 ActiveModule->LinkLibraries .push_back (
19881988 Module::LinkLibrary (std::string{LD.Library }, LD.Framework ));
19891989}
19901990
1991- void ModuleMapParser ::handleConfigMacros (
1991+ void ModuleMapLoader ::handleConfigMacros (
19921992 const modulemap::ConfigMacrosDecl &CMD) {
19931993 if (ActiveModule->Parent ) {
19941994 Diags.Report (CMD.Location , diag::err_mmap_config_macro_submodule);
@@ -2004,7 +2004,7 @@ void ModuleMapParser::handleConfigMacros(
20042004 CMD.Macros .begin (), CMD.Macros .end ());
20052005}
20062006
2007- void ModuleMapParser ::handleConflict (const modulemap::ConflictDecl &CD) {
2007+ void ModuleMapLoader ::handleConflict (const modulemap::ConflictDecl &CD) {
20082008 Module::UnresolvedConflict Conflict;
20092009
20102010 Conflict.Id = CD.Id ;
@@ -2013,7 +2013,7 @@ void ModuleMapParser::handleConflict(const modulemap::ConflictDecl &CD) {
20132013 ActiveModule->UnresolvedConflicts .push_back (Conflict);
20142014}
20152015
2016- void ModuleMapParser ::handleInferredModuleDecl (
2016+ void ModuleMapLoader ::handleInferredModuleDecl (
20172017 const modulemap::ModuleDecl &MD) {
20182018 SourceLocation StarLoc = MD.Id .front ().second ;
20192019
@@ -2103,7 +2103,7 @@ void ModuleMapParser::handleInferredModuleDecl(
21032103 }
21042104}
21052105
2106- bool ModuleMapParser::parseModuleMapFile () {
2106+ bool ModuleMapLoader::loadModuleMapFile () {
21072107 for (const auto &Decl : MMF.Decls ) {
21082108 std::visit (
21092109 llvm::makeVisitor (
@@ -2116,14 +2116,14 @@ bool ModuleMapParser::parseModuleMapFile() {
21162116 return HadError;
21172117}
21182118
2119- bool ModuleMap::parseModuleMapFile (FileEntryRef File, bool IsSystem,
2120- DirectoryEntryRef Dir, FileID ID,
2121- unsigned *Offset,
2122- SourceLocation ExternModuleLoc) {
2119+ bool ModuleMap::loadModuleMapFile (FileEntryRef File, bool IsSystem,
2120+ DirectoryEntryRef Dir, FileID ID,
2121+ unsigned *Offset,
2122+ SourceLocation ExternModuleLoc) {
21232123 assert (Target && " Missing target information" );
2124- llvm::DenseMap<const FileEntry *, bool >::iterator Known
2125- = ParsedModuleMap .find (File);
2126- if (Known != ParsedModuleMap .end ())
2124+ llvm::DenseMap<const FileEntry *, bool >::iterator Known =
2125+ LoadedModuleMap .find (File);
2126+ if (Known != LoadedModuleMap .end ())
21272127 return Known->second ;
21282128
21292129 // If the module map file wasn't already entered, do so now.
@@ -2136,20 +2136,21 @@ bool ModuleMap::parseModuleMapFile(FileEntryRef File, bool IsSystem,
21362136 assert (Target && " Missing target information" );
21372137 std::optional<llvm::MemoryBufferRef> Buffer = SourceMgr.getBufferOrNone (ID);
21382138 if (!Buffer)
2139- return ParsedModuleMap [File] = true ;
2139+ return LoadedModuleMap [File] = true ;
21402140 assert ((!Offset || *Offset <= Buffer->getBufferSize ()) &&
21412141 " invalid buffer offset" );
21422142
21432143 std::optional<modulemap::ModuleMapFile> MMF =
21442144 modulemap::parseModuleMap (ID, Dir, SourceMgr, Diags, IsSystem, Offset);
21452145 bool Result = false ;
21462146 if (MMF) {
2147- ModuleMapParser Parser (*MMF, SourceMgr, Diags, *this , ID, Dir, IsSystem);
2148- Result = Parser. parseModuleMapFile ();
2147+ ModuleMapLoader Loader (*MMF, SourceMgr, Diags, *this , ID, Dir, IsSystem);
2148+ Result = Loader. loadModuleMapFile ();
21492149 }
2150- ParsedModuleMap [File] = Result;
2150+ LoadedModuleMap [File] = Result;
21512151
2152- // Notify callbacks that we parsed it.
2152+ // Notify callbacks that we observed it.
2153+ // FIXME: We should only report module maps that were actually used.
21532154 for (const auto &Cb : Callbacks)
21542155 Cb->moduleMapFileRead (MMF ? MMF->Start : SourceLocation (), File, IsSystem);
21552156
0 commit comments