summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-03-21 22:49:54 +0000
committerDouglas Gregor <dgregor@apple.com>2010-03-21 22:49:54 +0000
commitb41ca8f2aeb085306fc8c1027fa621ce0a398fdc (patch)
tree854f813eb85e07fd827a89dae462b8685ee5daad /clang/lib
parent9f2284121a4fc4e108c93ab2f7b045700617bb72 (diff)
downloadbcm5719-llvm-b41ca8f2aeb085306fc8c1027fa621ce0a398fdc.tar.gz
bcm5719-llvm-b41ca8f2aeb085306fc8c1027fa621ce0a398fdc.zip
Keep track of the size/modification time of each file source-location
entry in a precompiled header, so that we can detect modified files even when we miss in the stat cache. llvm-svn: 99149
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Basic/SourceManager.cpp3
-rw-r--r--clang/lib/Frontend/PCHReader.cpp17
-rw-r--r--clang/lib/Frontend/PCHWriter.cpp7
3 files changed, 20 insertions, 7 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp
index 6def967c4cf..c34f3e25439 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -93,8 +93,7 @@ const llvm::MemoryBuffer *ContentCache::getBuffer(Diagnostic &Diag,
<< Entry->getName() << ErrorStr;
Buffer.setInt(true);
} else if (FileInfo.st_size != Entry->getSize() ||
- FileInfo.st_mtime != Entry->getModificationTime() ||
- FileInfo.st_ino != Entry->getInode()) {
+ FileInfo.st_mtime != Entry->getModificationTime()) {
// Check that the file's size, modification time, and inode are
// the same as in the file entry (which may have come from a
// stat cache).
diff --git a/clang/lib/Frontend/PCHReader.cpp b/clang/lib/Frontend/PCHReader.cpp
index e659ff047d7..8fd81df098e 100644
--- a/clang/lib/Frontend/PCHReader.cpp
+++ b/clang/lib/Frontend/PCHReader.cpp
@@ -905,11 +905,18 @@ PCHReader::PCHReadResult PCHReader::ReadSLocEntryRecord(unsigned ID) {
return Failure;
}
- if (Record.size() < 8) {
+ if (Record.size() < 10) {
Error("source location entry is incorrect");
return Failure;
}
+ if ((off_t)Record[4] != File->getSize() ||
+ (time_t)Record[5] != File->getModificationTime()) {
+ Diag(diag::err_fe_pch_file_modified)
+ << Filename;
+ return Failure;
+ }
+
FileID FID = SourceMgr.createFileID(File,
SourceLocation::getFromRawEncoding(Record[1]),
(SrcMgr::CharacteristicKind)Record[2],
@@ -920,10 +927,10 @@ PCHReader::PCHReadResult PCHReader::ReadSLocEntryRecord(unsigned ID) {
// Reconstruct header-search information for this file.
HeaderFileInfo HFI;
- HFI.isImport = Record[4];
- HFI.DirInfo = Record[5];
- HFI.NumIncludes = Record[6];
- HFI.ControllingMacroID = Record[7];
+ HFI.isImport = Record[6];
+ HFI.DirInfo = Record[7];
+ HFI.NumIncludes = Record[8];
+ HFI.ControllingMacroID = Record[9];
if (Listener)
Listener->ReadHeaderFileInfo(HFI, File->getUID());
break;
diff --git a/clang/lib/Frontend/PCHWriter.cpp b/clang/lib/Frontend/PCHWriter.cpp
index 4752cd3ea6e..6c2d1424c80 100644
--- a/clang/lib/Frontend/PCHWriter.cpp
+++ b/clang/lib/Frontend/PCHWriter.cpp
@@ -921,6 +921,9 @@ static unsigned CreateSLocFileAbbrev(llvm::BitstreamWriter &Stream) {
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Include location
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // Characteristic
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Line directives
+ // FileEntry fields.
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 12)); // Size
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32)); // Modification time
// HeaderFileInfo fields.
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isImport
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // DirInfo
@@ -1063,6 +1066,10 @@ void PCHWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
// The source location entry is a file. The blob associated
// with this entry is the file name.
+ // Emit size/modification time for this file.
+ Record.push_back(Content->Entry->getSize());
+ Record.push_back(Content->Entry->getModificationTime());
+
// Emit header-search information associated with this file.
HeaderFileInfo HFI;
HeaderSearch &HS = PP.getHeaderSearchInfo();
OpenPOWER on IntegriCloud