r221569 - Check module signature when the module has already been loaded
Ben Langmuir
blangmuir at apple.com
Fri Nov 7 16:34:30 PST 2014
Author: benlangmuir
Date: Fri Nov 7 18:34:30 2014
New Revision: 221569
URL: http://llvm.org/viewvc/llvm-project?rev=221569&view=rev
Log:
Check module signature when the module has already been loaded
We may need to verify the signature on subsequent imports as well, just
like we verify the size/modtime:
@import A;
@import B; // imports A
@import C; // imports A
Modified:
cfe/trunk/lib/Serialization/ModuleManager.cpp
cfe/trunk/test/Modules/rebuild.m
Modified: cfe/trunk/lib/Serialization/ModuleManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ModuleManager.cpp?rev=221569&r1=221568&r2=221569&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ModuleManager.cpp (original)
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp Fri Nov 7 18:34:30 2014
@@ -132,21 +132,27 @@ ModuleManager::addModule(StringRef FileN
// Initialize the stream
New->StreamFile.init((const unsigned char *)New->Buffer->getBufferStart(),
(const unsigned char *)New->Buffer->getBufferEnd());
+ }
+
+ if (ExpectedSignature) {
+ if (NewModule)
+ ModuleEntry->Signature = ReadSignature(ModuleEntry->StreamFile);
+ else
+ assert(ModuleEntry->Signature == ReadSignature(ModuleEntry->StreamFile));
- if (ExpectedSignature) {
- New->Signature = ReadSignature(New->StreamFile);
- if (New->Signature != ExpectedSignature) {
- ErrorStr = New->Signature ? "signature mismatch"
- : "could not read module signature";
+ if (ModuleEntry->Signature != ExpectedSignature) {
+ ErrorStr = ModuleEntry->Signature ? "signature mismatch"
+ : "could not read module signature";
+ if (NewModule) {
// Remove the module file immediately, since removeModules might try to
// invalidate the file cache for Entry, and that is not safe if this
// module is *itself* up to date, but has an out-of-date importer.
Modules.erase(Entry);
Chain.pop_back();
- delete New;
- return OutOfDate;
+ delete ModuleEntry;
}
+ return OutOfDate;
}
}
Modified: cfe/trunk/test/Modules/rebuild.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/rebuild.m?rev=221569&r1=221568&r2=221569&view=diff
==============================================================================
--- cfe/trunk/test/Modules/rebuild.m (original)
+++ cfe/trunk/test/Modules/rebuild.m Fri Nov 7 18:34:30 2014
@@ -25,4 +25,21 @@
// RUN: diff %t/Module.pcm %t/Module.pcm.saved.2
// RUN: not diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved
+// Rebuild Module, reset its timestamp, and verify its size hasn't changed
+// RUN: rm %t/Module.pcm
+// RUN: echo '@import Module;' | %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs -x objective-c -
+// RUN: touch -m -a -t 201101010000 %t/Module.pcm
+// RUN: wc -c %t/Module.pcm > %t/Module.size
+// RUN: diff %t/Module.size %t/Module.size.saved
+// RUN: cp %t/Module.pcm %t/Module.pcm.saved.2
+
+// Verify again with Module pre-imported.
+// NOTE: if we change how the signature is created, this test may need updating.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs %s
+// RUN: diff %t/Module.pcm %t/Module.pcm.saved.2
+// RUN: not diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved
+
+#ifdef PREIMPORT
+ at import Module;
+#endif
@import DependsOnModule;
More information about the cfe-commits
mailing list