Skip to content

Commit fc4510e

Browse files
committed
[ModuleInterface] Make up-to-date check recursive, since it runs first.
1 parent 9b25819 commit fc4510e

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

lib/Frontend/ParseableInterfaceSupport.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ ParseableInterfaceModuleLoader::configureSubInvocationAndOutputPaths(
152152
// Check that the output .swiftmodule file is at least as new as all the
153153
// dependencies it read when it was built last time.
154154
static bool
155-
swiftModuleIsUpToDate(clang::vfs::FileSystem &FS,
156-
StringRef InPath, StringRef OutPath) {
155+
swiftModuleIsUpToDate(clang::vfs::FileSystem &FS, StringRef OutPath) {
157156

158157
if (!FS.exists(OutPath))
159158
return false;
@@ -180,8 +179,20 @@ swiftModuleIsUpToDate(clang::vfs::FileSystem &FS,
180179
if (!InStatus ||
181180
(InStatus.get().getSize() != In.Size) ||
182181
(InStatus.get().getLastModificationTime() != In.LastModTime)) {
182+
LLVM_DEBUG(llvm::dbgs() << "Dep " << In.Path
183+
<< " is directly out of date\n");
183184
return false;
184185
}
186+
// Recursively probe any .swiftmodules for up-to-date-ness.
187+
auto Ext = llvm::sys::path::extension(In.Path);
188+
auto Ty = file_types::lookupTypeForExtension(Ext);
189+
if (Ty == file_types::TY_SwiftModuleFile &&
190+
!swiftModuleIsUpToDate(FS, In.Path)) {
191+
LLVM_DEBUG(llvm::dbgs() << "Dep " << In.Path
192+
<< " is indirectly out of date\n");
193+
return false;
194+
}
195+
LLVM_DEBUG(llvm::dbgs() << "Dep " << In.Path << " is up to date\n");
185196
}
186197
return true;
187198
}
@@ -301,7 +312,7 @@ std::error_code ParseableInterfaceModuleLoader::openModuleFiles(
301312
configureSubInvocationAndOutputPaths(SubInvocation, InPath, OutPath);
302313

303314
// Evaluate if we need to run this sub-invocation, and if so run it.
304-
if (!swiftModuleIsUpToDate(FS, InPath, OutPath)) {
315+
if (!swiftModuleIsUpToDate(FS, OutPath)) {
305316
if (buildSwiftModuleFromSwiftInterface(FS, Diags, SubInvocation, InPath,
306317
OutPath))
307318
return std::make_error_code(std::errc::invalid_argument);

0 commit comments

Comments
 (0)