mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Type checker] Keep the type checker alive as long as the ASTContext is.
It is possible for the SIL optimizers, IRGen, etc. to request information from the AST that only the type checker can provide, but the type checker is typically torn down after the “type checking” phase. This can lead to various crashes late in the compilation cycle. Keep the type checker instance around as long as the ASTContext is alive or until someone asks for it to be destroyed. Fixes SR-285 / rdar://problem/23677338.
This commit is contained in:
@@ -960,8 +960,7 @@ static bool reportModuleDocInfo(CompilerInvocation Invocation,
|
||||
return true;
|
||||
|
||||
ASTContext &Ctx = CI.getASTContext();
|
||||
// Setup a typechecker for protocol conformance resolving.
|
||||
OwnedResolver TypeResolver = createLazyResolver(Ctx);
|
||||
(void)createTypeChecker(Ctx);
|
||||
|
||||
SourceTextInfo IFaceInfo;
|
||||
if (getModuleInterfaceInfo(Ctx, ModuleName, IFaceInfo))
|
||||
@@ -1089,7 +1088,7 @@ static bool reportSourceDocInfo(CompilerInvocation Invocation,
|
||||
CI.performSema();
|
||||
|
||||
// Setup a typechecker for protocol conformance resolving.
|
||||
OwnedResolver TypeResolver = createLazyResolver(Ctx);
|
||||
(void)createTypeChecker(Ctx);
|
||||
|
||||
SourceTextInfo SourceInfo;
|
||||
if (getSourceTextInfo(CI, SourceInfo))
|
||||
@@ -1447,7 +1446,8 @@ findModuleGroups(StringRef ModuleName, ArrayRef<const char *> Args,
|
||||
|
||||
ASTContext &Ctx = CI.getASTContext();
|
||||
// Setup a typechecker for protocol conformance resolving.
|
||||
OwnedResolver TypeResolver = createLazyResolver(Ctx);
|
||||
(void)createTypeChecker(Ctx);
|
||||
|
||||
// Load standard library so that Clang importer can use it.
|
||||
auto *Stdlib = getModuleByFullName(Ctx, Ctx.StdlibModuleName);
|
||||
if (!Stdlib) {
|
||||
|
||||
Reference in New Issue
Block a user