Index: clang/lib/Basic/FileManager.cpp =================================================================== --- clang/lib/Basic/FileManager.cpp +++ clang/lib/Basic/FileManager.cpp @@ -221,12 +221,12 @@ // We've not seen this before. Fill it in. ++NumFileCacheMisses; - auto &NamedFileEnt = *SeenFileInsertResult.first; - assert(!NamedFileEnt.second && "should be newly-created"); + auto *NamedFileEnt = &*SeenFileInsertResult.first; + assert(!NamedFileEnt->second && "should be newly-created"); // Get the null-terminated file name as stored as the key of the // SeenFileEntries map. - StringRef InterndFileName = NamedFileEnt.first(); + StringRef InterndFileName = NamedFileEnt->first(); // Look up the directory for the file. When looking up something like // sys/foo.h we'll discover all of the search directories that have a 'sys' @@ -236,7 +236,7 @@ auto DirInfoOrErr = getDirectoryFromFile(*this, Filename, CacheFailure); if (!DirInfoOrErr) { // Directory doesn't exist, file can't exist. if (CacheFailure) - NamedFileEnt.second = DirInfoOrErr.getError(); + NamedFileEnt->second = DirInfoOrErr.getError(); else SeenFileEntries.erase(Filename); @@ -255,7 +255,7 @@ if (statError) { // There's no real file at the given path. if (CacheFailure) - NamedFileEnt.second = statError; + NamedFileEnt->second = statError; else SeenFileEntries.erase(Filename); @@ -268,7 +268,7 @@ // This occurs when one dir is symlinked to another, for example. FileEntry &UFE = UniqueRealFiles[Status.getUniqueID()]; - NamedFileEnt.second = &UFE; + NamedFileEnt->second = &UFE; // If the name returned by getStatValue is different than Filename, re-intern // the name. @@ -281,7 +281,11 @@ // In addition to re-interning the name, construct a redirecting seen file // entry, that will point to the name the filesystem actually wants to use. StringRef *Redirect = new (CanonicalNameStorage) StringRef(InterndFileName); - NamedFileEnt.second = Redirect; + auto SeenFileInsertResultIt = SeenFileEntries.find(Filename); + assert(SeenFileInsertResultIt != SeenFileEntries.end() && + "unexpected SeenFileEntries cache miss"); + SeenFileInsertResultIt->second = Redirect; + NamedFileEnt = &*SeenFileInsertResultIt; } if (UFE.isValid()) { // Already have an entry with this inode, return it.