summaryrefslogtreecommitdiff
path: root/src/ir/export-utils.h
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-04-22 10:56:40 -0700
committerGitHub <noreply@github.com>2022-04-22 10:56:40 -0700
commite16f1e7f250a832742397a1f082c9ea161619ca8 (patch)
treece433a68075350520dae08c2ff77565b3c38d530 /src/ir/export-utils.h
parent2ab19d9ac528ff11fa14b184a84c92e72d5b0163 (diff)
downloadbinaryen-e16f1e7f250a832742397a1f082c9ea161619ca8.tar.gz
binaryen-e16f1e7f250a832742397a1f082c9ea161619ca8.tar.bz2
binaryen-e16f1e7f250a832742397a1f082c9ea161619ca8.zip
[NominalFuzzing] SignatureRefining: Ignore exported functions (#4601)
This hits the fuzzer when it tries to call reference exports with a null.
Diffstat (limited to 'src/ir/export-utils.h')
-rw-r--r--src/ir/export-utils.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/ir/export-utils.h b/src/ir/export-utils.h
new file mode 100644
index 000000000..245365fbc
--- /dev/null
+++ b/src/ir/export-utils.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2022 WebAssembly Community Group participants
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef wasm_ir_export_h
+#define wasm_ir_export_h
+
+#include "wasm.h"
+
+namespace wasm::ExportUtils {
+
+inline std::vector<Function*> getExportedFunctions(Module& wasm) {
+ std::vector<Function*> ret;
+ for (auto& ex : wasm.exports) {
+ if (ex->kind == ExternalKind::Function) {
+ ret.push_back(wasm.getFunction(ex->value));
+ }
+ }
+ return ret;
+}
+
+} // namespace wasm::ExportUtils
+
+#endif // wasm_ir_export_h