Skip to content

Commit

Permalink
Get around limitation of g++-4.8
Browse files Browse the repository at this point in the history
  • Loading branch information
tqchen committed Jan 5, 2020
1 parent 00a6474 commit cea277d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/pass/ir_functor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,28 @@ class IRTransformer final :
f_postorder_(f_postorder),
only_enable_(only_enable) {
}

Stmt VisitStmt(const Stmt& stmt) final {
return MutateInternal<Stmt>(stmt, [this](const Stmt& s) {
return StmtMutator::VisitStmt(s);
return this->BaseVisitStmt(s);
});
}
Expr VisitExpr(const Expr& expr) final {
return MutateInternal<Expr>(expr, [this](const Expr& e) {
return ExprMutator::VisitExpr(e);
return this->BaseVisitExpr(e);
});
}

private:
// NOTE: redirect to parent's call
// This is used to get around limitation of gcc-4.8
Stmt BaseVisitStmt(const Stmt& s) {
return StmtMutator::VisitStmt(s);
}
Expr BaseVisitExpr(const Expr& e) {
return StmtMutator::VisitExpr(e);
}

template <typename T, typename F>
T MutateInternal(const T& node, F fmutate) {
if (only_enable_.size() &&
Expand Down

0 comments on commit cea277d

Please sign in to comment.