@@ -2042,19 +2042,15 @@ ASTReader::getGlobalPreprocessedEntityID(ModuleFile &M,
20422042 return LocalID + I->second ;
20432043}
20442044
2045- const FileEntry *HeaderFileInfoTrait::getFile (const internal_key_type &Key) {
2045+ OptionalFileEntryRef
2046+ HeaderFileInfoTrait::getFile (const internal_key_type &Key) {
20462047 FileManager &FileMgr = Reader.getFileManager ();
2047- if (!Key.Imported ) {
2048- if (auto File = FileMgr.getOptionalFileRef (Key.Filename ))
2049- return *File;
2050- return nullptr ;
2051- }
2048+ if (!Key.Imported )
2049+ return FileMgr.getOptionalFileRef (Key.Filename );
20522050
20532051 std::string Resolved = std::string (Key.Filename );
20542052 Reader.ResolveImportedPath (M, Resolved);
2055- if (auto File = FileMgr.getOptionalFileRef (Resolved))
2056- return *File;
2057- return nullptr ;
2053+ return FileMgr.getOptionalFileRef (Resolved);
20582054}
20592055
20602056unsigned HeaderFileInfoTrait::ComputeHash (internal_key_ref ikey) {
@@ -2080,8 +2076,8 @@ bool HeaderFileInfoTrait::EqualKey(internal_key_ref a, internal_key_ref b) {
20802076 return true ;
20812077
20822078 // Determine whether the actual files are equivalent.
2083- const FileEntry * FEA = getFile (a);
2084- const FileEntry * FEB = getFile (b);
2079+ OptionalFileEntryRef FEA = getFile (a);
2080+ OptionalFileEntryRef FEB = getFile (b);
20852081 return FEA && FEA == FEB;
20862082}
20872083
@@ -2112,12 +2108,13 @@ HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d,
21122108 HeaderFileInfo HFI;
21132109 unsigned Flags = *d++;
21142110
2111+ OptionalFileEntryRef FE;
21152112 bool Included = (Flags >> 6 ) & 0x01 ;
21162113 if (Included)
2117- if (const FileEntry * FE = getFile (key))
2114+ if (( FE = getFile (key) ))
21182115 // Not using \c Preprocessor::markIncluded(), since that would attempt to
21192116 // deserialize this header file info again.
2120- Reader.getPreprocessor ().getIncludedFiles ().insert (FE);
2117+ Reader.getPreprocessor ().getIncludedFiles ().insert (* FE);
21212118
21222119 // FIXME: Refactor with mergeHeaderFileInfo in HeaderSearch.cpp.
21232120 HFI.isImport |= (Flags >> 5 ) & 0x01 ;
@@ -2146,14 +2143,10 @@ HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d,
21462143 // implicit module import.
21472144 SubmoduleID GlobalSMID = Reader.getGlobalSubmoduleID (M, LocalSMID);
21482145 Module *Mod = Reader.getSubmodule (GlobalSMID);
2149- FileManager &FileMgr = Reader.getFileManager ();
21502146 ModuleMap &ModMap =
21512147 Reader.getPreprocessor ().getHeaderSearchInfo ().getModuleMap ();
21522148
2153- std::string Filename = std::string (key.Filename );
2154- if (key.Imported )
2155- Reader.ResolveImportedPath (M, Filename);
2156- if (auto FE = FileMgr.getOptionalFileRef (Filename)) {
2149+ if (FE || (FE = getFile (key))) {
21572150 // FIXME: NameAsWritten
21582151 Module::Header H = {std::string (key.Filename ), " " , *FE};
21592152 ModMap.addHeader (Mod, H, HeaderRole, /* Imported=*/ true );
0 commit comments