diff options
-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; |