Skip to content

Commit 3ece004

Browse files
committed
Record initial parent map
We need to be able to traverse back to the top of expressions in order to emit the diagnostic to the right place. This patch records the parent map of the highest expression in the tree that the checker was constructed with. This will record the mapping for all sub-expressions as well.
1 parent a7b4d36 commit 3ece004

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/Sema/TypeCheckEffects.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2119,6 +2119,8 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
21192119
/// context.
21202120
ConditionalEffectKind MaxThrowingKind;
21212121

2122+
llvm::DenseMap<Expr *, Expr *> parentMap;
2123+
21222124
void flagInvalidCode() {
21232125
// Suppress warnings about useless try or catch.
21242126
Flags.set(ContextFlags::HasAnyThrowSite);
@@ -2297,7 +2299,11 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
22972299
}
22982300

22992301
private:
2300-
void visitExprPre(Expr *expr) { return; }
2302+
void visitExprPre(Expr *expr) {
2303+
if (parentMap.count(expr) == 0)
2304+
parentMap = expr->getParentMap();
2305+
return;
2306+
}
23012307

23022308
ShouldRecurse_t checkClosure(ClosureExpr *E) {
23032309
ContextScope scope(*this, Context::forClosure(E));

0 commit comments

Comments
 (0)