summaryrefslogtreecommitdiff
path: root/src/ir/branch-utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/ir/branch-utils.h')
-rw-r--r--src/ir/branch-utils.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/ir/branch-utils.h b/src/ir/branch-utils.h
index 9598e2830..3c0275701 100644
--- a/src/ir/branch-utils.h
+++ b/src/ir/branch-utils.h
@@ -75,6 +75,13 @@ void operateOnScopeNameUsesAndSentTypes(Expression* expr, T func) {
func(name, sw->value ? sw->value->type : Type::none);
} else if (auto* br = expr->dynCast<BrOn>()) {
func(name, br->getSentType());
+ } else if (auto* tt = expr->dynCast<TryTable>()) {
+ for (Index i = 0; i < tt->catchTags.size(); i++) {
+ auto dest = tt->catchDests[i];
+ if (dest == name) {
+ func(name, tt->sentTypes[i]);
+ }
+ }
} else {
assert(expr->is<Try>() || expr->is<Rethrow>()); // delegate or rethrow
}
@@ -82,7 +89,8 @@ void operateOnScopeNameUsesAndSentTypes(Expression* expr, T func) {
}
// Similar to operateOnScopeNameUses, but also passes in the expression that is
-// sent if the branch is taken. nullptr is given if there is no value.
+// sent if the branch is taken. nullptr is given if there is no value or there
+// is a value but it is not known statically.
template<typename T>
void operateOnScopeNameUsesAndSentValues(Expression* expr, T func) {
operateOnScopeNameUses(expr, [&](Name& name) {
@@ -94,6 +102,10 @@ void operateOnScopeNameUsesAndSentValues(Expression* expr, T func) {
func(name, sw->value);
} else if (auto* br = expr->dynCast<BrOn>()) {
func(name, br->ref);
+ } else if (auto* tt = expr->dynCast<TryTable>()) {
+ // The values are supplied by throwing instructions, so we are unable to
+ // know what they will be here.
+ func(name, nullptr);
} else {
assert(expr->is<Try>() || expr->is<Rethrow>()); // delegate or rethrow
}