From c12cd1f4fb541b3435c0d317e230ecad4964cf53 Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Fri, 8 Aug 2025 17:10:16 +1200 Subject: [PATCH] frontends/ast: More usage of auto For consistency. --- frontends/ast/genrtlil.cc | 6 +++--- frontends/ast/simplify.cc | 28 ++++++++++++++-------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/frontends/ast/genrtlil.cc b/frontends/ast/genrtlil.cc index 93731abf0..0002f6308 100644 --- a/frontends/ast/genrtlil.cc +++ b/frontends/ast/genrtlil.cc @@ -2086,7 +2086,7 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint) cell->set_bool_attribute(ID::module_not_derived); for (auto it = children.begin(); it != children.end(); it++) { - AstNode *child = it->get(); + auto* child = it->get(); if (child->type == AST_CELLTYPE) { cell->type = child->str; if (flag_icells && cell->type.begins_with("\\$")) @@ -2095,7 +2095,7 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint) } if (child->type == AST_PARASET) { IdString paraname = child->str.empty() ? stringf("$%d", ++para_counter) : child->str; - const AstNode *value = child->children[0].get(); + const auto* value = child->children[0].get(); if (value->type == AST_REALVALUE) log_file_warning(*location.begin.filename, location.begin.line, "Replacing floating point parameter %s.%s = %f with string.\n", log_id(cell), log_id(paraname), value->realvalue); @@ -2108,7 +2108,7 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint) if (child->type == AST_ARGUMENT) { RTLIL::SigSpec sig; if (child->children.size() > 0) { - AstNode *arg = child->children[0].get(); + auto* arg = child->children[0].get(); int local_width_hint = -1; bool local_sign_hint = false; // don't inadvertently attempt to detect the width of interfaces diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc index 8cacec275..0a43955a2 100644 --- a/frontends/ast/simplify.cc +++ b/frontends/ast/simplify.cc @@ -698,13 +698,13 @@ static bool contains_unbased_unsized(const AstNode *node) // dimensions of the given wire reference void add_wire_for_ref(location loc, const RTLIL::Wire *ref, const std::string &str) { - std::unique_ptr left = AstNode::mkconst_int(loc, ref->width - 1 + ref->start_offset, true); - std::unique_ptr right = AstNode::mkconst_int(loc, ref->start_offset, true); + auto left = AstNode::mkconst_int(loc, ref->width - 1 + ref->start_offset, true); + auto right = AstNode::mkconst_int(loc, ref->start_offset, true); if (ref->upto) std::swap(left, right); - std::unique_ptr range = std::make_unique(loc, AST_RANGE, std::move(left), std::move(right)); + auto range = std::make_unique(loc, AST_RANGE, std::move(left), std::move(right)); - std::unique_ptr wire = std::make_unique(loc, AST_WIRE, std::move(range)); + auto wire = std::make_unique(loc, AST_WIRE, std::move(range)); wire->is_signed = ref->is_signed; wire->is_logic = true; wire->str = str; @@ -821,8 +821,8 @@ static bool try_determine_range_width(AstNode *range, int &result_width) return true; } - std::unique_ptr left_at_zero_ast = range->children[0]->clone_at_zero(); - std::unique_ptr right_at_zero_ast = range->children[1]->clone_at_zero(); + auto left_at_zero_ast = range->children[0]->clone_at_zero(); + auto right_at_zero_ast = range->children[1]->clone_at_zero(); while (left_at_zero_ast->simplify(true, 1, -1, false)) {} while (right_at_zero_ast->simplify(true, 1, -1, false)) {} @@ -1575,7 +1575,7 @@ bool AstNode::simplify(bool const_fold, int stage, int width_hint, bool sign_hin if (children[0]->type == AST_WIRE) { int width = 1; std::unique_ptr node; - AstNode* child = children[0].get(); + auto* child = children[0].get(); if (child->children.size() == 0) { // Base type (e.g., int) width = child->range_left - child->range_right +1; @@ -1591,7 +1591,7 @@ bool AstNode::simplify(bool const_fold, int stage, int width_hint, bool sign_hin if (resolved_type_node->type != AST_TYPEDEF) input_error("`%s' does not name a type\n", type_name.c_str()); log_assert(resolved_type_node->children.size() == 1); - AstNode *template_node = resolved_type_node->children[0].get(); + auto* template_node = resolved_type_node->children[0].get(); // Ensure typedef itself is fully simplified while (template_node->simplify(const_fold, stage, width_hint, sign_hint)) {}; @@ -2048,7 +2048,7 @@ bool AstNode::simplify(bool const_fold, int stage, int width_hint, bool sign_hin // Pretend it's just a wire in order to resolve the type in the code block above. AstNodeType param_type = type; type = AST_WIRE; - std::unique_ptr expr = std::move(children.front()); + auto expr = std::move(children.front()); children.erase(children.begin()); while (is_custom_type && simplify(const_fold, stage, width_hint, sign_hint)) {}; type = param_type; @@ -2130,13 +2130,13 @@ bool AstNode::simplify(bool const_fold, int stage, int width_hint, bool sign_hin range_right = children[0]->range_right; bool force_upto = false, force_downto = false; if (attributes.count(ID::force_upto)) { - AstNode *val = attributes[ID::force_upto].get(); + auto* val = attributes[ID::force_upto].get(); if (val->type != AST_CONSTANT) input_error("Attribute `force_upto' with non-constant value!\n"); force_upto = val->asAttrConst().as_bool(); } if (attributes.count(ID::force_downto)) { - AstNode *val = attributes[ID::force_downto].get(); + auto* val = attributes[ID::force_downto].get(); if (val->type != AST_CONSTANT) input_error("Attribute `force_downto' with non-constant value!\n"); force_downto = val->asAttrConst().as_bool(); @@ -3307,7 +3307,7 @@ skip_dynamic_range_lvalue_expansion:; } else { - std::unique_ptr& the_range = children[0]->children[1]; + auto& the_range = children[0]->children[1]; std::unique_ptr offset_ast; int width; @@ -5165,7 +5165,7 @@ bool AstNode::mem2reg_as_needed_pass2(pool &mem2reg_set, AstNode *mod, std::vector x_bits; for (int i = 0; i < width; i++) x_bits.push_back(RTLIL::State::Sx); - std::unique_ptr constant = AstNode::mkconst_bits(location, x_bits, false); + auto constant = AstNode::mkconst_bits(location, x_bits, false); constant->cloneInto(*this); } } @@ -5427,7 +5427,7 @@ std::unique_ptr AstNode::eval_const_function(AstNode *fcall, bool must_ while (!block->children.empty()) { // log("%zu left in block %p\n", block->children.size(), block.get()); - std::unique_ptr& stmt = block->children.front(); + auto& stmt = block->children.front(); #if 0 log("-----------------------------------\n");