<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 23, 2014, at 11:24 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Oct 23, 2014 at 11:05 AM, Ben Langmuir <span dir="ltr" class=""><<a href="mailto:blangmuir@apple.com" target="_blank" class="">blangmuir@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: benlangmuir<br class="">
Date: Thu Oct 23 13:05:36 2014<br class="">
New Revision: 220493<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=220493&view=rev" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=220493&view=rev</a><br class="">
Log:<br class="">
Add a "signature" to AST files to verify that they haven't changed<br class="">
<br class="">
Since the order of the IDs in the AST file (e.g. DeclIDs, SelectorIDs)<br class="">
is not stable,</blockquote><div class=""><br class="">Um... when you say "not stable" what do you mean? (& when you say "nothing changed" what do you mean)<br class=""></div></div></div></div></div></blockquote><div><br class=""></div><div>Identifiers, decls, macros, etc. are referred to by ID numbers, which depend on the order the entity is looked at during serialization. This in turn often depends on hash-table iteration order and is not stable across runs. When a module refers to a name in one of its imports, it will find the wrong name if the order has changed since it was first built.</div><div><br class=""></div><div>By “not changed” I mean that the sources have not changed.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class="">It's pretty important that the compiler produces identical bytes given identical input. We're pretty clear about fixing any cases where it doesn't (but maybe we haven't been as rigorous about that with AST serialization? I don't know - I'b be a bit scared if we haven’t)<br class=""></div></div></div></div></div></blockquote><div><br class=""></div><div>Maybe someone more familiar with the history of the ASTWriter can comment? +rsmith, +dgregor, +akyrtzidis</div><div><br class=""></div><div>I briefly looked at making the IDs deterministic, but I saw several hash tables being iterated over with no apparently guarantee of order, and figured we were not trying to produce identical bytes. We certainly *aren’t* producing identical bytes, and when this happens it causes utter insanity.</div><div><br class=""></div><div>Ben</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> it is not safe to load an AST file that depends on<br class="">
another AST file that has been rebuilt since the importer was built,<br class="">
even if "nothing changed". We previously used size and modtime to check<br class="">
this, but I've seen cases where a module rebuilt quickly enough to foil<br class="">
this check and caused very hard to debug build errors.<br class="">
<br class="">
To save cycles when we're loading the AST, we just generate a random<br class="">
nonce value and check that it hasn't changed when we load an imported<br class="">
module, rather than actually hash the whole file.<br class="">
<br class="">
This is slightly complicated by the fact that we need to verify the<br class="">
signature inside addModule, since we might otherwise consider that a<br class="">
mdoule is "OutOfDate" when really it is the importer that is out of<br class="">
date. I didn't see any regressions in module load time after this<br class="">
change.<br class="">
<br class="">
Added:<br class="">
cfe/trunk/test/Modules/rebuild.m<br class="">
Modified:<br class="">
cfe/trunk/include/clang/Serialization/ASTBitCodes.h<br class="">
cfe/trunk/include/clang/Serialization/ASTReader.h<br class="">
cfe/trunk/include/clang/Serialization/Module.h<br class="">
cfe/trunk/include/clang/Serialization/ModuleManager.h<br class="">
cfe/trunk/lib/Serialization/ASTReader.cpp<br class="">
cfe/trunk/lib/Serialization/ASTWriter.cpp<br class="">
cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp<br class="">
cfe/trunk/lib/Serialization/Module.cpp<br class="">
cfe/trunk/lib/Serialization/ModuleManager.cpp<br class="">
<br class="">
Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=220493&r1=220492&r2=220493&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=220493&r1=220492&r2=220493&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)<br class="">
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Thu Oct 23 13:05:36 2014<br class="">
@@ -288,7 +288,10 @@ namespace clang {<br class="">
<br class="">
/// \brief Record code for the module map file that was used to build this<br class="">
/// AST file.<br class="">
- MODULE_MAP_FILE = 14<br class="">
+ MODULE_MAP_FILE = 14,<br class="">
+<br class="">
+ /// \brief Record code for the signature that identifiers this AST file.<br class="">
+ SIGNATURE = 15<br class="">
};<br class="">
<br class="">
/// \brief Record types that occur within the input-files block<br class="">
<br class="">
Modified: cfe/trunk/include/clang/Serialization/ASTReader.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=220493&r1=220492&r2=220493&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=220493&r1=220492&r2=220493&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)<br class="">
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Oct 23 13:05:36 2014<br class="">
@@ -1125,6 +1125,7 @@ private:<br class="">
SourceLocation ImportLoc, ModuleFile *ImportedBy,<br class="">
SmallVectorImpl<ImportedModule> &Loaded,<br class="">
off_t ExpectedSize, time_t ExpectedModTime,<br class="">
+ serialization::ASTFileSignature ExpectedSignature,<br class="">
unsigned ClientLoadCapabilities);<br class="">
ASTReadResult ReadControlBlock(ModuleFile &F,<br class="">
SmallVectorImpl<ImportedModule> &Loaded,<br class="">
<br class="">
Modified: cfe/trunk/include/clang/Serialization/Module.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/Module.h?rev=220493&r1=220492&r2=220493&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/Module.h?rev=220493&r1=220492&r2=220493&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/include/clang/Serialization/Module.h (original)<br class="">
+++ cfe/trunk/include/clang/Serialization/Module.h Thu Oct 23 13:05:36 2014<br class="">
@@ -97,6 +97,8 @@ public:<br class="">
bool isNotFound() const { return Val.getInt() == NotFound; }<br class="">
};<br class="">
<br class="">
+typedef unsigned ASTFileSignature;<br class="">
+<br class="">
/// \brief Information about a module that has been loaded by the ASTReader.<br class="">
///<br class="">
/// Each instance of the Module class corresponds to a single AST file, which<br class="">
@@ -152,6 +154,10 @@ public:<br class="">
/// \brief The file entry for the module file.<br class="">
const FileEntry *File;<br class="">
<br class="">
+ /// \brief The signature of the module file, which may be used along with size<br class="">
+ /// and modification time to identify this particular file.<br class="">
+ ASTFileSignature Signature;<br class="">
+<br class="">
/// \brief Whether this module has been directly imported by the<br class="">
/// user.<br class="">
bool DirectlyImported;<br class="">
<br class="">
Modified: cfe/trunk/include/clang/Serialization/ModuleManager.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ModuleManager.h?rev=220493&r1=220492&r2=220493&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ModuleManager.h?rev=220493&r1=220492&r2=220493&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/include/clang/Serialization/ModuleManager.h (original)<br class="">
+++ cfe/trunk/include/clang/Serialization/ModuleManager.h Thu Oct 23 13:05:36 2014<br class="">
@@ -179,6 +179,12 @@ public:<br class="">
/// \param ExpectedModTime The expected modification time of the module<br class="">
/// file, used for validation. This will be zero if unknown.<br class="">
///<br class="">
+ /// \param ExpectedSignature The expected signature of the module file, used<br class="">
+ /// for validation. This will be zero if unknown.<br class="">
+ ///<br class="">
+ /// \param ReadSignature Reads the signature from an AST file without actually<br class="">
+ /// loading it.<br class="">
+ ///<br class="">
/// \param Module A pointer to the module file if the module was successfully<br class="">
/// loaded.<br class="">
///<br class="">
@@ -191,6 +197,9 @@ public:<br class="">
SourceLocation ImportLoc,<br class="">
ModuleFile *ImportedBy, unsigned Generation,<br class="">
off_t ExpectedSize, time_t ExpectedModTime,<br class="">
+ ASTFileSignature ExpectedSignature,<br class="">
+ std::function<ASTFileSignature(llvm::BitstreamReader &)><br class="">
+ ReadSignature,<br class="">
ModuleFile *&Module,<br class="">
std::string &ErrorStr);<br class="">
<br class="">
<br class="">
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=220493&r1=220492&r2=220493&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=220493&r1=220492&r2=220493&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)<br class="">
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Oct 23 13:05:36 2014<br class="">
@@ -2363,6 +2363,11 @@ ASTReader::ReadControlBlock(ModuleFile &<br class="">
break;<br class="">
}<br class="">
<br class="">
+ case SIGNATURE:<br class="">
+ assert((!F.Signature || F.Signature == Record[0]) && "signature changed");<br class="">
+ F.Signature = Record[0];<br class="">
+ break;<br class="">
+<br class="">
case IMPORTS: {<br class="">
// Load each of the imported PCH files.<br class="">
unsigned Idx = 0, N = Record.size();<br class="">
@@ -2376,6 +2381,7 @@ ASTReader::ReadControlBlock(ModuleFile &<br class="">
SourceLocation::getFromRawEncoding(Record[Idx++]);<br class="">
off_t StoredSize = (off_t)Record[Idx++];<br class="">
time_t StoredModTime = (time_t)Record[Idx++];<br class="">
+ ASTFileSignature StoredSignature = Record[Idx++];<br class="">
unsigned Length = Record[Idx++];<br class="">
SmallString<128> ImportedFile(Record.begin() + Idx,<br class="">
Record.begin() + Idx + Length);<br class="">
@@ -2383,7 +2389,7 @@ ASTReader::ReadControlBlock(ModuleFile &<br class="">
<br class="">
// Load the AST file.<br class="">
switch(ReadASTCore(ImportedFile, ImportedKind, ImportLoc, &F, Loaded,<br class="">
- StoredSize, StoredModTime,<br class="">
+ StoredSize, StoredModTime, StoredSignature,<br class="">
ClientLoadCapabilities)) {<br class="">
case Failure: return Failure;<br class="">
// If we have to ignore the dependency, we'll have to ignore this too.<br class="">
@@ -3552,7 +3558,7 @@ ASTReader::ASTReadResult ASTReader::Read<br class="">
SmallVector<ImportedModule, 4> Loaded;<br class="">
switch(ASTReadResult ReadResult = ReadASTCore(FileName, Type, ImportLoc,<br class="">
/*ImportedBy=*/nullptr, Loaded,<br class="">
- 0, 0,<br class="">
+ 0, 0, 0,<br class="">
ClientLoadCapabilities)) {<br class="">
case Failure:<br class="">
case Missing:<br class="">
@@ -3719,6 +3725,8 @@ ASTReader::ASTReadResult ASTReader::Read<br class="">
return Success;<br class="">
}<br class="">
<br class="">
+static ASTFileSignature readASTFileSignature(llvm::BitstreamReader &StreamFile);<br class="">
+<br class="">
ASTReader::ASTReadResult<br class="">
ASTReader::ReadASTCore(StringRef FileName,<br class="">
ModuleKind Type,<br class="">
@@ -3726,12 +3734,14 @@ ASTReader::ReadASTCore(StringRef FileNam<br class="">
ModuleFile *ImportedBy,<br class="">
SmallVectorImpl<ImportedModule> &Loaded,<br class="">
off_t ExpectedSize, time_t ExpectedModTime,<br class="">
+ ASTFileSignature ExpectedSignature,<br class="">
unsigned ClientLoadCapabilities) {<br class="">
ModuleFile *M;<br class="">
std::string ErrorStr;<br class="">
ModuleManager::AddModuleResult AddResult<br class="">
= ModuleMgr.addModule(FileName, Type, ImportLoc, ImportedBy,<br class="">
getGeneration(), ExpectedSize, ExpectedModTime,<br class="">
+ ExpectedSignature, readASTFileSignature,<br class="">
M, ErrorStr);<br class="">
<br class="">
switch (AddResult) {<br class="">
@@ -4029,6 +4039,34 @@ static bool SkipCursorToBlock(BitstreamC<br class="">
}<br class="">
}<br class="">
<br class="">
+static ASTFileSignature readASTFileSignature(llvm::BitstreamReader &StreamFile){<br class="">
+ BitstreamCursor Stream(StreamFile);<br class="">
+ if (Stream.Read(8) != 'C' ||<br class="">
+ Stream.Read(8) != 'P' ||<br class="">
+ Stream.Read(8) != 'C' ||<br class="">
+ Stream.Read(8) != 'H') {<br class="">
+ return 0;<br class="">
+ }<br class="">
+<br class="">
+ // Scan for the CONTROL_BLOCK_ID block.<br class="">
+ if (SkipCursorToBlock(Stream, CONTROL_BLOCK_ID))<br class="">
+ return 0;<br class="">
+<br class="">
+ // Scan for SIGNATURE inside the control block.<br class="">
+ ASTReader::RecordData Record;<br class="">
+ while (1) {<br class="">
+ llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks();<br class="">
+ if (Entry.Kind == llvm::BitstreamEntry::EndBlock ||<br class="">
+ Entry.Kind != llvm::BitstreamEntry::Record)<br class="">
+ return 0;<br class="">
+<br class="">
+ Record.clear();<br class="">
+ StringRef Blob;<br class="">
+ if (SIGNATURE == Stream.readRecord(Entry.ID, Record, &Blob))<br class="">
+ return Record[0];<br class="">
+ }<br class="">
+}<br class="">
+<br class="">
/// \brief Retrieve the name of the original source file name<br class="">
/// directly from the AST file, without actually loading the AST<br class="">
/// file.<br class="">
<br class="">
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=220493&r1=220492&r2=220493&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=220493&r1=220492&r2=220493&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)<br class="">
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Thu Oct 23 13:05:36 2014<br class="">
@@ -51,6 +51,7 @@<br class="">
#include "llvm/Support/MemoryBuffer.h"<br class="">
#include "llvm/Support/OnDiskHashTable.h"<br class="">
#include "llvm/Support/Path.h"<br class="">
+#include "llvm/Support/Process.h"<br class="">
#include <algorithm><br class="">
#include <cstdio><br class="">
#include <string.h><br class="">
@@ -862,6 +863,7 @@ void ASTWriter::WriteBlockInfoBlock() {<br class="">
// Control Block.<br class="">
BLOCK(CONTROL_BLOCK);<br class="">
RECORD(METADATA);<br class="">
+ RECORD(SIGNATURE);<br class="">
RECORD(MODULE_NAME);<br class="">
RECORD(MODULE_MAP_FILE);<br class="">
RECORD(IMPORTS);<br class="">
@@ -1092,6 +1094,14 @@ adjustFilenameForRelocatablePCH(const ch<br class="">
return Filename + Pos;<br class="">
}<br class="">
<br class="">
+static ASTFileSignature getSignature() {<br class="">
+ while (1) {<br class="">
+ if (ASTFileSignature S = llvm::sys::Process::GetRandomNumber())<br class="">
+ return S;<br class="">
+ // Rely on GetRandomNumber to eventually return non-zero...<br class="">
+ }<br class="">
+}<br class="">
+<br class="">
/// \brief Write the control block.<br class="">
void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,<br class="">
StringRef isysroot,<br class="">
@@ -1121,6 +1131,11 @@ void ASTWriter::WriteControlBlock(Prepro<br class="">
Stream.EmitRecordWithBlob(MetadataAbbrevCode, Record,<br class="">
getClangFullRepositoryVersion());<br class="">
<br class="">
+ // Signature<br class="">
+ Record.clear();<br class="">
+ Record.push_back(getSignature());<br class="">
+ Stream.EmitRecord(SIGNATURE, Record);<br class="">
+<br class="">
// Module name<br class="">
if (WritingModule) {<br class="">
BitCodeAbbrev *Abbrev = new BitCodeAbbrev();<br class="">
@@ -1173,6 +1188,7 @@ void ASTWriter::WriteControlBlock(Prepro<br class="">
AddSourceLocation((*M)->ImportLoc, Record);<br class="">
Record.push_back((*M)->File->getSize());<br class="">
Record.push_back((*M)->File->getModificationTime());<br class="">
+ Record.push_back((*M)->Signature);<br class="">
const std::string &FileName = (*M)->FileName;<br class="">
Record.push_back(FileName.size());<br class="">
Record.append(FileName.begin(), FileName.end());<br class="">
<br class="">
Modified: cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp?rev=220493&r1=220492&r2=220493&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp?rev=220493&r1=220492&r2=220493&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp (original)<br class="">
+++ cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp Thu Oct 23 13:05:36 2014<br class="">
@@ -591,6 +591,10 @@ bool GlobalModuleIndexBuilder::loadModul<br class="">
off_t StoredSize = (off_t)Record[Idx++];<br class="">
time_t StoredModTime = (time_t)Record[Idx++];<br class="">
<br class="">
+ // Skip the stored signature.<br class="">
+ // FIXME: we could read the signature out of the import and validate it.<br class="">
+ Idx++;<br class="">
+<br class="">
// Retrieve the imported file name.<br class="">
unsigned Length = Record[Idx++];<br class="">
SmallString<128> ImportedFile(Record.begin() + Idx,<br class="">
<br class="">
Modified: cfe/trunk/lib/Serialization/Module.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/Module.cpp?rev=220493&r1=220492&r2=220493&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/Module.cpp?rev=220493&r1=220492&r2=220493&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/lib/Serialization/Module.cpp (original)<br class="">
+++ cfe/trunk/lib/Serialization/Module.cpp Thu Oct 23 13:05:36 2014<br class="">
@@ -21,7 +21,7 @@ using namespace serialization;<br class="">
using namespace reader;<br class="">
<br class="">
ModuleFile::ModuleFile(ModuleKind Kind, unsigned Generation)<br class="">
- : Kind(Kind), File(nullptr), DirectlyImported(false),<br class="">
+ : Kind(Kind), File(nullptr), Signature(0), DirectlyImported(false),<br class="">
Generation(Generation), SizeInBits(0),<br class="">
LocalNumSLocEntries(0), SLocEntryBaseID(0),<br class="">
SLocEntryBaseOffset(0), SLocEntryOffsets(nullptr),<br class="">
<br class="">
Modified: cfe/trunk/lib/Serialization/ModuleManager.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ModuleManager.cpp?rev=220493&r1=220492&r2=220493&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ModuleManager.cpp?rev=220493&r1=220492&r2=220493&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/lib/Serialization/ModuleManager.cpp (original)<br class="">
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp Thu Oct 23 13:05:36 2014<br class="">
@@ -57,6 +57,9 @@ ModuleManager::addModule(StringRef FileN<br class="">
SourceLocation ImportLoc, ModuleFile *ImportedBy,<br class="">
unsigned Generation,<br class="">
off_t ExpectedSize, time_t ExpectedModTime,<br class="">
+ ASTFileSignature ExpectedSignature,<br class="">
+ std::function<ASTFileSignature(llvm::BitstreamReader &)><br class="">
+ ReadSignature,<br class="">
ModuleFile *&Module,<br class="">
std::string &ErrorStr) {<br class="">
Module = nullptr;<br class="">
@@ -130,6 +133,21 @@ ModuleManager::addModule(StringRef FileN<br class="">
// Initialize the stream<br class="">
New->StreamFile.init((const unsigned char *)New->Buffer->getBufferStart(),<br class="">
(const unsigned char *)New->Buffer->getBufferEnd());<br class="">
+<br class="">
+ if (ExpectedSignature) {<br class="">
+ New->Signature = ReadSignature(New->StreamFile);<br class="">
+ if (New->Signature != ExpectedSignature) {<br class="">
+ ErrorStr = New->Signature ? "signature mismatch"<br class="">
+ : "could not read module signature";<br class="">
+<br class="">
+ // Remove the module file immediately, since removeModules might try to<br class="">
+ // invalidate the file cache for Entry, and that is not safe if this<br class="">
+ // module is *itself* up to date, but has an out-of-date importer.<br class="">
+ Modules.erase(Entry);<br class="">
+ Chain.pop_back();<br class="">
+ return OutOfDate;<br class="">
+ }<br class="">
+ }<br class="">
}<br class="">
<br class="">
if (ImportedBy) {<br class="">
<br class="">
Added: cfe/trunk/test/Modules/rebuild.m<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/rebuild.m?rev=220493&view=auto" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/rebuild.m?rev=220493&view=auto</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/test/Modules/rebuild.m (added)<br class="">
+++ cfe/trunk/test/Modules/rebuild.m Thu Oct 23 13:05:36 2014<br class="">
@@ -0,0 +1,29 @@<br class="">
+// REQUIRES: shell<br class="">
+// RUN: rm -rf %t<br class="">
+<br class="">
+// Build Module and set its timestamp<br class="">
+// RUN: echo '@import Module;' | %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs -x objective-c -<br class="">
+// RUN: touch -m -a -t 201101010000 %t/Module.pcm<br class="">
+// RUN: cp %t/Module.pcm %t/Module.pcm.saved<br class="">
+// RUN: wc -c %t/Module.pcm > %t/Module.size.saved<br class="">
+<br class="">
+// Build DependsOnModule<br class="">
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs %s<br class="">
+// RUN: diff %t/Module.pcm %t/Module.pcm.saved<br class="">
+// RUN: cp %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved<br class="">
+<br class="">
+// Rebuild Module, reset its timestamp, and verify its size hasn't changed<br class="">
+// RUN: rm %t/Module.pcm<br class="">
+// RUN: echo '@import Module;' | %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs -x objective-c -<br class="">
+// RUN: touch -m -a -t 201101010000 %t/Module.pcm<br class="">
+// RUN: wc -c %t/Module.pcm > %t/Module.size<br class="">
+// RUN: diff %t/Module.size %t/Module.size.saved<br class="">
+// RUN: cp %t/Module.pcm %t/Module.pcm.saved.2<br class="">
+<br class="">
+// But the signature at least is expected to change, so we rebuild DependsOnModule.<br class="">
+// NOTE: if we change how the signature is created, this test may need updating.<br class="">
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs %s<br class="">
+// RUN: diff %t/Module.pcm %t/Module.pcm.saved.2<br class="">
+// RUN: not diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved<br class="">
+<br class="">
+@import DependsOnModule;<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
cfe-commits mailing list<br class="">
<a href="mailto:cfe-commits@cs.uiuc.edu" class="">cfe-commits@cs.uiuc.edu</a><br class="">
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank" class="">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br class="">
</blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>