[PATCH] D20137: [PCH] Fixed bugs with preamble invalidation when files change (on Windows)
Cameron via cfe-commits
cfe-commits at lists.llvm.org
Mon May 16 11:01:23 PDT 2016
cameron314 updated the summary for this revision.
cameron314 updated this revision to Diff 57367.
cameron314 added a comment.
This version of the patch takes into account potential changes between filenames and their unique IDs between parses.
http://reviews.llvm.org/D20137
Files:
lib/Frontend/ASTUnit.cpp
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<PreambleFileHash> OverriddenFiles;
+ std::map<llvm::sys::fs::UniqueID, PreambleFileHash> 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<PreambleFileHash>::iterator
+ for (llvm::StringMap<PreambleFileHash>::iterator
F = FilesInPreamble.begin(), FEnd = FilesInPreamble.end();
!AnyFileChanged && F != FEnd;
++F) {
- llvm::StringMap<PreambleFileHash>::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<llvm::sys::fs::UniqueID, PreambleFileHash>::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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20137.57367.patch
Type: text/x-patch
Size: 2877 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160516/3799e76d/attachment-0001.bin>
More information about the cfe-commits
mailing list