From 3a28c022e1607b012ecc6817aefcd14aa7470cce Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 12 Apr 2023 13:51:11 -0700 Subject: [NFC] Refactor some old fuzzer code (#5658) A return value was unused, and we have BranchUtils::operateOnScopeNameDefs now which can replace old manual code. --- src/tools/fuzzing/fuzzing.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'src/tools/fuzzing/fuzzing.cpp') 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()) { - 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()) { - if (name == loop->name) { - return true; - } - } else { - // an if or a try, ignorable - assert(curr->is() || curr->is()); + }); + if (has) { + return true; } if (i == 0) { return false; -- cgit v1.2.3