@@ -2031,19 +2031,15 @@ ASTReader::getGlobalPreprocessedEntityID(ModuleFile &M,
2031
2031
return LocalID + I->second ;
2032
2032
}
2033
2033
2034
- const FileEntry *HeaderFileInfoTrait::getFile (const internal_key_type &Key) {
2034
+ OptionalFileEntryRef
2035
+ HeaderFileInfoTrait::getFile (const internal_key_type &Key) {
2035
2036
FileManager &FileMgr = Reader.getFileManager ();
2036
- if (!Key.Imported ) {
2037
- if (auto File = FileMgr.getFile (Key.Filename ))
2038
- return *File;
2039
- return nullptr ;
2040
- }
2037
+ if (!Key.Imported )
2038
+ return FileMgr.getOptionalFileRef (Key.Filename );
2041
2039
2042
2040
std::string Resolved = std::string (Key.Filename );
2043
2041
Reader.ResolveImportedPath (M, Resolved);
2044
- if (auto File = FileMgr.getFile (Resolved))
2045
- return *File;
2046
- return nullptr ;
2042
+ return FileMgr.getOptionalFileRef (Resolved);
2047
2043
}
2048
2044
2049
2045
unsigned HeaderFileInfoTrait::ComputeHash (internal_key_ref ikey) {
@@ -2069,8 +2065,8 @@ bool HeaderFileInfoTrait::EqualKey(internal_key_ref a, internal_key_ref b) {
2069
2065
return true ;
2070
2066
2071
2067
// Determine whether the actual files are equivalent.
2072
- const FileEntry * FEA = getFile (a);
2073
- const FileEntry * FEB = getFile (b);
2068
+ OptionalFileEntryRef FEA = getFile (a);
2069
+ OptionalFileEntryRef FEB = getFile (b);
2074
2070
return FEA && FEA == FEB;
2075
2071
}
2076
2072
@@ -2101,12 +2097,13 @@ HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d,
2101
2097
HeaderFileInfo HFI;
2102
2098
unsigned Flags = *d++;
2103
2099
2100
+ OptionalFileEntryRef FE;
2104
2101
bool Included = (Flags >> 6 ) & 0x01 ;
2105
2102
if (Included)
2106
- if (const FileEntry * FE = getFile (key))
2103
+ if (( FE = getFile (key) ))
2107
2104
// Not using \c Preprocessor::markIncluded(), since that would attempt to
2108
2105
// deserialize this header file info again.
2109
- Reader.getPreprocessor ().getIncludedFiles ().insert (FE);
2106
+ Reader.getPreprocessor ().getIncludedFiles ().insert (* FE);
2110
2107
2111
2108
// FIXME: Refactor with mergeHeaderFileInfo in HeaderSearch.cpp.
2112
2109
HFI.isImport |= (Flags >> 5 ) & 0x01 ;
@@ -2135,14 +2132,10 @@ HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d,
2135
2132
// implicit module import.
2136
2133
SubmoduleID GlobalSMID = Reader.getGlobalSubmoduleID (M, LocalSMID);
2137
2134
Module *Mod = Reader.getSubmodule (GlobalSMID);
2138
- FileManager &FileMgr = Reader.getFileManager ();
2139
2135
ModuleMap &ModMap =
2140
2136
Reader.getPreprocessor ().getHeaderSearchInfo ().getModuleMap ();
2141
2137
2142
- std::string Filename = std::string (key.Filename );
2143
- if (key.Imported )
2144
- Reader.ResolveImportedPath (M, Filename);
2145
- if (auto FE = FileMgr.getOptionalFileRef (Filename)) {
2138
+ if (FE || (FE = getFile (key))) {
2146
2139
// FIXME: NameAsWritten
2147
2140
Module::Header H = {std::string (key.Filename ), " " , *FE};
2148
2141
ModMap.addHeader (Mod, H, HeaderRole, /* Imported=*/ true );
0 commit comments