summaryrefslogtreecommitdiff
path: root/test/example
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2023-05-17 09:10:08 -0700
committerGitHub <noreply@github.com>2023-05-17 09:10:08 -0700
commitaab5f274773f4e1567b02e6950b4d22119cf801d (patch)
tree80e6c2dc4531f6a3822eb966695e1cfd770497bd /test/example
parent164c62b25f52c2263455d50852ca97890ac292ee (diff)
downloadbinaryen-aab5f274773f4e1567b02e6950b4d22119cf801d.tar.gz
binaryen-aab5f274773f4e1567b02e6950b4d22119cf801d.tar.bz2
binaryen-aab5f274773f4e1567b02e6950b4d22119cf801d.zip
EffectAnalyzer: Do not clear break targets before walk()/visit() (#5723)
We depend on repeated calls to walk/visit accumulating effects, so this was a bug; if we want to clear stuff then we create a new EffectAnalyzer. Removing that fixes the attached testcase. Also added a unit test.
Diffstat (limited to 'test/example')
-rw-r--r--test/example/cpp-unit.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/example/cpp-unit.cpp b/test/example/cpp-unit.cpp
index d2339f030..e3e1269c3 100644
--- a/test/example/cpp-unit.cpp
+++ b/test/example/cpp-unit.cpp
@@ -637,6 +637,19 @@ void test_effects() {
assert_equal(effects.readsMutableStruct, false);
assert_equal(effects.writesStruct, false);
}
+
+ {
+ EffectAnalyzer effects(options, module);
+
+ // If we break, then we transfer control flow.
+ effects.breakTargets.insert("block");
+ assert_equal(effects.transfersControlFlow(), true);
+
+ // Repeated walks accumulate effects, that is, old effects are not
+ // removed.
+ effects.walk(&nop);
+ assert_equal(effects.transfersControlFlow(), true);
+ }
}
void test_field() {