[ModuleInterfaces] Clear dependencies before checking a different module

Sometimes, if one module we tried failed, we would leave the dependencies from the previous check and fail a different module which would have succeeded.

This manifested as the prebuilt-module-cache-forwarding test testing the wrong thing, because it retained a mod-time based dependency in the prebuilt cache, which should have been hash based, and used it.
This commit is contained in:
Harlan Haskins
2019-06-21 13:33:45 -07:00
parent 1e4ee19c78
commit 6bf4a0e3e4
2 changed files with 20 additions and 6 deletions

View File

@@ -913,7 +913,12 @@ class ParseableInterfaceModuleLoaderImpl {
bool serializedASTBufferIsUpToDate(
StringRef path, const llvm::MemoryBuffer &buf,
SmallVectorImpl<FileDependency> &allDeps) {
LLVM_DEBUG(llvm::dbgs() << "Validating deps of " << modulePath << "\n");
// Clear the existing dependencies, because we're going to re-fill them
// in validateSerializedAST.
allDeps.clear();
LLVM_DEBUG(llvm::dbgs() << "Validating deps of " << path << "\n");
auto validationInfo = serialization::validateSerializedAST(
buf.getBuffer(), /*ExtendedValidationInfo=*/nullptr, &allDeps);
@@ -944,6 +949,13 @@ class ParseableInterfaceModuleLoaderImpl {
StringRef path, const ForwardingModule &fwd,
SmallVectorImpl<FileDependency> &deps,
std::unique_ptr<llvm::MemoryBuffer> &moduleBuffer) {
// Clear the existing dependencies, because we're going to re-fill them
// from the forwarding module.
deps.clear();
LLVM_DEBUG(llvm::dbgs() << "Validating deps of " << path << "\n");
// First, make sure the underlying module path exists and is valid.
auto modBuf = fs.getBufferForFile(fwd.underlyingModulePath);
if (!modBuf || !serializedASTLooksValid(*modBuf.get()))