From 25e654cd0334e77ef7e15a600dbc564f58862e64 Mon Sep 17 00:00:00 2001 From: Alessandro Cattabiani Date: Thu, 16 Apr 2020 15:19:46 +0200 Subject: [PATCH] Remove virtual from set_parent_for_children (#296) * Remove virtual from set_parent_for_children (issue #296) - set_parent_for_children is called only in the constructors. The virtual keyword unnecessary and generates only confusion. - Remove virtual from set_parent_for_children (issue #295) - set_parent_in_children() visibility is now private Co-authored-by: Tristan Carel fixes #295 --- src/language/templates/ast/ast.cpp | 4 ---- src/language/templates/ast/ast.hpp | 17 ++++++----------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/language/templates/ast/ast.cpp b/src/language/templates/ast/ast.cpp index d2f7591b87..ab68e49b48 100644 --- a/src/language/templates/ast/ast.cpp +++ b/src/language/templates/ast/ast.cpp @@ -73,10 +73,6 @@ void Ast::set_parent(Ast* p) { parent = p; } -void Ast::set_parent_in_children() { - throw std::runtime_error("set_parent_in_children not implemented"); -} - {% for node in nodes %} diff --git a/src/language/templates/ast/ast.hpp b/src/language/templates/ast/ast.hpp index e70d98b03c..a8378df45a 100644 --- a/src/language/templates/ast/ast.hpp +++ b/src/language/templates/ast/ast.hpp @@ -348,14 +348,6 @@ struct Ast: public std::enable_shared_from_this { * \ref Check Ast::parent for more information */ virtual void set_parent(Ast* p); - - /** - *\brief Set this object as parent for all the children - * - * This should be called in every object (with children) constructor - * to set the parents. - */ - virtual void set_parent_in_children(); }; /** @} */ // end of ast_class @@ -714,12 +706,15 @@ struct Ast: public std::enable_shared_from_this { {% endif %} {% if node.children %} + private: /** - * \brief Set parents in children + *\brief Set this object as parent for all the children * - * Usually called in constructors + * This should be called in every object (with children) constructor + * to set parents. Since it is called only in the constructors it + * should not be virtual to avoid ambiguities (issue #295). */ - virtual void set_parent_in_children() override; + void set_parent_in_children(); {% endif %} };