@@ -3167,12 +3167,13 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
3167
3167
// / anchor expression, so we can emit diagnostics at the end.
3168
3168
llvm::MapVector<Expr *, std::vector<UnsafeUse>> uncoveredUnsafeUses;
3169
3169
3170
- static bool isEffectAnchor (Expr *e) {
3170
+ static bool isEffectAnchor (Expr *e, bool stopAtAutoClosure ) {
3171
3171
if (e->getLoc ().isInvalid ())
3172
3172
return false ;
3173
3173
3174
- return isa<AbstractClosureExpr>(e) || isa<DiscardAssignmentExpr>(e) ||
3175
- isa<AssignExpr>(e) || (isa<DeclRefExpr>(e) && e->isImplicit ());
3174
+ return isa<ClosureExpr>(e) || isa<DiscardAssignmentExpr>(e) ||
3175
+ isa<AssignExpr>(e) ||
3176
+ (stopAtAutoClosure && isa<AutoClosureExpr>(e));
3176
3177
}
3177
3178
3178
3179
static bool isAnchorTooEarly (Expr *e) {
@@ -3181,11 +3182,12 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
3181
3182
3182
3183
// / Find the top location where we should put the await
3183
3184
static Expr *walkToAnchor (Expr *e, llvm::DenseMap<Expr *, Expr *> &parentMap,
3184
- bool isInterpolatedString) {
3185
+ bool isInterpolatedString,
3186
+ bool stopAtAutoClosure) {
3185
3187
llvm::SmallPtrSet<Expr *, 4 > visited;
3186
3188
Expr *parent = e;
3187
3189
Expr *lastParent = e;
3188
- while (parent && !isEffectAnchor (parent)) {
3190
+ while (parent && !isEffectAnchor (parent, stopAtAutoClosure )) {
3189
3191
lastParent = parent;
3190
3192
parent = parentMap[parent];
3191
3193
@@ -3890,7 +3892,8 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
3890
3892
Flags.has (ContextFlags::InAsyncLet))) {
3891
3893
Expr *expr = E.dyn_cast <Expr*>();
3892
3894
Expr *anchor = walkToAnchor (expr, parentMap,
3893
- CurContext.isWithinInterpolatedString ());
3895
+ CurContext.isWithinInterpolatedString (),
3896
+ /* stopAtAutoClosure=*/ true );
3894
3897
if (Flags.has (ContextFlags::StmtExprCoversAwait))
3895
3898
classification.setDowngradeToWarning (true );
3896
3899
if (uncoveredAsync.find (anchor) == uncoveredAsync.end ())
@@ -3915,7 +3918,8 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
3915
3918
if (!Flags.has (ContextFlags::IsUnsafeCovered)) {
3916
3919
Expr *expr = E.dyn_cast <Expr*>();
3917
3920
Expr *anchor = walkToAnchor (expr, parentMap,
3918
- CurContext.isWithinInterpolatedString ());
3921
+ CurContext.isWithinInterpolatedString (),
3922
+ /* stopAtAutoClosure=*/ false );
3919
3923
3920
3924
// Figure out a location to use if the unsafe use didn't have one.
3921
3925
SourceLoc replacementLoc;
0 commit comments