Introduce Name Binding as a Frontend Action

Introduces the -name-bind frontend action that is intended as an intermediary between the parse-only actions and a full typechecking pass.  In this phase, module imports will be validated and resolved, making it possible to emit full make-style dependencies files among other things.

Note that all information available to a parse-only pass is available to name binding, but because it does not continue-on to typecheck input files, full semantic information is not.
This commit is contained in:
Robert Widmann
2018-06-29 15:49:54 -07:00
parent c440b0ba5a
commit cb1e9dd821
8 changed files with 89 additions and 29 deletions

View File

@@ -895,11 +895,14 @@ static bool performCompile(CompilerInstance &Instance,
if (Invocation.getInputKind() == InputFileKind::IFK_LLVM_IR)
return compileLLVMIR(Invocation, Instance, Stats);
if (FrontendOptions::shouldActionOnlyParse(Action))
if (FrontendOptions::shouldActionOnlyParse(Action)) {
Instance.performParseOnly(/*EvaluateConditionals*/
Action == FrontendOptions::ActionType::EmitImportedModules);
else
} else if (Action == FrontendOptions::ActionType::NameBind) {
Instance.performParseAndNameBindingOnly();
} else {
Instance.performSema();
}
SWIFT_DEFER {
// Emit request-evaluator graph via GraphViz, if requested.
@@ -912,8 +915,15 @@ static bool performCompile(CompilerInstance &Instance,
}
};
ASTContext &Context = Instance.getASTContext();
if (Action == FrontendOptions::ActionType::Parse)
return Instance.getASTContext().hadError();
return Context.hadError();
(void)emitMakeDependenciesIfNeeded(Context.Diags,
Instance.getDependencyTracker(), opts);
if (Action == FrontendOptions::ActionType::NameBind)
return Context.hadError();
if (observer)
observer->performedSemanticAnalysis(Instance);
@@ -929,8 +939,6 @@ static bool performCompile(CompilerInstance &Instance,
debugFailWithCrash();
}
ASTContext &Context = Instance.getASTContext();
verifyGenericSignaturesIfNeeded(Invocation, Context);
(void)migrator::updateCodeAndEmitRemapIfNeeded(&Instance, Invocation);
@@ -948,9 +956,6 @@ static bool performCompile(CompilerInstance &Instance,
if (opts.PrintClangStats && Context.getClangModuleLoader())
Context.getClangModuleLoader()->printStatistics();
(void)emitMakeDependenciesIfNeeded(Context.Diags,
Instance.getDependencyTracker(), opts);
emitReferenceDependenciesForAllPrimaryInputsIfNeeded(Invocation, Instance);
(void)emitLoadedModuleTraceForAllPrimariesIfNeeded(