From d0ce7b8ba33778aae39bdc55b03fd5281e64d8f3 Mon Sep 17 00:00:00 2001 From: Stephane Del Pino <stephane.delpino44@gmail.com> Date: Thu, 12 Dec 2019 17:15:41 +0100 Subject: [PATCH] Remove a bunch of useless remove_content --- src/language/ASTBuilder.cpp | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/language/ASTBuilder.cpp b/src/language/ASTBuilder.cpp index 6d1b00f89..462a7004e 100644 --- a/src/language/ASTBuilder.cpp +++ b/src/language/ASTBuilder.cpp @@ -22,7 +22,6 @@ struct ASTBuilder::rearrange : parse_tree::apply<ASTBuilder::rearrange> } else { // First we rearrange tree { - n->remove_content(); auto& children = n->children; auto rhs = std::move(children.back()); children.pop_back(); @@ -39,7 +38,6 @@ struct ASTBuilder::rearrange : parse_tree::apply<ASTBuilder::rearrange> Assert(n->children.size() == 2); auto& rhs = n->children[1]; if (rhs->is_type<language::unary_minus>()) { - rhs->remove_content(); n->set_type<language::plus_op>(); rhs = std::move(rhs->children[0]); } @@ -47,7 +45,6 @@ struct ASTBuilder::rearrange : parse_tree::apply<ASTBuilder::rearrange> Assert(n->children.size() == 2); auto& rhs = n->children[1]; if (rhs->is_type<language::unary_minus>()) { - rhs->remove_content(); n->set_type<language::minus_op>(); rhs = std::move(rhs->children[0]); } @@ -65,40 +62,32 @@ struct ASTBuilder::simplify_unary : parse_tree::apply<ASTBuilder::simplify_unary { if (n->children.size() == 1) { if (n->is_type<unary_expression>() or n->is_type<type_expression>()) { - n->remove_content(); n = std::move(n->children.back()); transform(n, st...); } else if (n->is_type<unary_minus>()) { auto& child = n->children[0]; if (child->is_type<unary_minus>()) { - n->remove_content(); - child->remove_content(); n = std::move(child->children[0]); transform(n, st...); } } else if (n->is_type<unary_not>()) { auto& child = n->children[0]; if (child->is_type<unary_not>()) { - n->remove_content(); - child->remove_content(); n = std::move(child->children[0]); transform(n, st...); } } } else if (n->children.size() == 2) { if (n->children[0]->is_type<language::unary_plus>()) { - n->remove_content(); n = std::move(n->children[1]); transform(n, st...); } else if (n->children[0]->is_type<language::unary_minus>() or n->children[0]->is_type<language::unary_not>() or n->children[0]->is_type<language::unary_minusminus>() or n->children[0]->is_type<language::unary_plusplus>()) { - n->remove_content(); auto expression = std::move(n->children[1]); auto unary_operator = std::move(n->children[0]); unary_operator->children.emplace_back(std::move(expression)); n = std::move(unary_operator); - n->remove_content(); transform(n, st...); } } @@ -111,11 +100,9 @@ struct ASTBuilder::simplify_unary : parse_tree::apply<ASTBuilder::simplify_unary auto unary_operator = std::move(n->children[child_nb - 1]); n->children.pop_back(); - unary_operator->remove_content(); unary_operator->children.emplace_back(std::move(n)); n = std::move(unary_operator); - n->remove_content(); transform(n->children[0], st...); } } @@ -132,7 +119,6 @@ struct ASTBuilder::simplify_node_list : parse_tree::apply<ASTBuilder::simplify_n if (n->is_type<language::name_list>() or n->is_type<language::function_argument_list>() or n->is_type<language::expression_list>()) { if (n->children.size() == 1) { - n->remove_content(); n = std::move(n->children.back()); transform(n, st...); } @@ -148,7 +134,6 @@ struct ASTBuilder::simplify_statement_block : parse_tree::apply<ASTBuilder::simp { if ((n->is_type<language::statement_block>() or n->is_type<language::block>()) and (n->children.size() == 1)) { if (not n->children[0]->is_type<language::declaration>()) { - n->remove_content(); n = std::move(n->children.back()); transform(n, st...); } else { @@ -165,7 +150,6 @@ struct ASTBuilder::simplify_for_statement_block : parse_tree::apply<ASTBuilder:: transform(std::unique_ptr<ASTNode>& n, States&&... st) { if ((n->is_type<language::for_statement_block>() or n->is_type<language::block>()) and (n->children.size() == 1)) { - n->remove_content(); n = std::move(n->children.back()); transform(n, st...); } @@ -180,7 +164,6 @@ struct ASTBuilder::simplify_for_init : parse_tree::apply<ASTBuilder::simplify_fo { Assert(n->children.size() <= 1); if (n->children.size() == 1) { - n->remove_content(); n = std::move(n->children.back()); } } @@ -194,7 +177,6 @@ struct ASTBuilder::simplify_for_test : parse_tree::apply<ASTBuilder::simplify_fo { Assert(n->children.size() <= 1); if (n->children.size() == 1) { - n->remove_content(); n = std::move(n->children.back()); } } @@ -208,7 +190,6 @@ struct ASTBuilder::simplify_for_post : parse_tree::apply<ASTBuilder::simplify_fo { Assert(n->children.size() <= 1); if (n->children.size() == 1) { - n->remove_content(); n = std::move(n->children.back()); } } @@ -223,7 +204,6 @@ struct ASTBuilder::simplify_stream_statement : parse_tree::apply<ASTBuilder::sim for (size_t i = 1; i < n->children.size(); ++i) { n->children[0]->children.emplace_back(std::move(n->children[i])); } - n->remove_content(); n = std::move(n->children[0]); } }; -- GitLab