From f12c4fe2eaab41eeb1c5d67984695342d3e1a361 Mon Sep 17 00:00:00 2001 From: Tianqi Chen Date: Sun, 5 Jan 2020 17:52:30 -0800 Subject: [PATCH] Get around limitation of g++-4.8 (#4626) --- 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 7c06a85..efc43a2 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 ExprMutator::VisitExpr(e); + } + template T MutateInternal(const T& node, F fmutate) { if (only_enable_.size() && -- 2.7.4