Skip to content

Commit

Permalink
Get around limitation of g++-4.8 (apache#4626)
Browse files Browse the repository at this point in the history
  • Loading branch information
tqchen authored and alexwong committed Feb 26, 2020
1 parent ce5dc69 commit c4ac8c6
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 ExprMutator::VisitExpr(e);
}

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

0 comments on commit c4ac8c6

Please sign in to comment.