Skip to content

Commit 4107d02

Browse files
committed
[SourceKit] Verify the stdlib is loaded before creating an AST
We have seen a couple of crashes that look like they are being caused by `sourcekitd` being unable to load the Swift stdlib. Emit a proper error message explaining the issue instead of crashing. This change assumes that all sourcekitd requests that create an AST require the stdlib. IMHO this is a reasonable assumption. Fixes rdar://75740572 by catching the crash in the new check.
1 parent fd8e349 commit 4107d02

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,11 @@ ASTUnitRef ASTProducer::createASTUnit(
848848
Error = "compilation setup failed";
849849
return nullptr;
850850
}
851+
if (CompIns.loadStdlibIfNeeded()) {
852+
LOG_WARN_FUNC("Loading the stdlib failed");
853+
Error = "Loading the stdlib failed";
854+
return nullptr;
855+
}
851856
registerIDERequestFunctions(CompIns.getASTContext().evaluator);
852857
if (TracedOp.enabled()) {
853858
TracedOp.start(TraceInfo);

0 commit comments

Comments
 (0)