Frontend: Fix crash when -stats-output-dir used with -typecheck-module-from-interface

There's no ASTContext in this case, so we just skip initializing stats if
the driver passes this flag down to us.
This commit is contained in:
Slava Pestov
2024-10-25 16:24:10 -04:00
parent ffaee52eb4
commit 9cd5b03466
2 changed files with 6 additions and 1 deletions

View File

@@ -563,7 +563,9 @@ bool CompilerInstance::setup(const CompilerInvocation &Invoke,
return true;
}
setupStatsReporter();
if (hasASTContext()) {
setupStatsReporter();
}
if (setupDiagnosticVerifierIfNeeded()) {
Error = "Setting up diagnostics verifier failed";

View File

@@ -0,0 +1,3 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-emit-module-interface(%t/foo.swiftinterface) %s -module-name foo
// RUN: %target-swift-frontend -typecheck-module-from-interface %t/foo.swiftinterface -stats-output-dir %t