From d09cd98bd3df9920f0ecab97615048c0594e8f7f Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sun, 19 Jul 2026 23:23:22 +0200 Subject: Add clang-tidy support --- gcc/Make-lang.in | 2 +- gcc/gcc/elna-generic.cc | 55 +++++++++++++++++++++++++------------------------ 2 files changed, 29 insertions(+), 28 deletions(-) (limited to 'gcc') diff --git a/gcc/Make-lang.in b/gcc/Make-lang.in index ecb0141..5b8b6a8 100644 --- a/gcc/Make-lang.in +++ b/gcc/Make-lang.in @@ -155,7 +155,7 @@ elna.stagefeedback: stagefeedback-start -mv elna/*$(objext) stagefeedback/elna ELNA_INCLUDES = -I $(srcdir)/elna/include -I elna/generated -ELNA_CXXFLAGS = -std=c++17 +ELNA_CXXFLAGS = -std=c++20 elna/%.o: elna/boot/%.cc elna/generated/parser.hh elna/generated/location.hh $(COMPILE) $(ELNA_CXXFLAGS) $(ELNA_INCLUDES) $< diff --git a/gcc/gcc/elna-generic.cc b/gcc/gcc/elna-generic.cc index b13fd2f..79207cc 100644 --- a/gcc/gcc/elna-generic.cc +++ b/gcc/gcc/elna-generic.cc @@ -17,6 +17,7 @@ along with GCC; see the file COPYING3. If not see #include #include +#include #include "elna/boot/evaluator.h" #include "elna/gcc/elna-diagnostic.h" @@ -29,9 +30,7 @@ along with GCC; see the file COPYING3. If not see #include "cgraph.h" #include "gimplify.h" #include "stringpool.h" -#include "diagnostic.h" #include "realmpfr.h" -#include "varasm.h" #include "fold-const.h" #include "langhooks.h" @@ -407,7 +406,7 @@ namespace elna::gcc this->current_expression = build_int_cstu(elna_char_type_node, character->value); } - void generic_visitor::visit(boot::literal *) + void generic_visitor::visit(boot::literal *) { this->current_expression = elna_pointer_nil_node; } @@ -580,54 +579,55 @@ namespace elna::gcc } switch (expression->operation()) { - case boot::binary_operator::sum: + using enum boot::binary_operator; + case sum: this->current_expression = build_arithmetic_operation(expression, PLUS_EXPR, left, right); break; - case boot::binary_operator::subtraction: + case subtraction: this->current_expression = build_arithmetic_operation(expression, MINUS_EXPR, left, right); break; - case boot::binary_operator::division: + case division: this->current_expression = build_arithmetic_operation(expression, TRUNC_DIV_EXPR, left, right); break; - case boot::binary_operator::remainder: + case remainder: this->current_expression = build_arithmetic_operation(expression, TRUNC_MOD_EXPR, left, right); break; - case boot::binary_operator::multiplication: + case multiplication: this->current_expression = build_arithmetic_operation(expression, MULT_EXPR, left, right); break; - case boot::binary_operator::less: + case less: this->current_expression = build_comparison_operation(expression, LT_EXPR, left, right); break; - case boot::binary_operator::greater: + case greater: this->current_expression = build_comparison_operation(expression, GT_EXPR, left, right); break; - case boot::binary_operator::less_equal: + case less_equal: this->current_expression = build_comparison_operation(expression, LE_EXPR, left, right); break; - case boot::binary_operator::greater_equal: + case greater_equal: this->current_expression = build_comparison_operation(expression, GE_EXPR, left, right); break; - case boot::binary_operator::conjunction: + case conjunction: this->current_expression = build_bit_logic_operation(expression, left, right); break; - case boot::binary_operator::disjunction: + case disjunction: this->current_expression = build_bit_logic_operation(expression, left, right); break; - case boot::binary_operator::exclusive_disjunction: + case exclusive_disjunction: this->current_expression = build_bit_logic_operation(expression, left, right); break; - case boot::binary_operator::equals: + case equals: this->current_expression = build_equality_operation(expression, left, right); break; - case boot::binary_operator::not_equals: + case not_equals: this->current_expression = build_equality_operation(expression, left, right); break; - case boot::binary_operator::shift_left: + case shift_left: this->current_expression = build_binary_operation( is_numeric_type(left_type) && right_type == elna_word_type_node, expression, LSHIFT_EXPR, left, right, left_type); break; - case boot::binary_operator::shift_right: + case shift_right: this->current_expression = build_binary_operation( is_numeric_type(left_type) && right_type == elna_word_type_node, expression, RSHIFT_EXPR, left, right, left_type); @@ -642,7 +642,8 @@ namespace elna::gcc switch (expression->operation()) { - case boot::unary_operator::reference: + using enum boot::unary_operator; + case reference: this->current_expression = prepare_rvalue(this->current_expression); TREE_ADDRESSABLE(this->current_expression) = 1; this->current_expression = build_fold_addr_expr_with_type_loc(location, @@ -650,7 +651,7 @@ namespace elna::gcc build_pointer_type(TREE_TYPE(this->current_expression))); TREE_NO_TRAMPOLINE(this->current_expression) = 1; break; - case boot::unary_operator::negation: + case negation: { tree operand_type = TREE_TYPE(this->current_expression); @@ -666,7 +667,7 @@ namespace elna::gcc } break; } - case boot::unary_operator::minus: + case minus: { tree operand_type = TREE_TYPE(this->current_expression); @@ -674,7 +675,7 @@ namespace elna::gcc operand_type, this->current_expression); break; } - case boot::unary_operator::plus: + case plus: // Identity: operand already in current_expression. break; } @@ -1034,9 +1035,9 @@ namespace elna::gcc } auto& branches = statement->branches; - for (auto it = branches.rbegin(); it != branches.rend(); ++it) + for (auto& branch : branches | std::views::reverse) { - result = make_if_branch(**it, result); + result = make_if_branch(*branch, result); } result = make_if_branch(statement->branch(), result); @@ -1087,9 +1088,9 @@ namespace elna::gcc tree result = NULL_TREE; auto& branches = statement->branches; - for (auto it = branches.rbegin(); it != branches.rend(); ++it) + for (auto& branch : branches | std::views::reverse) { - result = make_if_branch(**it, result, goto_check); + result = make_if_branch(*branch, result, goto_check); } result = make_if_branch(statement->branch(), result, goto_check); -- cgit v1.2.3