@@ -2042,19 +2042,15 @@ ASTReader::getGlobalPreprocessedEntityID(ModuleFile &M,
2042
2042
return LocalID + I->second ;
2043
2043
}
2044
2044
2045
- const FileEntry *HeaderFileInfoTrait::getFile (const internal_key_type &Key) {
2045
+ OptionalFileEntryRef
2046
+ HeaderFileInfoTrait::getFile (const internal_key_type &Key) {
2046
2047
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 );
2052
2050
2053
2051
std::string Resolved = std::string (Key.Filename );
2054
2052
Reader.ResolveImportedPath (M, Resolved);
2055
- if (auto File = FileMgr.getOptionalFileRef (Resolved))
2056
- return *File;
2057
- return nullptr ;
2053
+ return FileMgr.getOptionalFileRef (Resolved);
2058
2054
}
2059
2055
2060
2056
unsigned HeaderFileInfoTrait::ComputeHash (internal_key_ref ikey) {
@@ -2080,8 +2076,8 @@ bool HeaderFileInfoTrait::EqualKey(internal_key_ref a, internal_key_ref b) {
2080
2076
return true ;
2081
2077
2082
2078
// 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);
2085
2081
return FEA && FEA == FEB;
2086
2082
}
2087
2083
@@ -2112,12 +2108,13 @@ HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d,
2112
2108
HeaderFileInfo HFI;
2113
2109
unsigned Flags = *d++;
2114
2110
2111
+ OptionalFileEntryRef FE;
2115
2112
bool Included = (Flags >> 6 ) & 0x01 ;
2116
2113
if (Included)
2117
- if (const FileEntry * FE = getFile (key))
2114
+ if (( FE = getFile (key) ))
2118
2115
// Not using \c Preprocessor::markIncluded(), since that would attempt to
2119
2116
// deserialize this header file info again.
2120
- Reader.getPreprocessor ().getIncludedFiles ().insert (FE);
2117
+ Reader.getPreprocessor ().getIncludedFiles ().insert (* FE);
2121
2118
2122
2119
// FIXME: Refactor with mergeHeaderFileInfo in HeaderSearch.cpp.
2123
2120
HFI.isImport |= (Flags >> 5 ) & 0x01 ;
@@ -2146,14 +2143,10 @@ HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d,
2146
2143
// implicit module import.
2147
2144
SubmoduleID GlobalSMID = Reader.getGlobalSubmoduleID (M, LocalSMID);
2148
2145
Module *Mod = Reader.getSubmodule (GlobalSMID);
2149
- FileManager &FileMgr = Reader.getFileManager ();
2150
2146
ModuleMap &ModMap =
2151
2147
Reader.getPreprocessor ().getHeaderSearchInfo ().getModuleMap ();
2152
2148
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))) {
2157
2150
// FIXME: NameAsWritten
2158
2151
Module::Header H = {std::string (key.Filename ), " " , *FE};
2159
2152
ModMap.addHeader (Mod, H, HeaderRole, /* Imported=*/ true );
0 commit comments