diff --git a/frontends/ast/ast.h b/frontends/ast/ast.h index 4baa2a3f6..fdf4d1ec9 100644 --- a/frontends/ast/ast.h +++ b/frontends/ast/ast.h @@ -164,7 +164,7 @@ namespace AST AST_BIND }; - using AstSrcLocType = location; + using AstSrcLocType = Location; // convert an node type to a string (e.g. for debug output) std::string type2str(AstNodeType type); diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc index 5e755c124..5771ceaf2 100644 --- a/frontends/ast/simplify.cc +++ b/frontends/ast/simplify.cc @@ -684,7 +684,7 @@ static bool contains_unbased_unsized(const AstNode *node) // adds a wire to the current module with the given name that matches the // dimensions of the given wire reference -void add_wire_for_ref(location loc, const RTLIL::Wire *ref, const std::string &str) +void add_wire_for_ref(Location loc, const RTLIL::Wire *ref, const std::string &str) { auto left = AstNode::mkconst_int(loc, ref->width - 1 + ref->start_offset, true); auto right = AstNode::mkconst_int(loc, ref->start_offset, true); diff --git a/frontends/verilog/verilog_error.cc b/frontends/verilog/verilog_error.cc index 4adfaafa6..19e634b5d 100644 --- a/frontends/verilog/verilog_error.cc +++ b/frontends/verilog/verilog_error.cc @@ -43,7 +43,7 @@ static void verr_at(std::string filename, int begin_line, char const *fmt, va_li } [[noreturn]] -void VERILOG_FRONTEND::err_at_loc(location loc, char const *fmt, ...) +void VERILOG_FRONTEND::err_at_loc(Location loc, char const *fmt, ...) { va_list args; va_start(args, fmt); diff --git a/frontends/verilog/verilog_error.h b/frontends/verilog/verilog_error.h index 2eeb4538e..07198a2ba 100644 --- a/frontends/verilog/verilog_error.h +++ b/frontends/verilog/verilog_error.h @@ -10,7 +10,7 @@ YOSYS_NAMESPACE_BEGIN namespace VERILOG_FRONTEND { [[noreturn]] - void err_at_loc(location loc, char const *fmt, ...); + void err_at_loc(Location loc, char const *fmt, ...); }; YOSYS_NAMESPACE_END diff --git a/frontends/verilog/verilog_frontend.cc b/frontends/verilog/verilog_frontend.cc index e7d34dac5..4b4f7ad8d 100644 --- a/frontends/verilog/verilog_frontend.cc +++ b/frontends/verilog/verilog_frontend.cc @@ -502,7 +502,7 @@ struct VerilogFrontend : public Frontend { } auto filename_shared = std::make_shared(filename); - auto top_loc = location(); + auto top_loc = Location(); top_loc.begin.filename = filename_shared; parse_state.current_ast = new AST::AstNode(top_loc, AST::AST_DESIGN); VerilogLexer lexer(&parse_state, &parse_mode, filename_shared); diff --git a/frontends/verilog/verilog_location.h b/frontends/verilog/verilog_location.h index d2ef8e94c..9b530fbeb 100644 --- a/frontends/verilog/verilog_location.h +++ b/frontends/verilog/verilog_location.h @@ -11,16 +11,16 @@ * but using shared_ptr for filename */ -struct position { +struct Position { std::shared_ptr filename; int line; int column; - position(std::shared_ptr filename, int line = 1, int column = 1) + Position(std::shared_ptr filename, int line = 1, int column = 1) : filename(filename), line(line), column(column) {} - position() = default; - position(const position& other) = default; - position& operator=(const position& other) = default; + Position() = default; + Position(const Position& other) = default; + Position& operator=(const Position& other) = default; void advance() { ++column; } void columns(int count = 1) { @@ -41,15 +41,15 @@ struct position { } }; -struct location { - position begin; - position end; +struct Location { + Position begin; + Position end; - location() = default; - location(const position& b, const position& e) + Location() = default; + Location(const Position& b, const Position& e) : begin(b), end(e) {} - location(const location& other) = default; - location& operator=(const location& other) = default; + Location(const Location& other) = default; + Location& operator=(const Location& other) = default; void step() { begin = end; } @@ -89,7 +89,7 @@ struct location { } }; -static inline std::ostream& operator<<(std::ostream& os, const location& loc) { +static inline std::ostream& operator<<(std::ostream& os, const Location& loc) { return os << loc.to_string(); } diff --git a/frontends/verilog/verilog_parser.y b/frontends/verilog/verilog_parser.y index 0fc426756..1a290f1b2 100644 --- a/frontends/verilog/verilog_parser.y +++ b/frontends/verilog/verilog_parser.y @@ -38,7 +38,7 @@ %define api.value.type variant %define api.prefix {frontend_verilog_yy} %define api.token.constructor -%define api.location.type {location} +%define api.location.type {Location} %param { YOSYS_NAMESPACE_PREFIX VERILOG_FRONTEND::VerilogLexer* lexer } %parse-param { YOSYS_NAMESPACE_PREFIX VERILOG_FRONTEND::ParseState* extra } @@ -146,14 +146,10 @@ YOSYS_NAMESPACE_BEGIN namespace VERILOG_FRONTEND { - static location location_range(location begin, location end) { - return location(begin.begin, end.end); + static Location location_range(Location begin, Location end) { + return Location(begin.begin, end.end); } - static ConstParser make_ConstParser_here(parser::location_type flex_loc) { - ConstParser p{flex_loc}; - return p; - } static void append_attr(AstNode *ast, dict> *al) { for (auto &it : *al) { @@ -370,7 +366,7 @@ const AstNode *ParseState::addIncOrDecStmt(dict> *stmt_attr, std::unique_ptr lhs, dict> *op_attr, AST::AstNodeType op, - location loc) + Location loc) { auto one = AstNode::mkconst_int(loc, 1, true); auto rhs = std::make_unique(loc, op, lhs->clone(), std::move(one)); @@ -385,7 +381,7 @@ } // create a pre/post-increment/decrement expression, and add the corresponding statement - std::unique_ptr ParseState::addIncOrDecExpr(std::unique_ptr lhs, dict> *attr, AST::AstNodeType op, location loc, bool undo, bool sv_mode) + std::unique_ptr ParseState::addIncOrDecExpr(std::unique_ptr lhs, dict> *attr, AST::AstNodeType op, Location loc, bool undo, bool sv_mode) { ensureAsgnExprAllowed(loc, sv_mode); const AstNode *stmt = addIncOrDecStmt(nullptr, std::move(lhs), attr, op, loc); @@ -402,7 +398,7 @@ // add a binary operator assignment statement, e.g., a += b std::unique_ptr ParseState::addAsgnBinopStmt(dict> *attr, std::unique_ptr eq_lhs, AST::AstNodeType op, std::unique_ptr rhs) { - location loc = location_range(eq_lhs->location, rhs->location); + Location loc = location_range(eq_lhs->location, rhs->location); if (op == AST_SHIFT_LEFT || op == AST_SHIFT_RIGHT || op == AST_SHIFT_SLEFT || op == AST_SHIFT_SRIGHT) { rhs = std::make_unique(rhs->location, AST_TO_UNSIGNED, std::move(rhs)); @@ -3219,7 +3215,7 @@ basic_expr: TOK_LPAREN expr TOK_RPAREN integral_number { if ($4->compare(0, 1, "'") != 0) err_at_loc(@4, "Cast operation must be applied on sized constants e.g. () , while %s is not a sized constant.", $4->c_str()); - auto p = make_ConstParser_here(@4); + ConstParser p{@4}; auto val = p.const2ast(*$4, extra->case_type_stack.size() == 0 ? 0 : extra->case_type_stack.back(), !mode->lib); if (val == nullptr) log_error("Value conversion failed: `%s'\n", $4->c_str()); @@ -3231,7 +3227,7 @@ basic_expr: auto bits = std::make_unique(@$, AST_IDENTIFIER); bits->str = *$1; SET_AST_NODE_LOC(bits.get(), @1, @1); - auto p = make_ConstParser_here(@2); + ConstParser p{@2}; auto val = p.const2ast(*$2, extra->case_type_stack.size() == 0 ? 0 : extra->case_type_stack.back(), !mode->lib); SET_AST_NODE_LOC(val.get(), @2, @2); if (val == nullptr) @@ -3239,7 +3235,7 @@ basic_expr: $$ = std::make_unique(@$, AST_TO_BITS, std::move(bits), std::move(val)); } | integral_number { - auto p = make_ConstParser_here(@1); + ConstParser p{@1}; $$ = p.const2ast(*$1, extra->case_type_stack.size() == 0 ? 0 : extra->case_type_stack.back(), !mode->lib); SET_AST_NODE_LOC($$.get(), @1, @1); if ($$ == nullptr) diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 1b133d9c1..5899328ef 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -5725,7 +5725,7 @@ bool RTLIL::SigSpec::parse(RTLIL::SigSpec &sig, RTLIL::Module *module, std::stri if (('0' <= netname[0] && netname[0] <= '9') || netname[0] == '\'') { cover("kernel.rtlil.sigspec.parse.const"); - VERILOG_FRONTEND::ConstParser p{location()}; + VERILOG_FRONTEND::ConstParser p{Location()}; auto ast = p.const2ast(netname); if (ast == nullptr) return false;