@@ -649,8 +649,7 @@ ModuleMap::findOrCreateModuleForHeaderInUmbrellaDir(FileEntryRef File) {
649
649
UmbrellaModule = UmbrellaModule->Parent ;
650
650
651
651
if (UmbrellaModule->InferSubmodules ) {
652
- OptionalFileEntryRef UmbrellaModuleMap =
653
- getModuleMapFileForUniquing (UmbrellaModule);
652
+ FileID UmbrellaModuleMap = getModuleMapFileIDForUniquing (UmbrellaModule);
654
653
655
654
// Infer submodules for each of the directories we found between
656
655
// the directory of the umbrella header and the directory where
@@ -1031,7 +1030,7 @@ Module *ModuleMap::inferFrameworkModule(DirectoryEntryRef FrameworkDir,
1031
1030
1032
1031
// If the framework has a parent path from which we're allowed to infer
1033
1032
// a framework module, do so.
1034
- OptionalFileEntryRef ModuleMapFile ;
1033
+ FileID ModuleMapFID ;
1035
1034
if (!Parent) {
1036
1035
// Determine whether we're allowed to infer a module map.
1037
1036
bool canInfer = false ;
@@ -1070,7 +1069,7 @@ Module *ModuleMap::inferFrameworkModule(DirectoryEntryRef FrameworkDir,
1070
1069
Attrs.IsExhaustive |= inferred->second .Attrs .IsExhaustive ;
1071
1070
Attrs.NoUndeclaredIncludes |=
1072
1071
inferred->second .Attrs .NoUndeclaredIncludes ;
1073
- ModuleMapFile = inferred->second .ModuleMapFile ;
1072
+ ModuleMapFID = inferred->second .ModuleMapFID ;
1074
1073
}
1075
1074
}
1076
1075
}
@@ -1079,9 +1078,7 @@ Module *ModuleMap::inferFrameworkModule(DirectoryEntryRef FrameworkDir,
1079
1078
if (!canInfer)
1080
1079
return nullptr ;
1081
1080
} else {
1082
- OptionalFileEntryRefDegradesToFileEntryPtr ModuleMapRef =
1083
- getModuleMapFileForUniquing (Parent);
1084
- ModuleMapFile = ModuleMapRef;
1081
+ ModuleMapFID = getModuleMapFileIDForUniquing (Parent);
1085
1082
}
1086
1083
1087
1084
// Look for an umbrella header.
@@ -1098,7 +1095,7 @@ Module *ModuleMap::inferFrameworkModule(DirectoryEntryRef FrameworkDir,
1098
1095
Module *Result = new Module (ModuleName, SourceLocation (), Parent,
1099
1096
/* IsFramework=*/ true , /* IsExplicit=*/ false ,
1100
1097
NumCreatedModules++);
1101
- InferredModuleAllowedBy[Result] = ModuleMapFile ;
1098
+ InferredModuleAllowedBy[Result] = ModuleMapFID ;
1102
1099
Result->IsInferred = true ;
1103
1100
if (!Parent) {
1104
1101
if (LangOpts.CurrentModule == ModuleName)
@@ -1319,28 +1316,34 @@ void ModuleMap::addHeader(Module *Mod, Module::Header Header,
1319
1316
Cb->moduleMapAddHeader (Header.Entry .getName ());
1320
1317
}
1321
1318
1322
- OptionalFileEntryRef
1323
- ModuleMap::getContainingModuleMapFile (const Module *Module) const {
1319
+ FileID ModuleMap::getContainingModuleMapFileID (const Module *Module) const {
1324
1320
if (Module->DefinitionLoc .isInvalid ())
1325
- return std::nullopt ;
1321
+ return {} ;
1326
1322
1327
- return SourceMgr.getFileEntryRefForID (
1328
- SourceMgr.getFileID (Module->DefinitionLoc ));
1323
+ return SourceMgr.getFileID (Module->DefinitionLoc );
1329
1324
}
1330
1325
1331
1326
OptionalFileEntryRef
1332
- ModuleMap::getModuleMapFileForUniquing (const Module *M) const {
1327
+ ModuleMap::getContainingModuleMapFile (const Module *Module) const {
1328
+ return SourceMgr.getFileEntryRefForID (getContainingModuleMapFileID (Module));
1329
+ }
1330
+
1331
+ FileID ModuleMap::getModuleMapFileIDForUniquing (const Module *M) const {
1333
1332
if (M->IsInferred ) {
1334
1333
assert (InferredModuleAllowedBy.count (M) && " missing inferred module map" );
1335
1334
return InferredModuleAllowedBy.find (M)->second ;
1336
1335
}
1337
- return getContainingModuleMapFile (M);
1336
+ return getContainingModuleMapFileID (M);
1337
+ }
1338
+
1339
+ OptionalFileEntryRef
1340
+ ModuleMap::getModuleMapFileForUniquing (const Module *M) const {
1341
+ return SourceMgr.getFileEntryRefForID (getModuleMapFileIDForUniquing (M));
1338
1342
}
1339
1343
1340
- void ModuleMap::setInferredModuleAllowedBy (Module *M,
1341
- OptionalFileEntryRef ModMap) {
1344
+ void ModuleMap::setInferredModuleAllowedBy (Module *M, FileID ModMapFID) {
1342
1345
assert (M->IsInferred && " module not inferred" );
1343
- InferredModuleAllowedBy[M] = ModMap ;
1346
+ InferredModuleAllowedBy[M] = ModMapFID ;
1344
1347
}
1345
1348
1346
1349
std::error_code
@@ -1529,7 +1532,7 @@ namespace clang {
1529
1532
ModuleMap ⤅
1530
1533
1531
1534
// / The current module map file.
1532
- FileEntryRef ModuleMapFile ;
1535
+ FileID ModuleMapFID ;
1533
1536
1534
1537
// / Source location of most recent parsed module declaration
1535
1538
SourceLocation CurrModuleDeclLoc;
@@ -1599,13 +1602,12 @@ namespace clang {
1599
1602
bool parseOptionalAttributes (Attributes &Attrs);
1600
1603
1601
1604
public:
1602
- explicit ModuleMapParser (Lexer &L, SourceManager &SourceMgr,
1603
- const TargetInfo *Target, DiagnosticsEngine &Diags,
1604
- ModuleMap &Map, FileEntryRef ModuleMapFile ,
1605
- DirectoryEntryRef Directory, bool IsSystem)
1605
+ ModuleMapParser (Lexer &L, SourceManager &SourceMgr,
1606
+ const TargetInfo *Target, DiagnosticsEngine &Diags,
1607
+ ModuleMap &Map, FileID ModuleMapFID ,
1608
+ DirectoryEntryRef Directory, bool IsSystem)
1606
1609
: L(L), SourceMgr(SourceMgr), Target(Target), Diags(Diags), Map(Map),
1607
- ModuleMapFile(ModuleMapFile), Directory(Directory),
1608
- IsSystem(IsSystem) {
1610
+ ModuleMapFID (ModuleMapFID), Directory(Directory), IsSystem(IsSystem) {
1609
1611
Tok.clear ();
1610
1612
consumeToken ();
1611
1613
}
@@ -2028,11 +2030,13 @@ void ModuleMapParser::parseModuleDecl() {
2028
2030
}
2029
2031
2030
2032
if (TopLevelModule &&
2031
- ModuleMapFile != Map.getContainingModuleMapFile (TopLevelModule)) {
2032
- assert (ModuleMapFile != Map.getModuleMapFileForUniquing (TopLevelModule) &&
2033
+ ModuleMapFID != Map.getContainingModuleMapFileID (TopLevelModule)) {
2034
+ assert (ModuleMapFID !=
2035
+ Map.getModuleMapFileIDForUniquing (TopLevelModule) &&
2033
2036
" submodule defined in same file as 'module *' that allowed its "
2034
2037
" top-level module" );
2035
- Map.addAdditionalModuleMapFile (TopLevelModule, ModuleMapFile);
2038
+ Map.addAdditionalModuleMapFile (
2039
+ TopLevelModule, *SourceMgr.getFileEntryRefForID (ModuleMapFID));
2036
2040
}
2037
2041
}
2038
2042
@@ -2137,7 +2141,8 @@ void ModuleMapParser::parseModuleDecl() {
2137
2141
ActiveModule->NoUndeclaredIncludes = true ;
2138
2142
ActiveModule->Directory = Directory;
2139
2143
2140
- StringRef MapFileName (ModuleMapFile.getName ());
2144
+ StringRef MapFileName (
2145
+ SourceMgr.getFileEntryRefForID (ModuleMapFID)->getName ());
2141
2146
if (MapFileName.endswith (" module.private.modulemap" ) ||
2142
2147
MapFileName.endswith (" module_private.map" )) {
2143
2148
ActiveModule->ModuleMapIsPrivate = true ;
@@ -2922,7 +2927,7 @@ void ModuleMapParser::parseInferredModuleDecl(bool Framework, bool Explicit) {
2922
2927
// We'll be inferring framework modules for this directory.
2923
2928
Map.InferredDirectories [Directory].InferModules = true ;
2924
2929
Map.InferredDirectories [Directory].Attrs = Attrs;
2925
- Map.InferredDirectories [Directory].ModuleMapFile = ModuleMapFile ;
2930
+ Map.InferredDirectories [Directory].ModuleMapFID = ModuleMapFID ;
2926
2931
// FIXME: Handle the 'framework' keyword.
2927
2932
}
2928
2933
@@ -3160,8 +3165,7 @@ bool ModuleMap::parseModuleMapFile(FileEntryRef File, bool IsSystem,
3160
3165
Buffer->getBufferStart () + (Offset ? *Offset : 0 ),
3161
3166
Buffer->getBufferEnd ());
3162
3167
SourceLocation Start = L.getSourceLocation ();
3163
- ModuleMapParser Parser (L, SourceMgr, Target, Diags, *this , File, Dir,
3164
- IsSystem);
3168
+ ModuleMapParser Parser (L, SourceMgr, Target, Diags, *this , ID, Dir, IsSystem);
3165
3169
bool Result = Parser.parseModuleMapFile ();
3166
3170
ParsedModuleMap[File] = Result;
3167
3171
0 commit comments