@@ -1051,7 +1051,7 @@ Module *ModuleMap::inferFrameworkModule(DirectoryEntryRef FrameworkDir,
1051
1051
bool IsFrameworkDir = Parent.ends_with (" .framework" );
1052
1052
if (OptionalFileEntryRef ModMapFile =
1053
1053
HeaderInfo.lookupModuleMapFile (*ParentDir, IsFrameworkDir)) {
1054
- parseModuleMapFile (*ModMapFile, Attrs.IsSystem , *ParentDir);
1054
+ loadModuleMapFile (*ModMapFile, Attrs.IsSystem , *ParentDir);
1055
1055
inferred = InferredDirectories.find (*ParentDir);
1056
1056
}
1057
1057
@@ -1354,7 +1354,7 @@ std::error_code
1354
1354
ModuleMap::canonicalizeModuleMapPath (SmallVectorImpl<char > &Path) {
1355
1355
StringRef Dir = llvm::sys::path::parent_path ({Path.data (), Path.size ()});
1356
1356
1357
- // Do not canonicalize within the framework; the module map parser expects
1357
+ // Do not canonicalize within the framework; the module map loader expects
1358
1358
// Modules/ not Versions/A/Modules.
1359
1359
if (llvm::sys::path::filename (Dir) == " Modules" ) {
1360
1360
StringRef Parent = llvm::sys::path::parent_path (Dir);
@@ -1453,11 +1453,11 @@ bool ModuleMap::resolveConflicts(Module *Mod, bool Complain) {
1453
1453
}
1454
1454
1455
1455
// ----------------------------------------------------------------------------//
1456
- // Module map file parser
1456
+ // Module map file loader
1457
1457
// ----------------------------------------------------------------------------//
1458
1458
1459
1459
namespace clang {
1460
- class ModuleMapParser {
1460
+ class ModuleMapLoader {
1461
1461
modulemap::ModuleMapFile &MMF;
1462
1462
SourceManager &SourceMgr;
1463
1463
@@ -1467,7 +1467,7 @@ class ModuleMapParser {
1467
1467
// / The current module map file.
1468
1468
FileID ModuleMapFID;
1469
1469
1470
- // / Source location of most recent parsed module declaration
1470
+ // / Source location of most recent loaded module declaration
1471
1471
SourceLocation CurrModuleDeclLoc;
1472
1472
1473
1473
// / The directory that file names in this module map file should
@@ -1515,13 +1515,13 @@ class ModuleMapParser {
1515
1515
using Attributes = ModuleMap::Attributes;
1516
1516
1517
1517
public:
1518
- ModuleMapParser (modulemap::ModuleMapFile &MMF, SourceManager &SourceMgr,
1518
+ ModuleMapLoader (modulemap::ModuleMapFile &MMF, SourceManager &SourceMgr,
1519
1519
DiagnosticsEngine &Diags, ModuleMap &Map, FileID ModuleMapFID,
1520
1520
DirectoryEntryRef Directory, bool IsSystem)
1521
1521
: MMF(MMF), SourceMgr(SourceMgr), Diags(Diags), Map(Map),
1522
1522
ModuleMapFID (ModuleMapFID), Directory(Directory), IsSystem(IsSystem) {}
1523
1523
1524
- bool parseModuleMapFile ();
1524
+ bool loadModuleMapFile ();
1525
1525
};
1526
1526
1527
1527
} // namespace clang
@@ -1530,7 +1530,7 @@ class ModuleMapParser {
1530
1530
// / module map search logic to find the appropriate private module when PCH
1531
1531
// / is used with implicit module maps. Warn when private modules are written
1532
1532
// / in other ways (FooPrivate and Foo.Private), providing notes and fixits.
1533
- void ModuleMapParser ::diagnosePrivateModules (SourceLocation StartLoc) {
1533
+ void ModuleMapLoader ::diagnosePrivateModules (SourceLocation StartLoc) {
1534
1534
auto GenNoteAndFixIt = [&](StringRef BadName, StringRef Canonical,
1535
1535
const Module *M, SourceRange ReplLoc) {
1536
1536
auto D = Diags.Report (ActiveModule->DefinitionLoc ,
@@ -1584,7 +1584,7 @@ void ModuleMapParser::diagnosePrivateModules(SourceLocation StartLoc) {
1584
1584
}
1585
1585
}
1586
1586
1587
- void ModuleMapParser ::handleModuleDecl (const modulemap::ModuleDecl &MD) {
1587
+ void ModuleMapLoader ::handleModuleDecl (const modulemap::ModuleDecl &MD) {
1588
1588
if (MD.Id .front ().first == " *" )
1589
1589
return handleInferredModuleDecl (MD);
1590
1590
@@ -1763,7 +1763,7 @@ void ModuleMapParser::handleModuleDecl(const modulemap::ModuleDecl &MD) {
1763
1763
ActiveModule = PreviousActiveModule;
1764
1764
}
1765
1765
1766
- void ModuleMapParser ::handleExternModuleDecl (
1766
+ void ModuleMapLoader ::handleExternModuleDecl (
1767
1767
const modulemap::ExternModuleDecl &EMD) {
1768
1768
StringRef FileNameRef = EMD.Path ;
1769
1769
SmallString<128 > ModuleMapFileName;
@@ -1773,7 +1773,7 @@ void ModuleMapParser::handleExternModuleDecl(
1773
1773
FileNameRef = ModuleMapFileName;
1774
1774
}
1775
1775
if (auto File = SourceMgr.getFileManager ().getOptionalFileRef (FileNameRef))
1776
- Map.parseModuleMapFile (
1776
+ Map.loadModuleMapFile (
1777
1777
*File, IsSystem,
1778
1778
Map.HeaderInfo .getHeaderSearchOpts ().ModuleMapFileHomeIsCwd
1779
1779
? Directory
@@ -1810,7 +1810,7 @@ static bool shouldAddRequirement(Module *M, StringRef Feature,
1810
1810
return true ;
1811
1811
}
1812
1812
1813
- void ModuleMapParser ::handleRequiresDecl (const modulemap::RequiresDecl &RD) {
1813
+ void ModuleMapLoader ::handleRequiresDecl (const modulemap::RequiresDecl &RD) {
1814
1814
1815
1815
for (const modulemap::RequiresFeature &RF : RD.Features ) {
1816
1816
bool IsRequiresExcludedHack = false ;
@@ -1828,7 +1828,7 @@ void ModuleMapParser::handleRequiresDecl(const modulemap::RequiresDecl &RD) {
1828
1828
}
1829
1829
}
1830
1830
1831
- void ModuleMapParser ::handleHeaderDecl (const modulemap::HeaderDecl &HD) {
1831
+ void ModuleMapLoader ::handleHeaderDecl (const modulemap::HeaderDecl &HD) {
1832
1832
// We've already consumed the first token.
1833
1833
ModuleMap::ModuleHeaderRole Role = ModuleMap::NormalHeader;
1834
1834
@@ -1887,7 +1887,7 @@ static bool compareModuleHeaders(const Module::Header &A,
1887
1887
return A.NameAsWritten < B.NameAsWritten ;
1888
1888
}
1889
1889
1890
- void ModuleMapParser ::handleUmbrellaDirDecl (
1890
+ void ModuleMapLoader ::handleUmbrellaDirDecl (
1891
1891
const modulemap::UmbrellaDirDecl &UDD) {
1892
1892
std::string DirName = std::string (UDD.Path );
1893
1893
std::string DirNameAsWritten = DirName;
@@ -1919,7 +1919,7 @@ void ModuleMapParser::handleUmbrellaDirDecl(
1919
1919
1920
1920
if (UsesRequiresExcludedHack.count (ActiveModule)) {
1921
1921
// Mark this header 'textual' (see doc comment for
1922
- // ModuleMapParser ::UsesRequiresExcludedHack). Although iterating over the
1922
+ // ModuleMapLoader ::UsesRequiresExcludedHack). Although iterating over the
1923
1923
// directory is relatively expensive, in practice this only applies to the
1924
1924
// uncommonly used Tcl module on Darwin platforms.
1925
1925
std::error_code EC;
@@ -1953,12 +1953,12 @@ void ModuleMapParser::handleUmbrellaDirDecl(
1953
1953
Map.setUmbrellaDirAsWritten (ActiveModule, *Dir, DirNameAsWritten, DirName);
1954
1954
}
1955
1955
1956
- void ModuleMapParser ::handleExportDecl (const modulemap::ExportDecl &ED) {
1956
+ void ModuleMapLoader ::handleExportDecl (const modulemap::ExportDecl &ED) {
1957
1957
Module::UnresolvedExportDecl Unresolved = {ED.Location , ED.Id , ED.Wildcard };
1958
1958
ActiveModule->UnresolvedExports .push_back (Unresolved);
1959
1959
}
1960
1960
1961
- void ModuleMapParser ::handleExportAsDecl (const modulemap::ExportAsDecl &EAD) {
1961
+ void ModuleMapLoader ::handleExportAsDecl (const modulemap::ExportAsDecl &EAD) {
1962
1962
auto ModName = EAD.Id .front ();
1963
1963
1964
1964
if (!ActiveModule->ExportAsModule .empty ()) {
@@ -1976,19 +1976,19 @@ void ModuleMapParser::handleExportAsDecl(const modulemap::ExportAsDecl &EAD) {
1976
1976
Map.addLinkAsDependency (ActiveModule);
1977
1977
}
1978
1978
1979
- void ModuleMapParser ::handleUseDecl (const modulemap::UseDecl &UD) {
1979
+ void ModuleMapLoader ::handleUseDecl (const modulemap::UseDecl &UD) {
1980
1980
if (ActiveModule->Parent )
1981
1981
Diags.Report (UD.Location , diag::err_mmap_use_decl_submodule);
1982
1982
else
1983
1983
ActiveModule->UnresolvedDirectUses .push_back (UD.Id );
1984
1984
}
1985
1985
1986
- void ModuleMapParser ::handleLinkDecl (const modulemap::LinkDecl &LD) {
1986
+ void ModuleMapLoader ::handleLinkDecl (const modulemap::LinkDecl &LD) {
1987
1987
ActiveModule->LinkLibraries .push_back (
1988
1988
Module::LinkLibrary (std::string{LD.Library }, LD.Framework ));
1989
1989
}
1990
1990
1991
- void ModuleMapParser ::handleConfigMacros (
1991
+ void ModuleMapLoader ::handleConfigMacros (
1992
1992
const modulemap::ConfigMacrosDecl &CMD) {
1993
1993
if (ActiveModule->Parent ) {
1994
1994
Diags.Report (CMD.Location , diag::err_mmap_config_macro_submodule);
@@ -2004,7 +2004,7 @@ void ModuleMapParser::handleConfigMacros(
2004
2004
CMD.Macros .begin (), CMD.Macros .end ());
2005
2005
}
2006
2006
2007
- void ModuleMapParser ::handleConflict (const modulemap::ConflictDecl &CD) {
2007
+ void ModuleMapLoader ::handleConflict (const modulemap::ConflictDecl &CD) {
2008
2008
Module::UnresolvedConflict Conflict;
2009
2009
2010
2010
Conflict.Id = CD.Id ;
@@ -2013,7 +2013,7 @@ void ModuleMapParser::handleConflict(const modulemap::ConflictDecl &CD) {
2013
2013
ActiveModule->UnresolvedConflicts .push_back (Conflict);
2014
2014
}
2015
2015
2016
- void ModuleMapParser ::handleInferredModuleDecl (
2016
+ void ModuleMapLoader ::handleInferredModuleDecl (
2017
2017
const modulemap::ModuleDecl &MD) {
2018
2018
SourceLocation StarLoc = MD.Id .front ().second ;
2019
2019
@@ -2103,7 +2103,7 @@ void ModuleMapParser::handleInferredModuleDecl(
2103
2103
}
2104
2104
}
2105
2105
2106
- bool ModuleMapParser::parseModuleMapFile () {
2106
+ bool ModuleMapLoader::loadModuleMapFile () {
2107
2107
for (const auto &Decl : MMF.Decls ) {
2108
2108
std::visit (
2109
2109
llvm::makeVisitor (
@@ -2116,14 +2116,14 @@ bool ModuleMapParser::parseModuleMapFile() {
2116
2116
return HadError;
2117
2117
}
2118
2118
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) {
2123
2123
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 ())
2127
2127
return Known->second ;
2128
2128
2129
2129
// If the module map file wasn't already entered, do so now.
@@ -2136,20 +2136,21 @@ bool ModuleMap::parseModuleMapFile(FileEntryRef File, bool IsSystem,
2136
2136
assert (Target && " Missing target information" );
2137
2137
std::optional<llvm::MemoryBufferRef> Buffer = SourceMgr.getBufferOrNone (ID);
2138
2138
if (!Buffer)
2139
- return ParsedModuleMap [File] = true ;
2139
+ return LoadedModuleMap [File] = true ;
2140
2140
assert ((!Offset || *Offset <= Buffer->getBufferSize ()) &&
2141
2141
" invalid buffer offset" );
2142
2142
2143
2143
std::optional<modulemap::ModuleMapFile> MMF =
2144
2144
modulemap::parseModuleMap (ID, Dir, SourceMgr, Diags, IsSystem, Offset);
2145
2145
bool Result = false ;
2146
2146
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 ();
2149
2149
}
2150
- ParsedModuleMap [File] = Result;
2150
+ LoadedModuleMap [File] = Result;
2151
2151
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.
2153
2154
for (const auto &Cb : Callbacks)
2154
2155
Cb->moduleMapFileRead (MMF ? MMF->Start : SourceLocation (), File, IsSystem);
2155
2156
0 commit comments