Skip to content

Commit ab3a1f6

Browse files
authored
Copying fixes (#2289)
We didn't have an OverriddenVisitor in the copying code, and sadly unimplemented visitors just return null. That explains the crash in #2288 The missing visitors were push and pop.
1 parent bf4737b commit ab3a1f6

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/ir/ExpressionManipulator.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace ExpressionManipulator {
2424

2525
Expression*
2626
flexibleCopy(Expression* original, Module& wasm, CustomCopier custom) {
27-
struct Copier : public Visitor<Copier, Expression*> {
27+
struct Copier : public OverriddenVisitor<Copier, Expression*> {
2828
Module& wasm;
2929
CustomCopier custom;
3030

@@ -41,7 +41,7 @@ flexibleCopy(Expression* original, Module& wasm, CustomCopier custom) {
4141
if (ret) {
4242
return ret;
4343
}
44-
return Visitor<Copier, Expression*>::visit(curr);
44+
return OverriddenVisitor<Copier, Expression*>::visit(curr);
4545
}
4646

4747
Expression* visitBlock(Block* curr) {
@@ -223,6 +223,8 @@ flexibleCopy(Expression* original, Module& wasm, CustomCopier custom) {
223223
Expression* visitUnreachable(Unreachable* curr) {
224224
return builder.makeUnreachable();
225225
}
226+
Expression* visitPush(Push* curr) { return builder.makePush(curr->value); }
227+
Expression* visitPop(Pop* curr) { return builder.makePop(curr->type); }
226228
};
227229

228230
Copier copier(wasm, custom);

0 commit comments

Comments
 (0)