summaryrefslogtreecommitdiff
path: root/src/tools/fuzzing.h
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-03-15 07:54:55 -0700
committerGitHub <noreply@github.com>2021-03-15 07:54:55 -0700
commit528763d53426b05ab0d02c2aab741810316bb259 (patch)
treef8db25f8b96d25303b16056d141af653096c7212 /src/tools/fuzzing.h
parent81b6067b7b1edf50495dd3acf1465a62aec094e8 (diff)
downloadbinaryen-528763d53426b05ab0d02c2aab741810316bb259.tar.gz
binaryen-528763d53426b05ab0d02c2aab741810316bb259.tar.bz2
binaryen-528763d53426b05ab0d02c2aab741810316bb259.zip
Simplify fuzzer fixup code for names (#3688)
Rather than use delegates.h, we have helpers for scope names.
Diffstat (limited to 'src/tools/fuzzing.h')
-rw-r--r--src/tools/fuzzing.h48
1 files changed, 15 insertions, 33 deletions
diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h
index de03e943b..8283fccd1 100644
--- a/src/tools/fuzzing.h
+++ b/src/tools/fuzzing.h
@@ -27,6 +27,7 @@ high chance for set at start of loop
// TODO Generate exception handling instructions
+#include "ir/branch-utils.h"
#include "ir/memory-utils.h"
#include <ir/find_all.h>
#include <ir/literal-utils.h>
@@ -865,39 +866,20 @@ private:
void visitExpression(Expression* curr) {
// Note all scope names, and fix up all uses.
-
-#define DELEGATE_ID curr->_id
-
-#define DELEGATE_START(id) \
- auto* cast = curr->cast<id>(); \
- WASM_UNUSED(cast);
-
-#define DELEGATE_GET_FIELD(id, name) cast->name
-
-#define DELEGATE_FIELD_SCOPE_NAME_DEF(id, name) \
- if (cast->name.is()) { \
- if (seen.count(cast->name)) { \
- replace(); \
- } else { \
- seen.insert(cast->name); \
- } \
- }
-
-#define DELEGATE_FIELD_SCOPE_NAME_USE(id, name) replaceIfInvalid(cast->name);
-
-#define DELEGATE_FIELD_CHILD(id, name)
-#define DELEGATE_FIELD_OPTIONAL_CHILD(id, name)
-#define DELEGATE_FIELD_INT(id, name)
-#define DELEGATE_FIELD_INT_ARRAY(id, name)
-#define DELEGATE_FIELD_LITERAL(id, name)
-#define DELEGATE_FIELD_NAME(id, name)
-#define DELEGATE_FIELD_NAME_VECTOR(id, name)
-#define DELEGATE_FIELD_SCOPE_NAME_USE_VECTOR(id, name)
-#define DELEGATE_FIELD_SIGNATURE(id, name)
-#define DELEGATE_FIELD_TYPE(id, name)
-#define DELEGATE_FIELD_ADDRESS(id, name)
-
-#include "wasm-delegations-fields.h"
+ BranchUtils::operateOnScopeNameDefs(curr, [&](Name& name) {
+ if (name.is()) {
+ if (seen.count(name)) {
+ replace();
+ } else {
+ seen.insert(name);
+ }
+ }
+ });
+ BranchUtils::operateOnScopeNameUses(curr, [&](Name& name) {
+ if (name.is()) {
+ replaceIfInvalid(name);
+ }
+ });
}
bool replaceIfInvalid(Name target) {