Index: lib/Frontend/ASTUnit.cpp =================================================================== --- lib/Frontend/ASTUnit.cpp +++ lib/Frontend/ASTUnit.cpp @@ -1378,7 +1378,7 @@ // First, make a record of those files that have been overridden via // remapping or unsaved_files. - llvm::StringMap OverriddenFiles; + std::map OverriddenFiles; for (const auto &R : PreprocessorOpts.RemappedFiles) { if (AnyFileChanged) break; @@ -1391,24 +1391,38 @@ break; } - OverriddenFiles[R.first] = PreambleFileHash::createForFile( + OverriddenFiles[Status.getUniqueID()] = PreambleFileHash::createForFile( Status.getSize(), Status.getLastModificationTime().toEpochTime()); } for (const auto &RB : PreprocessorOpts.RemappedFileBuffers) { if (AnyFileChanged) break; - OverriddenFiles[RB.first] = + + vfs::Status Status; + if (FileMgr->getNoncachedStatValue(RB.first, Status)) { + AnyFileChanged = true; + break; + } + + OverriddenFiles[Status.getUniqueID()] = PreambleFileHash::createForMemoryBuffer(RB.second); } // Check whether anything has changed. - for (llvm::StringMap::iterator + for (llvm::StringMap::iterator F = FilesInPreamble.begin(), FEnd = FilesInPreamble.end(); !AnyFileChanged && F != FEnd; ++F) { - llvm::StringMap::iterator Overridden - = OverriddenFiles.find(F->first()); + vfs::Status Status; + if (FileMgr->getNoncachedStatValue(F->first(), Status)) { + // If we can't stat the file, assume that something horrible happened. + AnyFileChanged = true; + break; + } + + std::map::iterator Overridden + = OverriddenFiles.find(Status.getUniqueID()); if (Overridden != OverriddenFiles.end()) { // This file was remapped; check whether the newly-mapped file // matches up with the previous mapping. @@ -1418,11 +1432,7 @@ } // The file was not remapped; check whether it has changed on disk. - vfs::Status Status; - if (FileMgr->getNoncachedStatValue(F->first(), Status)) { - // If we can't stat the file, assume that something horrible happened. - AnyFileChanged = true; - } else if (Status.getSize() != uint64_t(F->second.Size) || + if (Status.getSize() != uint64_t(F->second.Size) || Status.getLastModificationTime().toEpochTime() != uint64_t(F->second.ModTime)) AnyFileChanged = true;