@@ -648,8 +648,7 @@ ModuleMap::findOrCreateModuleForHeaderInUmbrellaDir(FileEntryRef File) {
648
648
UmbrellaModule = UmbrellaModule->Parent ;
649
649
650
650
if (UmbrellaModule->InferSubmodules ) {
651
- OptionalFileEntryRef UmbrellaModuleMap =
652
- getModuleMapFileForUniquing (UmbrellaModule);
651
+ FileID UmbrellaModuleMap = getModuleMapFileIDForUniquing (UmbrellaModule);
653
652
654
653
// Infer submodules for each of the directories we found between
655
654
// the directory of the umbrella header and the directory where
@@ -1021,7 +1020,7 @@ Module *ModuleMap::inferFrameworkModule(DirectoryEntryRef FrameworkDir,
1021
1020
1022
1021
// If the framework has a parent path from which we're allowed to infer
1023
1022
// a framework module, do so.
1024
- OptionalFileEntryRef ModuleMapFile ;
1023
+ FileID ModuleMapFID ;
1025
1024
if (!Parent) {
1026
1025
// Determine whether we're allowed to infer a module map.
1027
1026
bool canInfer = false ;
@@ -1060,7 +1059,7 @@ Module *ModuleMap::inferFrameworkModule(DirectoryEntryRef FrameworkDir,
1060
1059
Attrs.IsExhaustive |= inferred->second .Attrs .IsExhaustive ;
1061
1060
Attrs.NoUndeclaredIncludes |=
1062
1061
inferred->second .Attrs .NoUndeclaredIncludes ;
1063
- ModuleMapFile = inferred->second .ModuleMapFile ;
1062
+ ModuleMapFID = inferred->second .ModuleMapFID ;
1064
1063
}
1065
1064
}
1066
1065
}
@@ -1069,7 +1068,7 @@ Module *ModuleMap::inferFrameworkModule(DirectoryEntryRef FrameworkDir,
1069
1068
if (!canInfer)
1070
1069
return nullptr ;
1071
1070
} else {
1072
- ModuleMapFile = getModuleMapFileForUniquing (Parent);
1071
+ ModuleMapFID = getModuleMapFileIDForUniquing (Parent);
1073
1072
}
1074
1073
1075
1074
// Look for an umbrella header.
@@ -1086,7 +1085,7 @@ Module *ModuleMap::inferFrameworkModule(DirectoryEntryRef FrameworkDir,
1086
1085
Module *Result = new Module (ModuleName, SourceLocation (), Parent,
1087
1086
/* IsFramework=*/ true , /* IsExplicit=*/ false ,
1088
1087
NumCreatedModules++);
1089
- InferredModuleAllowedBy[Result] = ModuleMapFile ;
1088
+ InferredModuleAllowedBy[Result] = ModuleMapFID ;
1090
1089
Result->IsInferred = true ;
1091
1090
if (!Parent) {
1092
1091
if (LangOpts.CurrentModule == ModuleName)
@@ -1307,28 +1306,34 @@ void ModuleMap::addHeader(Module *Mod, Module::Header Header,
1307
1306
Cb->moduleMapAddHeader (Header.Entry .getName ());
1308
1307
}
1309
1308
1310
- OptionalFileEntryRef
1311
- ModuleMap::getContainingModuleMapFile (const Module *Module) const {
1309
+ FileID ModuleMap::getContainingModuleMapFileID (const Module *Module) const {
1312
1310
if (Module->DefinitionLoc .isInvalid ())
1313
- return std::nullopt ;
1311
+ return {} ;
1314
1312
1315
- return SourceMgr.getFileEntryRefForID (
1316
- SourceMgr.getFileID (Module->DefinitionLoc ));
1313
+ return SourceMgr.getFileID (Module->DefinitionLoc );
1317
1314
}
1318
1315
1319
1316
OptionalFileEntryRef
1320
- ModuleMap::getModuleMapFileForUniquing (const Module *M) const {
1317
+ ModuleMap::getContainingModuleMapFile (const Module *Module) const {
1318
+ return SourceMgr.getFileEntryRefForID (getContainingModuleMapFileID (Module));
1319
+ }
1320
+
1321
+ FileID ModuleMap::getModuleMapFileIDForUniquing (const Module *M) const {
1321
1322
if (M->IsInferred ) {
1322
1323
assert (InferredModuleAllowedBy.count (M) && " missing inferred module map" );
1323
1324
return InferredModuleAllowedBy.find (M)->second ;
1324
1325
}
1325
- return getContainingModuleMapFile (M);
1326
+ return getContainingModuleMapFileID (M);
1327
+ }
1328
+
1329
+ OptionalFileEntryRef
1330
+ ModuleMap::getModuleMapFileForUniquing (const Module *M) const {
1331
+ return SourceMgr.getFileEntryRefForID (getModuleMapFileIDForUniquing (M));
1326
1332
}
1327
1333
1328
- void ModuleMap::setInferredModuleAllowedBy (Module *M,
1329
- OptionalFileEntryRef ModMap) {
1334
+ void ModuleMap::setInferredModuleAllowedBy (Module *M, FileID ModMapFID) {
1330
1335
assert (M->IsInferred && " module not inferred" );
1331
- InferredModuleAllowedBy[M] = ModMap ;
1336
+ InferredModuleAllowedBy[M] = ModMapFID ;
1332
1337
}
1333
1338
1334
1339
std::error_code
@@ -1517,7 +1522,7 @@ namespace clang {
1517
1522
ModuleMap ⤅
1518
1523
1519
1524
// / The current module map file.
1520
- FileEntryRef ModuleMapFile ;
1525
+ FileID ModuleMapFID ;
1521
1526
1522
1527
// / Source location of most recent parsed module declaration
1523
1528
SourceLocation CurrModuleDeclLoc;
@@ -1585,13 +1590,12 @@ namespace clang {
1585
1590
bool parseOptionalAttributes (Attributes &Attrs);
1586
1591
1587
1592
public:
1588
- explicit ModuleMapParser (Lexer &L, SourceManager &SourceMgr,
1589
- const TargetInfo *Target, DiagnosticsEngine &Diags,
1590
- ModuleMap &Map, FileEntryRef ModuleMapFile ,
1591
- DirectoryEntryRef Directory, bool IsSystem)
1593
+ ModuleMapParser (Lexer &L, SourceManager &SourceMgr,
1594
+ const TargetInfo *Target, DiagnosticsEngine &Diags,
1595
+ ModuleMap &Map, FileID ModuleMapFID ,
1596
+ DirectoryEntryRef Directory, bool IsSystem)
1592
1597
: L(L), SourceMgr(SourceMgr), Target(Target), Diags(Diags), Map(Map),
1593
- ModuleMapFile(ModuleMapFile), Directory(Directory),
1594
- IsSystem(IsSystem) {
1598
+ ModuleMapFID (ModuleMapFID), Directory(Directory), IsSystem(IsSystem) {
1595
1599
Tok.clear ();
1596
1600
consumeToken ();
1597
1601
}
@@ -2011,11 +2015,13 @@ void ModuleMapParser::parseModuleDecl() {
2011
2015
}
2012
2016
2013
2017
if (TopLevelModule &&
2014
- ModuleMapFile != Map.getContainingModuleMapFile (TopLevelModule)) {
2015
- assert (ModuleMapFile != Map.getModuleMapFileForUniquing (TopLevelModule) &&
2018
+ ModuleMapFID != Map.getContainingModuleMapFileID (TopLevelModule)) {
2019
+ assert (ModuleMapFID !=
2020
+ Map.getModuleMapFileIDForUniquing (TopLevelModule) &&
2016
2021
" submodule defined in same file as 'module *' that allowed its "
2017
2022
" top-level module" );
2018
- Map.addAdditionalModuleMapFile (TopLevelModule, ModuleMapFile);
2023
+ Map.addAdditionalModuleMapFile (
2024
+ TopLevelModule, *SourceMgr.getFileEntryRefForID (ModuleMapFID));
2019
2025
}
2020
2026
}
2021
2027
@@ -2120,7 +2126,8 @@ void ModuleMapParser::parseModuleDecl() {
2120
2126
ActiveModule->NoUndeclaredIncludes = true ;
2121
2127
ActiveModule->Directory = Directory;
2122
2128
2123
- StringRef MapFileName (ModuleMapFile.getName ());
2129
+ StringRef MapFileName (
2130
+ SourceMgr.getFileEntryRefForID (ModuleMapFID)->getName ());
2124
2131
if (MapFileName.ends_with (" module.private.modulemap" ) ||
2125
2132
MapFileName.ends_with (" module_private.map" )) {
2126
2133
ActiveModule->ModuleMapIsPrivate = true ;
@@ -2906,7 +2913,7 @@ void ModuleMapParser::parseInferredModuleDecl(bool Framework, bool Explicit) {
2906
2913
// We'll be inferring framework modules for this directory.
2907
2914
Map.InferredDirectories [Directory].InferModules = true ;
2908
2915
Map.InferredDirectories [Directory].Attrs = Attrs;
2909
- Map.InferredDirectories [Directory].ModuleMapFile = ModuleMapFile ;
2916
+ Map.InferredDirectories [Directory].ModuleMapFID = ModuleMapFID ;
2910
2917
// FIXME: Handle the 'framework' keyword.
2911
2918
}
2912
2919
@@ -3139,8 +3146,7 @@ bool ModuleMap::parseModuleMapFile(FileEntryRef File, bool IsSystem,
3139
3146
Buffer->getBufferStart () + (Offset ? *Offset : 0 ),
3140
3147
Buffer->getBufferEnd ());
3141
3148
SourceLocation Start = L.getSourceLocation ();
3142
- ModuleMapParser Parser (L, SourceMgr, Target, Diags, *this , File, Dir,
3143
- IsSystem);
3149
+ ModuleMapParser Parser (L, SourceMgr, Target, Diags, *this , ID, Dir, IsSystem);
3144
3150
bool Result = Parser.parseModuleMapFile ();
3145
3151
ParsedModuleMap[File] = Result;
3146
3152
0 commit comments