summaryrefslogtreecommitdiff
path: root/src/ast/branch-utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast/branch-utils.h')
-rw-r--r--src/ast/branch-utils.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/ast/branch-utils.h b/src/ast/branch-utils.h
index bdf52d36a..853b998af 100644
--- a/src/ast/branch-utils.h
+++ b/src/ast/branch-utils.h
@@ -37,6 +37,15 @@ inline bool isBranchTaken(Switch* sw) {
sw->condition->type != unreachable;
}
+inline bool isBranchTaken(Expression* expr) {
+ if (auto* br = expr->dynCast<Break>()) {
+ return isBranchTaken(br);
+ } else if (auto* sw = expr->dynCast<Switch>()) {
+ return isBranchTaken(sw);
+ }
+ WASM_UNREACHABLE();
+}
+
// returns the set of targets to which we branch that are
// outside of a node
inline std::set<Name> getExitingBranches(Expression* ast) {