Merge pull request #17391 from DougGregor/output-request-graphviz

This commit is contained in:
swift-ci
2018-06-21 01:10:30 -07:00
committed by GitHub
7 changed files with 35 additions and 3 deletions

View File

@@ -855,6 +855,13 @@ emitIndexData(CompilerInvocation &Invocation, CompilerInstance &Instance) {
return hadEmitIndexDataError;
}
/// Emits the request-evaluator graph to the given file in GraphViz format.
void emitRequestEvaluatorGraphViz(ASTContext &ctx, StringRef graphVizPath) {
std::error_code error;
llvm::raw_fd_ostream out(graphVizPath, error, llvm::sys::fs::F_Text);
ctx.evaluator.printDependenciesGraphviz(out);
}
static bool performCompileStepsPostSILGen(
CompilerInstance &Instance, CompilerInvocation &Invocation,
std::unique_ptr<SILModule> SM, bool astGuaranteedToCorrespondToSIL,
@@ -894,6 +901,17 @@ static bool performCompile(CompilerInstance &Instance,
else
Instance.performSema();
SWIFT_DEFER {
// Emit request-evaluator graph via GraphViz, if requested.
if (!Invocation.getFrontendOptions().RequestEvaluatorGraphVizPath.empty() &&
Instance.hasASTContext()) {
ASTContext &ctx = Instance.getASTContext();
emitRequestEvaluatorGraphViz(
ctx,
Invocation.getFrontendOptions().RequestEvaluatorGraphVizPath);
}
};
if (Action == FrontendOptions::ActionType::Parse)
return Instance.getASTContext().hadError();