From cea277dc29fa5039c042fe8546f5754b6994b084 Mon Sep 17 00:00:00 2001 From: tqchen Date: Sun, 5 Jan 2020 09:51:57 -0800 Subject: [PATCH] Get around limitation of g++-4.8 --- src/pass/ir_functor.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/pass/ir_functor.cc b/src/pass/ir_functor.cc index 7c06a853390f3..f336698815dcd 100644 --- a/src/pass/ir_functor.cc +++ b/src/pass/ir_functor.cc @@ -71,18 +71,28 @@ class IRTransformer final : f_postorder_(f_postorder), only_enable_(only_enable) { } + Stmt VisitStmt(const Stmt& stmt) final { return MutateInternal(stmt, [this](const Stmt& s) { - return StmtMutator::VisitStmt(s); + return this->BaseVisitStmt(s); }); } Expr VisitExpr(const Expr& expr) final { return MutateInternal(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 T MutateInternal(const T& node, F fmutate) { if (only_enable_.size() &&