diff options
author | Alon Zakai <azakai@google.com> | 2023-04-12 13:51:11 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-12 13:51:11 -0700 |
commit | 3a28c022e1607b012ecc6817aefcd14aa7470cce (patch) | |
tree | fd615900a9c77dbd74079e59e312f844678c4b0c /src | |
parent | cca4d1d42960226e8ad8b75a7e2401ab660cb774 (diff) | |
download | binaryen-3a28c022e1607b012ecc6817aefcd14aa7470cce.tar.gz binaryen-3a28c022e1607b012ecc6817aefcd14aa7470cce.tar.bz2 binaryen-3a28c022e1607b012ecc6817aefcd14aa7470cce.zip |
[NFC] Refactor some old fuzzer code (#5658)
A return value was unused, and we have BranchUtils::operateOnScopeNameDefs now
which can replace old manual code.
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/fuzzing/fuzzing.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index 58edbd0f5..0e6d41ec9 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -914,13 +914,11 @@ void TranslateToFuzzReader::fixAfterChanges(Function* func) { }); } - bool replaceIfInvalid(Name target) { + void replaceIfInvalid(Name target) { if (!hasBreakTarget(target)) { // There is no valid parent, replace with something trivially safe. replace(); - return true; } - return false; } void replace() { replaceCurrent(parent.makeTrivial(getCurrent()->type)); } @@ -932,17 +930,14 @@ void TranslateToFuzzReader::fixAfterChanges(Function* func) { Index i = controlFlowStack.size() - 1; while (1) { auto* curr = controlFlowStack[i]; - if (auto* block = curr->dynCast<Block>()) { - if (name == block->name) { - return true; + bool has = false; + BranchUtils::operateOnScopeNameDefs(curr, [&](Name& def) { + if (def == name) { + has = true; } - } else if (auto* loop = curr->dynCast<Loop>()) { - if (name == loop->name) { - return true; - } - } else { - // an if or a try, ignorable - assert(curr->is<If>() || curr->is<Try>()); + }); + if (has) { + return true; } if (i == 0) { return false; |