Skip to content

Commit 7202402

Browse files
committed
Enusre that we cannot infinite-loop when finding expression parent
1 parent 88b28c3 commit 7202402

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/Sema/TypeCheckEffects.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3168,11 +3168,15 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
31683168
/// Find the top location where we should put the await
31693169
static Expr *walkToAnchor(Expr *e, llvm::DenseMap<Expr *, Expr *> &parentMap,
31703170
bool isInterpolatedString) {
3171+
llvm::SmallPtrSet<Expr *, 4> visited;
31713172
Expr *parent = e;
31723173
Expr *lastParent = e;
31733174
while (parent && !isEffectAnchor(parent)) {
31743175
lastParent = parent;
31753176
parent = parentMap[parent];
3177+
3178+
if (!visited.insert(parent).second)
3179+
break;
31763180
}
31773181

31783182
if (parent && !isAnchorTooEarly(parent)) {

0 commit comments

Comments
 (0)