[Frontend] Support -index-store-path for explicit module interface compilation.

This commit is contained in:
Tony Allevato
2025-02-16 14:44:49 -05:00
committed by Tony Allevato
parent 2a76cc13f6
commit 5fd985256c
2 changed files with 54 additions and 4 deletions

View File

@@ -974,6 +974,21 @@ static void dumpAPIIfNeeded(const CompilerInstance &Instance) {
}
}
static bool shouldEmitIndexData(const CompilerInvocation &Invocation) {
const auto &opts = Invocation.getFrontendOptions();
auto action = opts.RequestedAction;
if (action == FrontendOptions::ActionType::CompileModuleFromInterface &&
opts.ExplicitInterfaceBuild) {
return true;
}
// FIXME: This predicate matches the status quo, but there's no reason
// indexing cannot run for actions that do not require stdlib e.g. to better
// facilitate tests.
return FrontendOptions::doesActionRequireSwiftStandardLibrary(action);
}
/// Perform any actions that must have access to the ASTContext, and need to be
/// delayed until the Swift compile pipeline has finished. This may be called
/// before or after LLVM depending on when the ASTContext gets freed.
@@ -1068,10 +1083,7 @@ static void performEndOfPipelineActions(CompilerInstance &Instance) {
}
}
// FIXME: This predicate matches the status quo, but there's no reason
// indexing cannot run for actions that do not require stdlib e.g. to better
// facilitate tests.
if (FrontendOptions::doesActionRequireSwiftStandardLibrary(action)) {
if (shouldEmitIndexData(Invocation)) {
emitIndexData(Instance);
}