mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Wrap SE-0481 into an upcoming feature until source incompatibilities are resolved
This commit is contained in:
@@ -515,9 +515,11 @@ void LabeledConditionalStmt::setCond(StmtCondition e) {
|
||||
/// - If `requiresCaptureListRef` is `true`, additionally requires that the
|
||||
/// RHS of the self condition references a var defined in a capture list.
|
||||
bool LabeledConditionalStmt::rebindsSelf(ASTContext &Ctx,
|
||||
bool requiresCaptureListRef) const {
|
||||
return llvm::any_of(getCond(), [&Ctx, requiresCaptureListRef](const auto &cond) {
|
||||
return cond.rebindsSelf(Ctx, requiresCaptureListRef);
|
||||
bool requiresCaptureListRef,
|
||||
bool requireLoadExpr) const {
|
||||
return llvm::any_of(getCond(), [&Ctx, requiresCaptureListRef,
|
||||
requireLoadExpr](const auto &cond) {
|
||||
return cond.rebindsSelf(Ctx, requiresCaptureListRef, requireLoadExpr);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -526,7 +528,8 @@ bool LabeledConditionalStmt::rebindsSelf(ASTContext &Ctx,
|
||||
/// - If `requiresCaptureListRef` is `true`, additionally requires that the
|
||||
/// RHS of the self condition references a var defined in a capture list.
|
||||
bool StmtConditionElement::rebindsSelf(ASTContext &Ctx,
|
||||
bool requiresCaptureListRef) const {
|
||||
bool requiresCaptureListRef,
|
||||
bool requireLoadExpr) const {
|
||||
auto pattern = getPatternOrNull();
|
||||
if (!pattern) {
|
||||
return false;
|
||||
@@ -554,6 +557,10 @@ bool StmtConditionElement::rebindsSelf(ASTContext &Ctx,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (requireLoadExpr && !isa<LoadExpr>(exprToCheckForDRE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (auto *load = dyn_cast<LoadExpr>(exprToCheckForDRE)) {
|
||||
exprToCheckForDRE = load->getSubExpr();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user