@@ -648,8 +648,7 @@ ModuleMap::findOrCreateModuleForHeaderInUmbrellaDir(FileEntryRef File) {
648648 UmbrellaModule = UmbrellaModule->Parent ;
649649
650650 if (UmbrellaModule->InferSubmodules ) {
651- OptionalFileEntryRef UmbrellaModuleMap =
652- getModuleMapFileForUniquing (UmbrellaModule);
651+ FileID UmbrellaModuleMap = getModuleMapFileIDForUniquing (UmbrellaModule);
653652
654653 // Infer submodules for each of the directories we found between
655654 // the directory of the umbrella header and the directory where
@@ -1021,7 +1020,7 @@ Module *ModuleMap::inferFrameworkModule(DirectoryEntryRef FrameworkDir,
10211020
10221021 // If the framework has a parent path from which we're allowed to infer
10231022 // a framework module, do so.
1024- OptionalFileEntryRef ModuleMapFile ;
1023+ FileID ModuleMapFID ;
10251024 if (!Parent) {
10261025 // Determine whether we're allowed to infer a module map.
10271026 bool canInfer = false ;
@@ -1060,7 +1059,7 @@ Module *ModuleMap::inferFrameworkModule(DirectoryEntryRef FrameworkDir,
10601059 Attrs.IsExhaustive |= inferred->second .Attrs .IsExhaustive ;
10611060 Attrs.NoUndeclaredIncludes |=
10621061 inferred->second .Attrs .NoUndeclaredIncludes ;
1063- ModuleMapFile = inferred->second .ModuleMapFile ;
1062+ ModuleMapFID = inferred->second .ModuleMapFID ;
10641063 }
10651064 }
10661065 }
@@ -1069,7 +1068,7 @@ Module *ModuleMap::inferFrameworkModule(DirectoryEntryRef FrameworkDir,
10691068 if (!canInfer)
10701069 return nullptr ;
10711070 } else {
1072- ModuleMapFile = getModuleMapFileForUniquing (Parent);
1071+ ModuleMapFID = getModuleMapFileIDForUniquing (Parent);
10731072 }
10741073
10751074 // Look for an umbrella header.
@@ -1086,7 +1085,7 @@ Module *ModuleMap::inferFrameworkModule(DirectoryEntryRef FrameworkDir,
10861085 Module *Result = new Module (ModuleName, SourceLocation (), Parent,
10871086 /* IsFramework=*/ true , /* IsExplicit=*/ false ,
10881087 NumCreatedModules++);
1089- InferredModuleAllowedBy[Result] = ModuleMapFile ;
1088+ InferredModuleAllowedBy[Result] = ModuleMapFID ;
10901089 Result->IsInferred = true ;
10911090 if (!Parent) {
10921091 if (LangOpts.CurrentModule == ModuleName)
@@ -1307,28 +1306,34 @@ void ModuleMap::addHeader(Module *Mod, Module::Header Header,
13071306 Cb->moduleMapAddHeader (Header.Entry .getName ());
13081307}
13091308
1310- OptionalFileEntryRef
1311- ModuleMap::getContainingModuleMapFile (const Module *Module) const {
1309+ FileID ModuleMap::getContainingModuleMapFileID (const Module *Module) const {
13121310 if (Module->DefinitionLoc .isInvalid ())
1313- return std:: nullopt ;
1311+ return {} ;
13141312
1315- return SourceMgr.getFileEntryRefForID (
1316- SourceMgr.getFileID (Module->DefinitionLoc ));
1313+ return SourceMgr.getFileID (Module->DefinitionLoc );
13171314}
13181315
13191316OptionalFileEntryRef
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 {
13211322 if (M->IsInferred ) {
13221323 assert (InferredModuleAllowedBy.count (M) && " missing inferred module map" );
13231324 return InferredModuleAllowedBy.find (M)->second ;
13241325 }
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));
13261332}
13271333
1328- void ModuleMap::setInferredModuleAllowedBy (Module *M,
1329- OptionalFileEntryRef ModMap) {
1334+ void ModuleMap::setInferredModuleAllowedBy (Module *M, FileID ModMapFID) {
13301335 assert (M->IsInferred && " module not inferred" );
1331- InferredModuleAllowedBy[M] = ModMap ;
1336+ InferredModuleAllowedBy[M] = ModMapFID ;
13321337}
13331338
13341339std::error_code
@@ -1517,7 +1522,7 @@ namespace clang {
15171522 ModuleMap ⤅
15181523
15191524 // / The current module map file.
1520- FileEntryRef ModuleMapFile ;
1525+ FileID ModuleMapFID ;
15211526
15221527 // / Source location of most recent parsed module declaration
15231528 SourceLocation CurrModuleDeclLoc;
@@ -1585,13 +1590,12 @@ namespace clang {
15851590 bool parseOptionalAttributes (Attributes &Attrs);
15861591
15871592 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)
15921597 : 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) {
15951599 Tok.clear ();
15961600 consumeToken ();
15971601 }
@@ -2011,11 +2015,13 @@ void ModuleMapParser::parseModuleDecl() {
20112015 }
20122016
20132017 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) &&
20162021 " submodule defined in same file as 'module *' that allowed its "
20172022 " top-level module" );
2018- Map.addAdditionalModuleMapFile (TopLevelModule, ModuleMapFile);
2023+ Map.addAdditionalModuleMapFile (
2024+ TopLevelModule, *SourceMgr.getFileEntryRefForID (ModuleMapFID));
20192025 }
20202026 }
20212027
@@ -2120,7 +2126,8 @@ void ModuleMapParser::parseModuleDecl() {
21202126 ActiveModule->NoUndeclaredIncludes = true ;
21212127 ActiveModule->Directory = Directory;
21222128
2123- StringRef MapFileName (ModuleMapFile.getName ());
2129+ StringRef MapFileName (
2130+ SourceMgr.getFileEntryRefForID (ModuleMapFID)->getName ());
21242131 if (MapFileName.ends_with (" module.private.modulemap" ) ||
21252132 MapFileName.ends_with (" module_private.map" )) {
21262133 ActiveModule->ModuleMapIsPrivate = true ;
@@ -2906,7 +2913,7 @@ void ModuleMapParser::parseInferredModuleDecl(bool Framework, bool Explicit) {
29062913 // We'll be inferring framework modules for this directory.
29072914 Map.InferredDirectories [Directory].InferModules = true ;
29082915 Map.InferredDirectories [Directory].Attrs = Attrs;
2909- Map.InferredDirectories [Directory].ModuleMapFile = ModuleMapFile ;
2916+ Map.InferredDirectories [Directory].ModuleMapFID = ModuleMapFID ;
29102917 // FIXME: Handle the 'framework' keyword.
29112918 }
29122919
@@ -3139,8 +3146,7 @@ bool ModuleMap::parseModuleMapFile(FileEntryRef File, bool IsSystem,
31393146 Buffer->getBufferStart () + (Offset ? *Offset : 0 ),
31403147 Buffer->getBufferEnd ());
31413148 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);
31443150 bool Result = Parser.parseModuleMapFile ();
31453151 ParsedModuleMap[File] = Result;
31463152
0 commit comments