mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
SILGen: Mark function escapes for script globals captured by closures.
We did this for func decls in script, so that DI can flag func decls that access script globals before they've been initialized, but we failed to do so for closures, causing us to miss DI violations when closures referenced script globals before their initialization. Fixes rdar://problem/24357063.
This commit is contained in:
@@ -378,6 +378,14 @@ SILGenFunction::emitClosureValue(SILLocation loc, SILDeclRef constant,
|
||||
wasSpecialized = true;
|
||||
}
|
||||
|
||||
// If we're in top-level code, we don't need to physically capture script
|
||||
// globals, but we still need to mark them as escaping so that DI can flag
|
||||
// uninitialized uses.
|
||||
if (this == SGM.TopLevelSGF) {
|
||||
SGM.emitMarkFunctionEscapeForTopLevelCodeGlobals(loc,
|
||||
TheClosure.getCaptureInfo());
|
||||
}
|
||||
|
||||
if (!TheClosure.getCaptureInfo().hasLocalCaptures() && !wasSpecialized) {
|
||||
auto result = ManagedValue::forUnmanaged(functionRef);
|
||||
return emitOrigToSubstValue(loc, result,
|
||||
|
||||
Reference in New Issue
Block a user