mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[OwnershipUtils] Undef isn't introduced/enclosed.
Previously, calling `visitEnclosingDefs` or `visitBorrowIntroducers` would crash if the `SILValue` argument were an instance of `SILUndef` because both instantiate a `::FindEnclosingDefs` with the the result of of calling `getFunction()` on that argument and `::FindEnclosingDefs` in turn uses that result to create a `ValueSet`; but `SILUndef::getFunction` returns `nullptr`, which is illegal to use as the function for a `ValueSet`(or any other data structure relying on `NodeBits`). If the function specified as a separate argument, no values would be visited and `true` would be returned. Instead of burdening the API with a separate argument, check for `SILUndef` up front and return `true`.
This commit is contained in:
@@ -2230,12 +2230,16 @@ protected:
|
||||
|
||||
bool swift::visitEnclosingDefs(SILValue value,
|
||||
function_ref<bool(SILValue)> visitor) {
|
||||
if (isa<SILUndef>(value))
|
||||
return true;
|
||||
return FindEnclosingDefs(value->getFunction())
|
||||
.visitEnclosingDefs(value, visitor);
|
||||
}
|
||||
|
||||
bool swift::visitBorrowIntroducers(SILValue value,
|
||||
function_ref<bool(SILValue)> visitor) {
|
||||
if (isa<SILUndef>(value))
|
||||
return true;
|
||||
return FindEnclosingDefs(value->getFunction())
|
||||
.visitBorrowIntroducers(value, visitor);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user