[Frontend] Move dependency verifier to end of pipeline

Allow the verification of dependencies before LLVM,
allowing the freeing of the ASTContext.
This commit is contained in:
Hamish Knight
2020-06-29 15:26:27 -07:00
parent 12ae72c808
commit 958bf8e3fd

View File

@@ -1270,6 +1270,19 @@ static void performEndOfPipelineActions(CompilerInstance &Instance) {
emitAnyWholeModulePostTypeCheckSupplementaryOutputs(Instance);
}
// Verify reference dependencies of the current compilation job. Note this
// must be run *before* verifying diagnostics so that the former can be tested
// via the latter.
if (opts.EnableIncrementalDependencyVerifier) {
if (!Instance.getPrimarySourceFiles().empty()) {
swift::verifyDependencies(Instance.getSourceMgr(),
Instance.getPrimarySourceFiles());
} else {
swift::verifyDependencies(Instance.getSourceMgr(),
Instance.getMainModule()->getFiles());
}
}
// Emit dependencies and index data.
emitReferenceDependenciesForAllPrimaryInputsIfNeeded(Instance);
emitIndexData(Instance);
@@ -1555,12 +1568,6 @@ static void freeASTContextIfPossible(CompilerInstance &Instance) {
return;
}
// Verifying incremental dependencies relies on access to the Swift Module's
// source files.
if (opts.EnableIncrementalDependencyVerifier) {
return;
}
// If there are multiple primary inputs it is too soon to free
// the ASTContext, etc.. OTOH, if this compilation generates code for > 1
// primary input, then freeing it after processing the last primary is
@@ -2228,19 +2235,6 @@ int swift::performFrontend(ArrayRef<const char *> Args,
Invocation.getFrontendOptions().DumpAPIPath);
}
// Verify reference dependencies of the current compilation job *before*
// verifying diagnostics so that the former can be tested via the latter.
if (Invocation.getFrontendOptions().EnableIncrementalDependencyVerifier) {
if (!Instance->getPrimarySourceFiles().empty()) {
HadError |= swift::verifyDependencies(Instance->getSourceMgr(),
Instance->getPrimarySourceFiles());
} else {
HadError |= swift::verifyDependencies(
Instance->getSourceMgr(),
Instance->getMainModule()->getFiles());
}
}
if (verifierEnabled) {
DiagnosticEngine &diags = Instance->getDiags();
if (diags.hasFatalErrorOccurred() &&