summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ModuleManager.cpp
diff options
context:
space:
mode:
authorBen Langmuir <blangmuir@apple.com>2014-11-08 00:34:30 +0000
committerBen Langmuir <blangmuir@apple.com>2014-11-08 00:34:30 +0000
commited9825848281163a14c55f48def81b6e04ef7ffe (patch)
tree36162d39034f3905531184d226a958fcb38ebaf1 /clang/lib/Serialization/ModuleManager.cpp
parente531d27cd13fa11d88deee18ae4256bca528ac07 (diff)
downloadbcm5719-llvm-ed9825848281163a14c55f48def81b6e04ef7ffe.tar.gz
bcm5719-llvm-ed9825848281163a14c55f48def81b6e04ef7ffe.zip
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 llvm-svn: 221569
Diffstat (limited to 'clang/lib/Serialization/ModuleManager.cpp')
-rw-r--r--clang/lib/Serialization/ModuleManager.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp
index 3baaa0a4b28..b5ee4145020 100644
--- a/clang/lib/Serialization/ModuleManager.cpp
+++ b/clang/lib/Serialization/ModuleManager.cpp
@@ -132,21 +132,27 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
// 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;
}
}
OpenPOWER on IntegriCloud