diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2023-07-10 15:42:49 -0400 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 18:55:56 +0100 |
commit | d991a3f15f64d3a16cce0866508bb76d87b9627c (patch) | |
tree | 05089b03dde35a66eba255f7b8392c35a08508e8 | |
parent | ad14f866184f91afa9a0a6e73ee14b06ce017037 (diff) | |
download | gcc-d991a3f15f64d3a16cce0866508bb76d87b9627c.zip gcc-d991a3f15f64d3a16cce0866508bb76d87b9627c.tar.gz gcc-d991a3f15f64d3a16cce0866508bb76d87b9627c.tar.bz2 |
gccrs: Replace some usages of Location with location_t
gcc/rust/ChangeLog:
* ast/rust-ast-collector.cc: Replace Location with location_t.
* ast/rust-ast.cc: Likewise.
* ast/rust-ast.h: Likewise.
* ast/rust-expr.h: Likewise.
* ast/rust-item.h: Likewise.
* ast/rust-macro.h: Likewise.
* ast/rust-path.cc: Likewise.
* ast/rust-path.h: Likewise.
* ast/rust-pattern.h: Likewise.
* ast/rust-stmt.h: Likewise.
* ast/rust-type.h: Likewise.
* backend/rust-compile-base.cc: Likewise.
* backend/rust-compile-base.h: Likewise.
* backend/rust-compile-block.cc: Likewise.
* backend/rust-compile-expr.cc: Likewise.
* backend/rust-compile-expr.h: Likewise.
* backend/rust-compile-fnparam.cc: Likewise.
* backend/rust-compile-fnparam.h: Likewise.
* backend/rust-compile-intrinsic.cc: Likewise.
* backend/rust-compile-pattern.cc: Likewise.
* backend/rust-compile-resolve-path.h: Likewise.
* backend/rust-compile.cc: Likewise.
* checks/errors/rust-const-checker.cc: Likewise.
* checks/errors/rust-const-checker.h: Likewise.
* checks/errors/rust-unsafe-checker.cc: Likewise.
* checks/errors/rust-unsafe-checker.h: Likewise.
* expand/rust-macro-builtins.cc: Likewise.
* expand/rust-macro-expand.h: Likewise.
* hir/rust-ast-lower-base.h: Likewise.
* hir/rust-ast-lower-implitem.h: Likewise.
* hir/rust-ast-lower-item.cc: Likewise.
* hir/tree/rust-hir-expr.h: Likewise.
* hir/tree/rust-hir-item.h: Likewise.
* hir/tree/rust-hir-path.h: Likewise.
* hir/tree/rust-hir-pattern.h: Likewise.
* hir/tree/rust-hir-stmt.h: Likewise.
* hir/tree/rust-hir-type.h: Likewise.
* hir/tree/rust-hir.cc: Likewise.
* hir/tree/rust-hir.h: Likewise.
* lex/rust-token.h: Likewise.
* metadata/rust-extern-crate.cc: Likewise.
* metadata/rust-extern-crate.h: Likewise.
* parse/rust-parse-impl.h: Likewise.
* parse/rust-parse.h: Likewise.
* resolve/rust-ast-resolve-expr.cc: Likewise.
* resolve/rust-ast-resolve-implitem.h: Likewise.
* resolve/rust-ast-resolve-pattern.h: Likewise.
* resolve/rust-ast-resolve-stmt.h: Likewise.
* resolve/rust-ast-resolve-toplevel.h: Likewise.
* resolve/rust-ast-resolve-type.h: Likewise.
* resolve/rust-name-resolver.cc: Likewise.
* resolve/rust-name-resolver.h: Likewise.
* rust-diagnostics.cc: Likewise.
* rust-diagnostics.h: Likewise.
* rust-gcc.cc: Likewise.
* rust-session-manager.cc: Likewise.
* rust-session-manager.h: Likewise.
* typecheck/rust-casts.cc: Likewise.
* typecheck/rust-casts.h: Likewise.
* typecheck/rust-coercion.cc: Likewise.
* typecheck/rust-coercion.h: Likewise.
* typecheck/rust-hir-path-probe.cc: Likewise.
* typecheck/rust-hir-path-probe.h: Likewise.
* typecheck/rust-hir-trait-reference.cc: Likewise.
* typecheck/rust-hir-trait-reference.h: Likewise.
* typecheck/rust-hir-trait-resolve.cc: Likewise.
* typecheck/rust-hir-type-check-base.cc: Likewise.
* typecheck/rust-hir-type-check-base.h: Likewise.
* typecheck/rust-hir-type-check-item.cc: Likewise.
* typecheck/rust-hir-type-check-item.h: Likewise.
* typecheck/rust-hir-type-check-path.cc: Likewise.
* typecheck/rust-hir-type-check-pattern.cc: Likewise.
* typecheck/rust-hir-type-check-pattern.h: Likewise.
* typecheck/rust-hir-type-check-type.cc: Likewise.
* typecheck/rust-hir-type-check-type.h: Likewise.
* typecheck/rust-hir-type-check.cc: Likewise.
* typecheck/rust-hir-type-check.h: Likewise.
* typecheck/rust-substitution-mapper.cc: Likewise.
* typecheck/rust-substitution-mapper.h: Likewise.
* typecheck/rust-type-util.cc: Likewise.
* typecheck/rust-typecheck-context.cc: Likewise.
* typecheck/rust-tyty-bounds.cc: Likewise.
* typecheck/rust-tyty-call.h: Likewise.
* typecheck/rust-tyty-subst.cc: Likewise.
* typecheck/rust-tyty-subst.h: Likewise.
* typecheck/rust-tyty-util.cc: Likewise.
* typecheck/rust-tyty-util.h: Likewise.
* typecheck/rust-tyty.cc: Likewise.
* typecheck/rust-tyty.h: Likewise.
* typecheck/rust-unify.cc: Likewise.
* typecheck/rust-unify.h: Likewise.
* util/rust-hir-map.cc: Likewise.
* util/rust-hir-map.h: Likewise.
* util/rust-identifier.h: Likewise.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
94 files changed, 965 insertions, 943 deletions
diff --git a/gcc/rust/ast/rust-ast-collector.cc b/gcc/rust/ast/rust-ast-collector.cc index ad2ffd0..3b9f457 100644 --- a/gcc/rust/ast/rust-ast-collector.cc +++ b/gcc/rust/ast/rust-ast-collector.cc @@ -788,7 +788,7 @@ TokenCollector::visit (QualifiedPathInType &path) } void -TokenCollector::visit (Literal &lit, Location locus) +TokenCollector::visit (Literal &lit, location_t locus) { auto value = lit.as_string (); switch (lit.get_lit_type ()) diff --git a/gcc/rust/ast/rust-ast.cc b/gcc/rust/ast/rust-ast.cc index 4e24f1d..699232c 100644 --- a/gcc/rust/ast/rust-ast.cc +++ b/gcc/rust/ast/rust-ast.cc @@ -3643,7 +3643,7 @@ AttributeParser::parse_path_meta_item () case EQUAL: { skip_token (); - Location locus = peek_token ()->get_locus (); + location_t locus = peek_token ()->get_locus (); Literal lit = parse_literal (); if (lit.is_error ()) { @@ -3848,7 +3848,7 @@ AttributeParser::parse_simple_path_segment () std::unique_ptr<MetaItemLitExpr> AttributeParser::parse_meta_item_lit () { - Location locus = peek_token ()->get_locus (); + location_t locus = peek_token ()->get_locus (); LiteralExpr lit_expr (parse_literal (), {}, locus); return std::unique_ptr<MetaItemLitExpr> ( new MetaItemLitExpr (std::move (lit_expr))); diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 85dae48..bd6a06e 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -182,7 +182,7 @@ class Token : public TokenTree, public MacroMatch // Token kind. TokenId token_id; // Token location. - Location locus; + location_t locus; // Associated text (if any) of token. std::string str; // Token type hint (if any). @@ -205,7 +205,7 @@ public: #if 0 /* constructor from general text - avoid using if lexer const_TokenPtr is * available */ - Token (TokenId token_id, Location locus, std::string str, + Token (TokenId token_id, location_t locus, std::string str, PrimitiveCoreType type_hint) : token_id (token_id), locus (locus), str (std::move (str)), type_hint (type_hint) @@ -370,13 +370,13 @@ public: class SimplePathSegment : public PathSegment { std::string segment_name; - Location locus; + location_t locus; NodeId node_id; // only allow identifiers, "super", "self", "crate", or "$crate" public: // TODO: put checks in constructor to enforce this rule? - SimplePathSegment (std::string segment_name, Location locus) + SimplePathSegment (std::string segment_name, location_t locus) : segment_name (std::move (segment_name)), locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ()) {} @@ -413,14 +413,14 @@ class SimplePath { bool opening_scope_resolution; std::vector<SimplePathSegment> segments; - Location locus; + location_t locus; NodeId node_id; public: // Constructor SimplePath (std::vector<SimplePathSegment> path_segments, bool has_opening_scope_resolution = false, - Location locus = UNDEF_LOCATION) + location_t locus = UNDEF_LOCATION) : opening_scope_resolution (has_opening_scope_resolution), segments (std::move (path_segments)), locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ()) @@ -458,7 +458,7 @@ public: * ensure that this is a valid identifier in path, so be careful. Also, this * will have no location data. * TODO have checks? */ - static SimplePath from_str (std::string str, Location locus) + static SimplePath from_str (std::string str, location_t locus) { std::vector<AST::SimplePathSegment> single_segments = {AST::SimplePathSegment (std::move (str), locus)}; @@ -498,7 +498,7 @@ private: // bool has_attr_input; std::unique_ptr<AttrInput> attr_input; - Location locus; + location_t locus; bool inner_attribute; @@ -510,7 +510,7 @@ public: // Constructor has pointer AttrInput for polymorphism reasons Attribute (SimplePath path, std::unique_ptr<AttrInput> input, - Location locus = UNDEF_LOCATION, bool inner_attribute = false) + location_t locus = UNDEF_LOCATION, bool inner_attribute = false) : path (std::move (path)), attr_input (std::move (input)), locus (locus), inner_attribute (inner_attribute) {} @@ -794,7 +794,7 @@ class DelimTokenTree : public TokenTree, public AttrInput { DelimType delim_type; std::vector<std::unique_ptr<TokenTree>> token_trees; - Location locus; + location_t locus; protected: DelimTokenTree *clone_delim_tok_tree_impl () const @@ -820,7 +820,7 @@ public: DelimTokenTree (DelimType delim_type, std::vector<std::unique_ptr<TokenTree>> token_trees = std::vector<std::unique_ptr<TokenTree>> (), - Location locus = UNDEF_LOCATION) + location_t locus = UNDEF_LOCATION) : delim_type (delim_type), token_trees (std::move (token_trees)), locus (locus) {} @@ -1091,11 +1091,11 @@ class IdentifierExpr : public ExprWithoutBlock { std::vector<Attribute> outer_attrs; Identifier ident; - Location locus; + location_t locus; public: IdentifierExpr (Identifier ident, std::vector<Attribute> outer_attrs, - Location locus) + location_t locus) : outer_attrs (std::move (outer_attrs)), ident (std::move (ident)), locus (locus) {} @@ -1277,19 +1277,19 @@ public: private: LifetimeType lifetime_type; std::string lifetime_name; - Location locus; + location_t locus; NodeId node_id; public: // Constructor Lifetime (LifetimeType type, std::string name = std::string (), - Location locus = UNDEF_LOCATION) + location_t locus = UNDEF_LOCATION) : TypeParamBound (Analysis::Mappings::get ()->get_next_node_id ()), lifetime_type (type), lifetime_name (std::move (name)), locus (locus) {} Lifetime (NodeId id, LifetimeType type, std::string name = std::string (), - Location locus = UNDEF_LOCATION) + location_t locus = UNDEF_LOCATION) : TypeParamBound (id), lifetime_type (type), lifetime_name (std::move (name)), locus (locus) {} @@ -1366,7 +1366,7 @@ class LifetimeParam : public GenericParam Lifetime lifetime; std::vector<Lifetime> lifetime_bounds; Attribute outer_attr; - Location locus; + location_t locus; public: Lifetime get_lifetime () const { return lifetime; } @@ -1391,7 +1391,7 @@ public: // Constructor LifetimeParam (Lifetime lifetime, std::vector<Lifetime> lifetime_bounds, - Attribute outer_attr, Location locus) + Attribute outer_attr, location_t locus) : lifetime (std::move (lifetime)), lifetime_bounds (std::move (lifetime_bounds)), outer_attr (std::move (outer_attr)), locus (locus) @@ -1418,7 +1418,7 @@ protected: class TraitItem : public Visitable { protected: - TraitItem (Location locus) + TraitItem (location_t locus) : node_id (Analysis::Mappings::get ()->get_next_node_id ()), locus (locus) {} @@ -1426,7 +1426,7 @@ protected: virtual TraitItem *clone_trait_item_impl () const = 0; NodeId node_id; - Location locus; + location_t locus; public: virtual ~TraitItem () {} diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h index 1ea82c7..c836250 100644 --- a/gcc/rust/ast/rust-expr.h +++ b/gcc/rust/ast/rust-expr.h @@ -39,7 +39,7 @@ class LiteralExpr : public ExprWithoutBlock { std::vector<Attribute> outer_attrs; Literal literal; - Location locus; + location_t locus; public: std::string as_string () const override { return literal.as_string (); } @@ -48,13 +48,13 @@ public: LiteralExpr (std::string value_as_string, Literal::LitType type, PrimitiveCoreType type_hint, std::vector<Attribute> outer_attrs, - Location locus) + location_t locus) : outer_attrs (std::move (outer_attrs)), literal (std::move (value_as_string), type, type_hint), locus (locus) {} LiteralExpr (Literal literal, std::vector<Attribute> outer_attrs, - Location locus) + location_t locus) : outer_attrs (std::move (outer_attrs)), literal (std::move (literal)), locus (locus) {} @@ -256,7 +256,7 @@ class OperatorExpr : public ExprWithoutBlock { // TODO: create binary and unary operator subclasses? public: - Location locus; + location_t locus; protected: /* Variables must be protected to allow derived classes to use them as first @@ -266,7 +266,7 @@ protected: // Constructor (only for initialisation of expr purposes) OperatorExpr (std::unique_ptr<Expr> main_or_left_expr, - std::vector<Attribute> outer_attribs, Location locus) + std::vector<Attribute> outer_attribs, location_t locus) : locus (locus), outer_attrs (std::move (outer_attribs)), main_or_left_expr (std::move (main_or_left_expr)) {} @@ -331,7 +331,7 @@ public: BorrowExpr (std::unique_ptr<Expr> borrow_lvalue, bool is_mut_borrow, bool is_double_borrow, std::vector<Attribute> outer_attribs, - Location locus) + location_t locus) : OperatorExpr (std::move (borrow_lvalue), std::move (outer_attribs), locus), is_mut (is_mut_borrow), double_borrow (is_double_borrow) @@ -367,7 +367,7 @@ public: // Constructor calls OperatorExpr's protected constructor DereferenceExpr (std::unique_ptr<Expr> deref_lvalue, - std::vector<Attribute> outer_attribs, Location locus) + std::vector<Attribute> outer_attribs, location_t locus) : OperatorExpr (std::move (deref_lvalue), std::move (outer_attribs), locus) {} @@ -397,7 +397,7 @@ public: // Constructor calls OperatorExpr's protected constructor ErrorPropagationExpr (std::unique_ptr<Expr> potential_error_value, - std::vector<Attribute> outer_attribs, Location locus) + std::vector<Attribute> outer_attribs, location_t locus) : OperatorExpr (std::move (potential_error_value), std::move (outer_attribs), locus) {} @@ -439,7 +439,7 @@ public: // Constructor calls OperatorExpr's protected constructor NegationExpr (std::unique_ptr<Expr> negated_value, ExprType expr_kind, - std::vector<Attribute> outer_attribs, Location locus) + std::vector<Attribute> outer_attribs, location_t locus) : OperatorExpr (std::move (negated_value), std::move (outer_attribs), locus), expr_type (expr_kind) @@ -483,7 +483,7 @@ public: // Constructor calls OperatorExpr's protected constructor ArithmeticOrLogicalExpr (std::unique_ptr<Expr> left_value, std::unique_ptr<Expr> right_value, - ExprType expr_kind, Location locus) + ExprType expr_kind, location_t locus) : OperatorExpr (std::move (left_value), std::vector<Attribute> (), locus), expr_type (expr_kind), right_expr (std::move (right_value)) {} @@ -559,7 +559,7 @@ public: // Constructor requires pointers for polymorphism ComparisonExpr (std::unique_ptr<Expr> left_value, std::unique_ptr<Expr> right_value, ExprType comparison_kind, - Location locus) + location_t locus) : OperatorExpr (std::move (left_value), std::vector<Attribute> (), locus), expr_type (comparison_kind), right_expr (std::move (right_value)) {} @@ -631,7 +631,7 @@ public: // Constructor calls OperatorExpr's protected constructor LazyBooleanExpr (std::unique_ptr<Expr> left_bool_expr, std::unique_ptr<Expr> right_bool_expr, ExprType expr_kind, - Location locus) + location_t locus) : OperatorExpr (std::move (left_bool_expr), std::vector<Attribute> (), locus), expr_type (expr_kind), right_expr (std::move (right_bool_expr)) @@ -701,7 +701,7 @@ public: // Constructor requires calling protected constructor of OperatorExpr TypeCastExpr (std::unique_ptr<Expr> expr_to_cast, - std::unique_ptr<TypeNoBounds> type_to_cast_to, Location locus) + std::unique_ptr<TypeNoBounds> type_to_cast_to, location_t locus) : OperatorExpr (std::move (expr_to_cast), std::vector<Attribute> (), locus), type_to_convert_to (std::move (type_to_cast_to)) {} @@ -763,7 +763,7 @@ public: // Call OperatorExpr constructor to initialise left_expr AssignmentExpr (std::unique_ptr<Expr> value_to_assign_to, std::unique_ptr<Expr> value_to_assign, - std::vector<Attribute> outer_attribs, Location locus) + std::vector<Attribute> outer_attribs, location_t locus) : OperatorExpr (std::move (value_to_assign_to), std::move (outer_attribs), locus), right_expr (std::move (value_to_assign)) @@ -838,7 +838,7 @@ public: // Use pointers in constructor to enable polymorphism CompoundAssignmentExpr (std::unique_ptr<Expr> value_to_assign_to, std::unique_ptr<Expr> value_to_assign, - ExprType expr_kind, Location locus) + ExprType expr_kind, location_t locus) : OperatorExpr (std::move (value_to_assign_to), std::vector<Attribute> (), locus), expr_type (expr_kind), right_expr (std::move (value_to_assign)) @@ -898,7 +898,7 @@ class GroupedExpr : public ExprWithoutBlock std::vector<Attribute> outer_attrs; std::vector<Attribute> inner_attrs; std::unique_ptr<Expr> expr_in_parens; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -916,7 +916,7 @@ public: GroupedExpr (std::unique_ptr<Expr> parenthesised_expr, std::vector<Attribute> inner_attribs, - std::vector<Attribute> outer_attribs, Location locus) + std::vector<Attribute> outer_attribs, location_t locus) : outer_attrs (std::move (outer_attribs)), inner_attrs (std::move (inner_attribs)), expr_in_parens (std::move (parenthesised_expr)), locus (locus) @@ -1012,10 +1012,10 @@ protected: class ArrayElemsValues : public ArrayElems { std::vector<std::unique_ptr<Expr> > values; - Location locus; + location_t locus; public: - ArrayElemsValues (std::vector<std::unique_ptr<Expr> > elems, Location locus) + ArrayElemsValues (std::vector<std::unique_ptr<Expr> > elems, location_t locus) : ArrayElems (), values (std::move (elems)), locus (locus) {} @@ -1066,12 +1066,12 @@ class ArrayElemsCopied : public ArrayElems { std::unique_ptr<Expr> elem_to_copy; std::unique_ptr<Expr> num_copies; - Location locus; + location_t locus; public: // Constructor requires pointers for polymorphism ArrayElemsCopied (std::unique_ptr<Expr> copied_elem, - std::unique_ptr<Expr> copy_amount, Location locus) + std::unique_ptr<Expr> copy_amount, location_t locus) : ArrayElems (), elem_to_copy (std::move (copied_elem)), num_copies (std::move (copy_amount)), locus (locus) {} @@ -1126,7 +1126,7 @@ class ArrayExpr : public ExprWithoutBlock std::vector<Attribute> outer_attrs; std::vector<Attribute> inner_attrs; std::unique_ptr<ArrayElems> internal_elements; - Location locus; + location_t locus; // TODO: find another way to store this to save memory? bool marked_for_strip = false; @@ -1148,7 +1148,7 @@ public: // Constructor requires ArrayElems pointer ArrayExpr (std::unique_ptr<ArrayElems> array_elems, std::vector<Attribute> inner_attribs, - std::vector<Attribute> outer_attribs, Location locus) + std::vector<Attribute> outer_attribs, location_t locus) : outer_attrs (std::move (outer_attribs)), inner_attrs (std::move (inner_attribs)), internal_elements (std::move (array_elems)), locus (locus) @@ -1219,14 +1219,14 @@ class ArrayIndexExpr : public ExprWithoutBlock std::vector<Attribute> outer_attrs; std::unique_ptr<Expr> array_expr; std::unique_ptr<Expr> index_expr; - Location locus; + location_t locus; public: std::string as_string () const override; ArrayIndexExpr (std::unique_ptr<Expr> array_expr, std::unique_ptr<Expr> array_index_expr, - std::vector<Attribute> outer_attribs, Location locus) + std::vector<Attribute> outer_attribs, location_t locus) : outer_attrs (std::move (outer_attribs)), array_expr (std::move (array_expr)), index_expr (std::move (array_index_expr)), locus (locus) @@ -1320,7 +1320,7 @@ class TupleExpr : public ExprWithoutBlock std::vector<Attribute> outer_attrs; std::vector<Attribute> inner_attrs; std::vector<std::unique_ptr<Expr> > tuple_elems; - Location locus; + location_t locus; // TODO: find another way to store this to save memory? bool marked_for_strip = false; @@ -1341,7 +1341,7 @@ public: TupleExpr (std::vector<std::unique_ptr<Expr> > tuple_elements, std::vector<Attribute> inner_attribs, - std::vector<Attribute> outer_attribs, Location locus) + std::vector<Attribute> outer_attribs, location_t locus) : outer_attrs (std::move (outer_attribs)), inner_attrs (std::move (inner_attribs)), tuple_elems (std::move (tuple_elements)), locus (locus) @@ -1419,7 +1419,7 @@ class TupleIndexExpr : public ExprWithoutBlock // TupleIndex is a decimal int literal with no underscores or suffix TupleIndex tuple_index; - Location locus; + location_t locus; // i.e. pair.0 @@ -1429,7 +1429,7 @@ public: TupleIndex get_tuple_index () const { return tuple_index; } TupleIndexExpr (std::unique_ptr<Expr> tuple_expr, TupleIndex index, - std::vector<Attribute> outer_attribs, Location locus) + std::vector<Attribute> outer_attribs, location_t locus) : outer_attrs (std::move (outer_attribs)), tuple_expr (std::move (tuple_expr)), tuple_index (index), locus (locus) {} @@ -1538,7 +1538,7 @@ class StructExprStruct : public StructExpr { std::vector<Attribute> inner_attrs; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -1549,7 +1549,7 @@ public: // Constructor has to call protected constructor of base class StructExprStruct (PathInExpression struct_path, std::vector<Attribute> inner_attribs, - std::vector<Attribute> outer_attribs, Location locus) + std::vector<Attribute> outer_attribs, location_t locus) : StructExpr (std::move (struct_path), std::move (outer_attribs)), inner_attrs (std::move (inner_attribs)), locus (locus) {} @@ -1573,10 +1573,10 @@ struct StructBase { private: std::unique_ptr<Expr> base_struct; - Location locus; + location_t locus; public: - StructBase (std::unique_ptr<Expr> base_struct_ptr, Location locus) + StructBase (std::unique_ptr<Expr> base_struct_ptr, location_t locus) : base_struct (std::move (base_struct_ptr)), locus (locus) {} @@ -1659,10 +1659,10 @@ protected: class StructExprFieldIdentifier : public StructExprField { Identifier field_name; - Location locus; + location_t locus; public: - StructExprFieldIdentifier (Identifier field_identifier, Location locus) + StructExprFieldIdentifier (Identifier field_identifier, location_t locus) : StructExprField (), field_name (std::move (field_identifier)), locus (locus) {} @@ -1727,12 +1727,12 @@ public: class StructExprFieldIdentifierValue : public StructExprFieldWithVal { Identifier field_name; - Location locus; + location_t locus; public: StructExprFieldIdentifierValue (Identifier field_identifier, std::unique_ptr<Expr> field_value, - Location locus) + location_t locus) : StructExprFieldWithVal (std::move (field_value)), field_name (std::move (field_identifier)), locus (locus) {} @@ -1758,11 +1758,12 @@ protected: class StructExprFieldIndexValue : public StructExprFieldWithVal { TupleIndex index; - Location locus; + location_t locus; public: StructExprFieldIndexValue (TupleIndex tuple_index, - std::unique_ptr<Expr> field_value, Location locus) + std::unique_ptr<Expr> field_value, + location_t locus) : StructExprFieldWithVal (std::move (field_value)), index (tuple_index), locus (locus) {} @@ -1801,8 +1802,8 @@ public: // Constructor for StructExprStructFields when no struct base is used StructExprStructFields ( PathInExpression struct_path, - std::vector<std::unique_ptr<StructExprField> > expr_fields, Location locus, - StructBase base_struct = StructBase::error (), + std::vector<std::unique_ptr<StructExprField> > expr_fields, + location_t locus, StructBase base_struct = StructBase::error (), std::vector<Attribute> inner_attribs = std::vector<Attribute> (), std::vector<Attribute> outer_attribs = std::vector<Attribute> ()) : StructExprStruct (std::move (struct_path), std::move (inner_attribs), @@ -1872,7 +1873,7 @@ public: StructExprStructBase (PathInExpression struct_path, StructBase base_struct, std::vector<Attribute> inner_attribs, - std::vector<Attribute> outer_attribs, Location locus) + std::vector<Attribute> outer_attribs, location_t locus) : StructExprStruct (std::move (struct_path), std::move (inner_attribs), std::move (outer_attribs), locus), struct_base (std::move (base_struct)) @@ -1901,7 +1902,7 @@ class CallExpr : public ExprWithoutBlock std::vector<Attribute> outer_attrs; std::unique_ptr<Expr> function; std::vector<std::unique_ptr<Expr> > params; - Location locus; + location_t locus; public: Function *fndeclRef; @@ -1910,7 +1911,7 @@ public: CallExpr (std::unique_ptr<Expr> function_expr, std::vector<std::unique_ptr<Expr> > function_params, - std::vector<Attribute> outer_attribs, Location locus) + std::vector<Attribute> outer_attribs, location_t locus) : outer_attrs (std::move (outer_attribs)), function (std::move (function_expr)), params (std::move (function_params)), locus (locus) @@ -2003,7 +2004,7 @@ class MethodCallExpr : public ExprWithoutBlock std::unique_ptr<Expr> receiver; PathExprSegment method_name; std::vector<std::unique_ptr<Expr> > params; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -2011,7 +2012,7 @@ public: MethodCallExpr (std::unique_ptr<Expr> call_receiver, PathExprSegment method_path, std::vector<std::unique_ptr<Expr> > method_params, - std::vector<Attribute> outer_attribs, Location locus) + std::vector<Attribute> outer_attribs, location_t locus) : outer_attrs (std::move (outer_attribs)), receiver (std::move (call_receiver)), method_name (std::move (method_path)), params (std::move (method_params)), @@ -2106,14 +2107,14 @@ class FieldAccessExpr : public ExprWithoutBlock std::vector<Attribute> outer_attrs; std::unique_ptr<Expr> receiver; Identifier field; - Location locus; + location_t locus; public: std::string as_string () const override; FieldAccessExpr (std::unique_ptr<Expr> field_access_receiver, Identifier field_name, std::vector<Attribute> outer_attribs, - Location locus) + location_t locus) : outer_attrs (std::move (outer_attribs)), receiver (std::move (field_access_receiver)), field (std::move (field_name)), locus (locus) @@ -2191,7 +2192,7 @@ private: std::vector<Attribute> outer_attrs; std::unique_ptr<Pattern> pattern; std::unique_ptr<Type> type; - Location locus; + location_t locus; public: // Returns whether the type of the parameter has been given. @@ -2200,7 +2201,7 @@ public: bool has_outer_attrs () const { return !outer_attrs.empty (); } // Constructor for closure parameter - ClosureParam (std::unique_ptr<Pattern> param_pattern, Location locus, + ClosureParam (std::unique_ptr<Pattern> param_pattern, location_t locus, std::unique_ptr<Type> param_type = nullptr, std::vector<Attribute> outer_attrs = {}) : outer_attrs (std::move (outer_attrs)), @@ -2277,11 +2278,11 @@ class ClosureExpr : public ExprWithoutBlock std::vector<Attribute> outer_attrs; bool has_move; std::vector<ClosureParam> params; // may be empty - Location locus; + location_t locus; protected: ClosureExpr (std::vector<ClosureParam> closure_params, bool has_move, - std::vector<Attribute> outer_attribs, Location locus) + std::vector<Attribute> outer_attribs, location_t locus) : outer_attrs (std::move (outer_attribs)), has_move (has_move), params (std::move (closure_params)), locus (locus) {} @@ -2316,7 +2317,7 @@ public: // Constructor for a ClosureExprInner ClosureExprInner (std::unique_ptr<Expr> closure_inner_expr, - std::vector<ClosureParam> closure_params, Location locus, + std::vector<ClosureParam> closure_params, location_t locus, bool is_move = false, std::vector<Attribute> outer_attribs = std::vector<Attribute> ()) @@ -2544,7 +2545,7 @@ public: ClosureExprInnerTyped (std::unique_ptr<Type> closure_return_type, std::unique_ptr<BlockExpr> closure_expr, std::vector<ClosureParam> closure_params, - Location locus, bool is_move = false, + location_t locus, bool is_move = false, std::vector<Attribute> outer_attribs = std::vector<Attribute> ()) : ClosureExpr (std::move (closure_params), is_move, @@ -2624,7 +2625,7 @@ class ContinueExpr : public ExprWithoutBlock { std::vector<Attribute> outer_attrs; Lifetime label; - Location locus; + location_t locus; // TODO: find another way to store this to save memory? bool marked_for_strip = false; @@ -2637,7 +2638,7 @@ public: // Constructor for a ContinueExpr with a label. ContinueExpr (Lifetime label, std::vector<Attribute> outer_attribs, - Location locus) + location_t locus) : outer_attrs (std::move (outer_attribs)), label (std::move (label)), locus (locus) {} @@ -2676,7 +2677,7 @@ class BreakExpr : public ExprWithoutBlock std::vector<Attribute> outer_attrs; Lifetime label; std::unique_ptr<Expr> break_expr; - Location locus; + location_t locus; // TODO: find another way to store this to save memory? bool marked_for_strip = false; @@ -2693,7 +2694,7 @@ public: // Constructor for a break expression BreakExpr (Lifetime break_label, std::unique_ptr<Expr> expr_in_break, - std::vector<Attribute> outer_attribs, Location locus) + std::vector<Attribute> outer_attribs, location_t locus) : outer_attrs (std::move (outer_attribs)), label (std::move (break_label)), break_expr (std::move (expr_in_break)), locus (locus) {} @@ -2768,11 +2769,11 @@ protected: // Base range expression AST node object - abstract class RangeExpr : public ExprWithoutBlock { - Location locus; + location_t locus; protected: // outer attributes not allowed before range expressions - RangeExpr (Location locus) : locus (locus) {} + RangeExpr (location_t locus) : locus (locus) {} public: Location get_locus () const override final { return locus; } @@ -2801,7 +2802,7 @@ public: std::string as_string () const override; RangeFromToExpr (std::unique_ptr<Expr> range_from, - std::unique_ptr<Expr> range_to, Location locus) + std::unique_ptr<Expr> range_to, location_t locus) : RangeExpr (locus), from (std::move (range_from)), to (std::move (range_to)) {} @@ -2883,7 +2884,7 @@ class RangeFromExpr : public RangeExpr public: std::string as_string () const override; - RangeFromExpr (std::unique_ptr<Expr> range_from, Location locus) + RangeFromExpr (std::unique_ptr<Expr> range_from, location_t locus) : RangeExpr (locus), from (std::move (range_from)) {} @@ -2945,7 +2946,7 @@ public: std::string as_string () const override; // outer attributes not allowed - RangeToExpr (std::unique_ptr<Expr> range_to, Location locus) + RangeToExpr (std::unique_ptr<Expr> range_to, location_t locus) : RangeExpr (locus), to (std::move (range_to)) {} @@ -3007,7 +3008,7 @@ class RangeFullExpr : public RangeExpr public: std::string as_string () const override; - RangeFullExpr (Location locus) : RangeExpr (locus) {} + RangeFullExpr (location_t locus) : RangeExpr (locus) {} // outer attributes not allowed void accept_vis (ASTVisitor &vis) override; @@ -3036,7 +3037,7 @@ public: std::string as_string () const override; RangeFromToInclExpr (std::unique_ptr<Expr> range_from, - std::unique_ptr<Expr> range_to, Location locus) + std::unique_ptr<Expr> range_to, location_t locus) : RangeExpr (locus), from (std::move (range_from)), to (std::move (range_to)) {} @@ -3119,7 +3120,7 @@ class RangeToInclExpr : public RangeExpr public: std::string as_string () const override; - RangeToInclExpr (std::unique_ptr<Expr> range_to, Location locus) + RangeToInclExpr (std::unique_ptr<Expr> range_to, location_t locus) : RangeExpr (locus), to (std::move (range_to)) {} // outer attributes not allowed @@ -3177,7 +3178,7 @@ class ReturnExpr : public ExprWithoutBlock { std::vector<Attribute> outer_attrs; std::unique_ptr<Expr> return_expr; - Location locus; + location_t locus; // TODO: find another way to store this to save memory? bool marked_for_strip = false; @@ -3191,7 +3192,7 @@ public: // Constructor for ReturnExpr. ReturnExpr (std::unique_ptr<Expr> returned_expr, - std::vector<Attribute> outer_attribs, Location locus) + std::vector<Attribute> outer_attribs, location_t locus) : outer_attrs (std::move (outer_attribs)), return_expr (std::move (returned_expr)), locus (locus) {} @@ -3268,13 +3269,13 @@ class UnsafeBlockExpr : public ExprWithBlock std::vector<Attribute> outer_attrs; // Or just have it extend BlockExpr std::unique_ptr<BlockExpr> expr; - Location locus; + location_t locus; public: std::string as_string () const override; UnsafeBlockExpr (std::unique_ptr<BlockExpr> block_expr, - std::vector<Attribute> outer_attribs, Location locus) + std::vector<Attribute> outer_attribs, location_t locus) : outer_attrs (std::move (outer_attribs)), expr (std::move (block_expr)), locus (locus) {} @@ -3346,14 +3347,14 @@ protected: class LoopLabel /*: public Node*/ { Lifetime label; // or type LIFETIME_OR_LABEL - Location locus; + location_t locus; NodeId node_id; public: std::string as_string () const; - LoopLabel (Lifetime loop_label, Location locus = UNDEF_LOCATION) + LoopLabel (Lifetime loop_label, location_t locus = UNDEF_LOCATION) : label (std::move (loop_label)), locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ()) {} @@ -3381,11 +3382,11 @@ protected: std::unique_ptr<BlockExpr> loop_block; private: - Location locus; + location_t locus; protected: // Constructor for BaseLoopExpr - BaseLoopExpr (std::unique_ptr<BlockExpr> loop_block, Location locus, + BaseLoopExpr (std::unique_ptr<BlockExpr> loop_block, location_t locus, LoopLabel loop_label = LoopLabel::error (), std::vector<Attribute> outer_attribs = std::vector<Attribute> ()) @@ -3459,7 +3460,7 @@ public: std::string as_string () const override; // Constructor for LoopExpr - LoopExpr (std::unique_ptr<BlockExpr> loop_block, Location locus, + LoopExpr (std::unique_ptr<BlockExpr> loop_block, location_t locus, LoopLabel loop_label = LoopLabel::error (), std::vector<Attribute> outer_attribs = std::vector<Attribute> ()) : BaseLoopExpr (std::move (loop_block), locus, std::move (loop_label), @@ -3487,7 +3488,7 @@ public: // Constructor for while loop with loop label WhileLoopExpr (std::unique_ptr<Expr> loop_condition, - std::unique_ptr<BlockExpr> loop_block, Location locus, + std::unique_ptr<BlockExpr> loop_block, location_t locus, LoopLabel loop_label = LoopLabel::error (), std::vector<Attribute> outer_attribs = std::vector<Attribute> ()) @@ -3548,7 +3549,7 @@ public: // Constructor with a loop label WhileLetLoopExpr (std::vector<std::unique_ptr<Pattern> > match_arm_patterns, std::unique_ptr<Expr> scrutinee, - std::unique_ptr<BlockExpr> loop_block, Location locus, + std::unique_ptr<BlockExpr> loop_block, location_t locus, LoopLabel loop_label = LoopLabel::error (), std::vector<Attribute> outer_attribs = std::vector<Attribute> ()) @@ -3630,7 +3631,7 @@ public: // Constructor with loop label ForLoopExpr (std::unique_ptr<Pattern> loop_pattern, std::unique_ptr<Expr> iterator_expr, - std::unique_ptr<BlockExpr> loop_body, Location locus, + std::unique_ptr<BlockExpr> loop_body, location_t locus, LoopLabel loop_label = LoopLabel::error (), std::vector<Attribute> outer_attribs = std::vector<Attribute> ()) : BaseLoopExpr (std::move (loop_body), locus, std::move (loop_label), @@ -3696,13 +3697,13 @@ class IfExpr : public ExprWithBlock std::vector<Attribute> outer_attrs; std::unique_ptr<Expr> condition; std::unique_ptr<BlockExpr> if_block; - Location locus; + location_t locus; public: std::string as_string () const override; IfExpr (std::unique_ptr<Expr> condition, std::unique_ptr<BlockExpr> if_block, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : outer_attrs (std::move (outer_attrs)), condition (std::move (condition)), if_block (std::move (if_block)), locus (locus) {} @@ -3818,7 +3819,7 @@ public: IfExprConseqElse (std::unique_ptr<Expr> condition, std::unique_ptr<BlockExpr> if_block, std::unique_ptr<ExprWithBlock> else_block, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : IfExpr (std::move (condition), std::move (if_block), std::move (outer_attrs), locus), else_block (std::move (else_block)) @@ -3872,14 +3873,14 @@ class IfLetExpr : public ExprWithBlock std::vector<std::unique_ptr<Pattern> > match_arm_patterns; // inlined std::unique_ptr<Expr> value; std::unique_ptr<BlockExpr> if_block; - Location locus; + location_t locus; public: std::string as_string () const override; IfLetExpr (std::vector<std::unique_ptr<Pattern> > match_arm_patterns, std::unique_ptr<Expr> value, std::unique_ptr<BlockExpr> if_block, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : outer_attrs (std::move (outer_attrs)), match_arm_patterns (std::move (match_arm_patterns)), value (std::move (value)), if_block (std::move (if_block)), locus (locus) @@ -4011,7 +4012,7 @@ public: std::vector<std::unique_ptr<Pattern> > match_arm_patterns, std::unique_ptr<Expr> value, std::unique_ptr<BlockExpr> if_block, std::unique_ptr<ExprWithBlock> else_block, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : IfLetExpr (std::move (match_arm_patterns), std::move (value), std::move (if_block), std::move (outer_attrs), locus), else_block (std::move (else_block)) @@ -4070,7 +4071,7 @@ private: // inlined from MatchArmGuard std::unique_ptr<Expr> guard_expr; - Location locus; + location_t locus; public: // Returns whether the MatchArm has a match arm guard expression @@ -4078,7 +4079,7 @@ public: // Constructor for match arm with a guard expression MatchArm (std::vector<std::unique_ptr<Pattern> > match_arm_patterns, - Location locus, std::unique_ptr<Expr> guard_expr = nullptr, + location_t locus, std::unique_ptr<Expr> guard_expr = nullptr, std::vector<Attribute> outer_attrs = std::vector<Attribute> ()) : outer_attrs (std::move (outer_attrs)), match_arm_patterns (std::move (match_arm_patterns)), @@ -4128,7 +4129,7 @@ public: // Creates a match arm in an error state. static MatchArm create_error () { - Location locus = UNDEF_LOCATION; + location_t locus = UNDEF_LOCATION; return MatchArm (std::vector<std::unique_ptr<Pattern> > (), locus); } @@ -4219,7 +4220,7 @@ class MatchExpr : public ExprWithBlock std::unique_ptr<Expr> branch_value; std::vector<Attribute> inner_attrs; std::vector<MatchCase> match_arms; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -4230,7 +4231,7 @@ public: MatchExpr (std::unique_ptr<Expr> branch_value, std::vector<MatchCase> match_arms, std::vector<Attribute> inner_attrs, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : outer_attrs (std::move (outer_attrs)), branch_value (std::move (branch_value)), inner_attrs (std::move (inner_attrs)), @@ -4314,12 +4315,12 @@ class AwaitExpr : public ExprWithoutBlock { std::vector<Attribute> outer_attrs; std::unique_ptr<Expr> awaited_expr; - Location locus; + location_t locus; public: // TODO: ensure outer attributes are actually allowed AwaitExpr (std::unique_ptr<Expr> awaited_expr, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : outer_attrs (std::move (outer_attrs)), awaited_expr (std::move (awaited_expr)), locus (locus) {} @@ -4395,11 +4396,11 @@ class AsyncBlockExpr : public ExprWithBlock std::vector<Attribute> outer_attrs; bool has_move; std::unique_ptr<BlockExpr> block_expr; - Location locus; + location_t locus; public: AsyncBlockExpr (std::unique_ptr<BlockExpr> block_expr, bool has_move, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : outer_attrs (std::move (outer_attrs)), has_move (has_move), block_expr (std::move (block_expr)), locus (locus) {} @@ -4509,7 +4510,7 @@ struct InlineAsmRegOrRegClass }; Identifier name; - Location locus; + location_t locus; }; struct InlineAsmOperand @@ -4561,14 +4562,14 @@ struct InlineAsmOperand { std::unique_ptr<Expr> sym; }; - Location locus; + location_t locus; }; struct InlineAsmPlaceHolder { size_t operand_idx; char modifier; // can be null - Location locus; + location_t locus; }; struct InlineAsmTemplatePiece diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h index 8ddfb1d..d385798 100644 --- a/gcc/rust/ast/rust-item.h +++ b/gcc/rust/ast/rust-item.h @@ -63,7 +63,7 @@ class TypeParam : public GenericParam // bool has_type; std::unique_ptr<Type> type; - Location locus; + location_t locus; public: Identifier get_type_representation () const { return type_representation; } @@ -77,7 +77,7 @@ public: // Returns whether the type param has an outer attribute. bool has_outer_attribute () const { return !outer_attr.is_empty (); } - TypeParam (Identifier type_representation, Location locus = UNDEF_LOCATION, + TypeParam (Identifier type_representation, location_t locus = UNDEF_LOCATION, std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds = std::vector<std::unique_ptr<TypeParamBound>> (), std::unique_ptr<Type> type = nullptr, @@ -191,13 +191,13 @@ class LifetimeWhereClauseItem : public WhereClauseItem { Lifetime lifetime; std::vector<Lifetime> lifetime_bounds; - Location locus; + location_t locus; NodeId node_id; public: LifetimeWhereClauseItem (Lifetime lifetime, std::vector<Lifetime> lifetime_bounds, - Location locus) + location_t locus) : lifetime (std::move (lifetime)), lifetime_bounds (std::move (lifetime_bounds)), locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ()) @@ -230,7 +230,7 @@ class TypeBoundWhereClauseItem : public WhereClauseItem std::unique_ptr<Type> bound_type; std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds; NodeId node_id; - Location locus; + location_t locus; public: // Returns whether the item has ForLifetimes @@ -244,7 +244,7 @@ public: TypeBoundWhereClauseItem ( std::vector<LifetimeParam> for_lifetimes, std::unique_ptr<Type> bound_type, std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds, - Location locus) + location_t locus) : for_lifetimes (std::move (for_lifetimes)), bound_type (std::move (bound_type)), type_param_bounds (std::move (type_param_bounds)), @@ -387,7 +387,7 @@ class SelfParam NodeId node_id; - Location locus; + location_t locus; // Unrestricted constructor used for error state SelfParam (Lifetime lifetime, bool has_ref, bool is_mut, Type *type) @@ -420,14 +420,14 @@ public: } // Type-based self parameter (not ref, no lifetime) - SelfParam (std::unique_ptr<Type> type, bool is_mut, Location locus) + SelfParam (std::unique_ptr<Type> type, bool is_mut, location_t locus) : has_ref (false), is_mut (is_mut), lifetime (Lifetime::error ()), type (std::move (type)), node_id (Analysis::Mappings::get ()->get_next_node_id ()), locus (locus) {} // Lifetime-based self parameter (is ref, no type) - SelfParam (Lifetime lifetime, bool is_mut, Location locus) + SelfParam (Lifetime lifetime, bool is_mut, location_t locus) : has_ref (true), is_mut (is_mut), lifetime (std::move (lifetime)), node_id (Analysis::Mappings::get ()->get_next_node_id ()), locus (locus) {} @@ -490,10 +490,10 @@ class FunctionQualifiers bool has_unsafe; bool has_extern; std::string extern_abi; - Location locus; + location_t locus; public: - FunctionQualifiers (Location locus, AsyncConstStatus const_status, + FunctionQualifiers (location_t locus, AsyncConstStatus const_status, bool has_unsafe, bool has_extern = false, std::string extern_abi = std::string ()) : const_status (const_status), has_unsafe (has_unsafe), @@ -522,14 +522,14 @@ public: class FunctionParam { std::vector<Attribute> outer_attrs; - Location locus; + location_t locus; std::unique_ptr<Pattern> param_name; std::unique_ptr<Type> type; public: FunctionParam (std::unique_ptr<Pattern> param_name, std::unique_ptr<Type> param_type, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : outer_attrs (std::move (outer_attrs)), locus (locus), param_name (std::move (param_name)), type (std::move (param_type)), node_id (Analysis::Mappings::get ()->get_next_node_id ()) @@ -623,13 +623,13 @@ private: VisType vis_type; // Only assigned if vis_type is IN_PATH SimplePath in_path; - Location locus; + location_t locus; // should this store location info? public: // Creates a Visibility - TODO make constructor protected or private? - Visibility (VisType vis_type, SimplePath in_path, Location locus) + Visibility (VisType vis_type, SimplePath in_path, location_t locus) : vis_type (vis_type), in_path (std::move (in_path)), locus (locus) {} @@ -738,7 +738,7 @@ class Method : public InherentImplItem, public TraitImplItem std::unique_ptr<Type> return_type; WhereClause where_clause; std::unique_ptr<BlockExpr> function_body; - Location locus; + location_t locus; NodeId node_id; bool is_default; @@ -781,7 +781,7 @@ public: SelfParam self_param, std::vector<FunctionParam> function_params, std::unique_ptr<Type> return_type, WhereClause where_clause, std::unique_ptr<BlockExpr> function_body, Visibility vis, - std::vector<Attribute> outer_attrs, Location locus, + std::vector<Attribute> outer_attrs, location_t locus, bool is_default = false) : outer_attrs (std::move (outer_attrs)), vis (std::move (vis)), qualifiers (std::move (qualifiers)), @@ -1008,7 +1008,7 @@ public: private: Identifier module_name; - Location locus; + location_t locus; ModuleKind kind; // Name of the file including the module @@ -1040,7 +1040,7 @@ public: // Unloaded module constructor Module (Identifier module_name, Visibility visibility, - std::vector<Attribute> outer_attrs, Location locus, + std::vector<Attribute> outer_attrs, location_t locus, std::string outer_filename, std::vector<std::string> module_scope) : VisItem (std::move (visibility), std::move (outer_attrs)), module_name (module_name), locus (locus), kind (ModuleKind::UNLOADED), @@ -1050,7 +1050,7 @@ public: {} // Loaded module constructor, with items - Module (Identifier name, Location locus, + Module (Identifier name, location_t locus, std::vector<std::unique_ptr<Item>> items, Visibility visibility = Visibility::create_error (), std::vector<Attribute> inner_attrs = std::vector<Attribute> (), @@ -1156,7 +1156,7 @@ class ExternCrate : public VisItem // this is either an identifier or "_", with _ parsed to string std::string as_clause_name; - Location locus; + location_t locus; /* e.g. "extern crate foo as _" @@ -1174,7 +1174,7 @@ public: // Constructor ExternCrate (std::string referenced_crate, Visibility visibility, - std::vector<Attribute> outer_attrs, Location locus, + std::vector<Attribute> outer_attrs, location_t locus, std::string as_clause_name = std::string ()) : VisItem (std::move (visibility), std::move (outer_attrs)), referenced_crate (std::move (referenced_crate)), @@ -1213,7 +1213,7 @@ protected: // The path-ish thing referred to in a use declaration - abstract base class class UseTree { - Location locus; + location_t locus; public: enum Kind @@ -1256,7 +1256,7 @@ protected: // Clone function implementation as pure virtual method virtual UseTree *clone_use_tree_impl () const = 0; - UseTree (Location locus) : locus (locus) {} + UseTree (location_t locus) : locus (locus) {} }; // Use tree with a glob (wildcard) operator @@ -1275,7 +1275,7 @@ private: SimplePath path; public: - UseTreeGlob (PathType glob_type, SimplePath path, Location locus) + UseTreeGlob (PathType glob_type, SimplePath path, location_t locus) : UseTree (locus), glob_type (glob_type), path (std::move (path)) { if (this->glob_type != PATH_PREFIXED) @@ -1336,7 +1336,7 @@ private: public: UseTreeList (PathType path_type, SimplePath path, - std::vector<std::unique_ptr<UseTree>> trees, Location locus) + std::vector<std::unique_ptr<UseTree>> trees, location_t locus) : UseTree (locus), path_type (path_type), path (std::move (path)), trees (std::move (trees)) { @@ -1432,7 +1432,7 @@ private: Identifier identifier; // only if NewBindType is IDENTIFIER public: - UseTreeRebind (NewBindType bind_type, SimplePath path, Location locus, + UseTreeRebind (NewBindType bind_type, SimplePath path, location_t locus, Identifier identifier = std::string ()) : UseTree (locus), path (std::move (path)), bind_type (bind_type), identifier (std::move (identifier)) @@ -1479,13 +1479,13 @@ protected: class UseDeclaration : public VisItem { std::unique_ptr<UseTree> use_tree; - Location locus; + location_t locus; public: std::string as_string () const override; UseDeclaration (std::unique_ptr<UseTree> use_tree, Visibility visibility, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : VisItem (std::move (visibility), std::move (outer_attrs)), use_tree (std::move (use_tree)), locus (locus) {} @@ -1553,7 +1553,7 @@ class Function : public VisItem, public InherentImplItem, public TraitImplItem std::unique_ptr<Type> return_type; WhereClause where_clause; std::unique_ptr<BlockExpr> function_body; - Location locus; + location_t locus; bool is_default; public: @@ -1577,7 +1577,7 @@ public: std::vector<FunctionParam> function_params, std::unique_ptr<Type> return_type, WhereClause where_clause, std::unique_ptr<BlockExpr> function_body, Visibility vis, - std::vector<Attribute> outer_attrs, Location locus, + std::vector<Attribute> outer_attrs, location_t locus, bool is_default = false) : VisItem (std::move (vis), std::move (outer_attrs)), qualifiers (std::move (qualifiers)), @@ -1730,7 +1730,7 @@ class TypeAlias : public VisItem, public TraitImplItem std::unique_ptr<Type> existing_type; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -1745,7 +1745,8 @@ public: TypeAlias (Identifier new_type_name, std::vector<std::unique_ptr<GenericParam>> generic_params, WhereClause where_clause, std::unique_ptr<Type> existing_type, - Visibility vis, std::vector<Attribute> outer_attrs, Location locus) + Visibility vis, std::vector<Attribute> outer_attrs, + location_t locus) : VisItem (std::move (vis), std::move (outer_attrs)), new_type_name (std::move (new_type_name)), generic_params (std::move (generic_params)), @@ -1854,7 +1855,7 @@ protected: WhereClause where_clause; private: - Location locus; + location_t locus; public: // Returns whether struct has generic parameters. @@ -1888,7 +1889,7 @@ public: protected: Struct (Identifier struct_name, std::vector<std::unique_ptr<GenericParam>> generic_params, - WhereClause where_clause, Visibility vis, Location locus, + WhereClause where_clause, Visibility vis, location_t locus, std::vector<Attribute> outer_attrs = std::vector<Attribute> ()) : VisItem (std::move (vis), std::move (outer_attrs)), struct_name (std::move (struct_name)), @@ -1940,7 +1941,7 @@ class StructField NodeId node_id; - Location locus; + location_t locus; public: // Returns whether struct field has any outer attributes. @@ -1950,7 +1951,7 @@ public: bool has_visibility () const { return !visibility.is_error (); } StructField (Identifier field_name, std::unique_ptr<Type> field_type, - Visibility vis, Location locus, + Visibility vis, location_t locus, std::vector<Attribute> outer_attrs = std::vector<Attribute> ()) : outer_attrs (std::move (outer_attrs)), visibility (std::move (vis)), field_name (std::move (field_name)), field_type (std::move (field_type)), @@ -2041,7 +2042,7 @@ public: StructStruct (std::vector<StructField> fields, Identifier struct_name, std::vector<std::unique_ptr<GenericParam>> generic_params, WhereClause where_clause, bool is_unit, Visibility vis, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : Struct (std::move (struct_name), std::move (generic_params), std::move (where_clause), std::move (vis), locus, std::move (outer_attrs)), @@ -2052,7 +2053,7 @@ public: StructStruct (Identifier struct_name, std::vector<std::unique_ptr<GenericParam>> generic_params, WhereClause where_clause, Visibility vis, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : Struct (std::move (struct_name), std::move (generic_params), std::move (where_clause), std::move (vis), locus, std::move (outer_attrs)), @@ -2092,7 +2093,7 @@ class TupleField NodeId node_id; - Location locus; + location_t locus; public: // Returns whether tuple field has outer attributes. @@ -2103,7 +2104,8 @@ public: bool has_visibility () const { return !visibility.is_error (); } // Complete constructor - TupleField (std::unique_ptr<Type> field_type, Visibility vis, Location locus, + TupleField (std::unique_ptr<Type> field_type, Visibility vis, + location_t locus, std::vector<Attribute> outer_attrs = std::vector<Attribute> ()) : outer_attrs (std::move (outer_attrs)), visibility (std::move (vis)), field_type (std::move (field_type)), @@ -2185,7 +2187,7 @@ public: TupleStruct (std::vector<TupleField> fields, Identifier struct_name, std::vector<std::unique_ptr<GenericParam>> generic_params, WhereClause where_clause, Visibility vis, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : Struct (std::move (struct_name), std::move (generic_params), std::move (where_clause), std::move (vis), locus, std::move (outer_attrs)), @@ -2214,13 +2216,13 @@ class EnumItem : public VisItem { Identifier variant_name; - Location locus; + location_t locus; public: virtual ~EnumItem () {} EnumItem (Identifier variant_name, Visibility vis, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : VisItem (std::move (vis), std::move (outer_attrs)), variant_name (std::move (variant_name)), locus (locus) {} @@ -2260,7 +2262,7 @@ public: EnumItemTuple (Identifier variant_name, Visibility vis, std::vector<TupleField> tuple_fields, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : EnumItem (std::move (variant_name), std::move (vis), std::move (outer_attrs), locus), tuple_fields (std::move (tuple_fields)) @@ -2297,7 +2299,7 @@ public: EnumItemStruct (Identifier variant_name, Visibility vis, std::vector<StructField> struct_fields, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : EnumItem (std::move (variant_name), std::move (vis), std::move (outer_attrs), locus), struct_fields (std::move (struct_fields)) @@ -2330,7 +2332,7 @@ class EnumItemDiscriminant : public EnumItem public: EnumItemDiscriminant (Identifier variant_name, Visibility vis, std::unique_ptr<Expr> expr, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : EnumItem (std::move (variant_name), std::move (vis), std::move (outer_attrs), locus), expression (std::move (expr)) @@ -2389,7 +2391,7 @@ class Enum : public VisItem std::vector<std::unique_ptr<EnumItem>> items; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -2408,7 +2410,7 @@ public: Enum (Identifier enum_name, Visibility vis, std::vector<std::unique_ptr<GenericParam>> generic_params, WhereClause where_clause, std::vector<std::unique_ptr<EnumItem>> items, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : VisItem (std::move (vis), std::move (outer_attrs)), enum_name (std::move (enum_name)), generic_params (std::move (generic_params)), @@ -2504,7 +2506,7 @@ class Union : public VisItem std::vector<StructField> variants; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -2518,7 +2520,7 @@ public: Union (Identifier union_name, Visibility vis, std::vector<std::unique_ptr<GenericParam>> generic_params, WhereClause where_clause, std::vector<StructField> variants, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : VisItem (std::move (vis), std::move (outer_attrs)), union_name (std::move (union_name)), generic_params (std::move (generic_params)), @@ -2603,14 +2605,14 @@ class ConstantItem : public VisItem, std::unique_ptr<Type> type; std::unique_ptr<Expr> const_expr; - Location locus; + location_t locus; public: std::string as_string () const override; ConstantItem (std::string ident, Visibility vis, std::unique_ptr<Type> type, std::unique_ptr<Expr> const_expr, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : VisItem (std::move (vis), std::move (outer_attrs)), identifier (std::move (ident)), type (std::move (type)), const_expr (std::move (const_expr)), locus (locus) @@ -2718,14 +2720,14 @@ class StaticItem : public VisItem Identifier name; std::unique_ptr<Type> type; std::unique_ptr<Expr> expr; - Location locus; + location_t locus; public: std::string as_string () const override; StaticItem (Identifier name, bool is_mut, std::unique_ptr<Type> type, std::unique_ptr<Expr> expr, Visibility vis, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : VisItem (std::move (vis), std::move (outer_attrs)), has_mut (is_mut), name (std::move (name)), type (std::move (type)), expr (std::move (expr)), locus (locus) @@ -2948,7 +2950,7 @@ public: bool has_definition () const { return block_expr != nullptr; } TraitItemFunc (TraitFunctionDecl decl, std::unique_ptr<BlockExpr> block_expr, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : TraitItem (locus), outer_attrs (std::move (outer_attrs)), decl (std::move (decl)), block_expr (std::move (block_expr)) {} @@ -3164,7 +3166,7 @@ public: bool has_definition () const { return block_expr != nullptr; } TraitItemMethod (TraitMethodDecl decl, std::unique_ptr<BlockExpr> block_expr, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : TraitItem (locus), outer_attrs (std::move (outer_attrs)), decl (std::move (decl)), block_expr (std::move (block_expr)) {} @@ -3252,7 +3254,7 @@ public: TraitItemConst (Identifier name, std::unique_ptr<Type> type, std::unique_ptr<Expr> expr, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : TraitItem (locus), outer_attrs (std::move (outer_attrs)), name (std::move (name)), type (std::move (type)), expr (std::move (expr)) {} @@ -3359,7 +3361,7 @@ public: TraitItemType (Identifier name, std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : TraitItem (locus), outer_attrs (std::move (outer_attrs)), name (std::move (name)), type_param_bounds (std::move (type_param_bounds)) {} @@ -3439,7 +3441,7 @@ class Trait : public VisItem WhereClause where_clause; std::vector<Attribute> inner_attrs; std::vector<std::unique_ptr<TraitItem>> trait_items; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -3471,7 +3473,7 @@ public: WhereClause where_clause, std::vector<std::unique_ptr<TraitItem>> trait_items, Visibility vis, std::vector<Attribute> outer_attrs, std::vector<Attribute> inner_attrs, - Location locus) + location_t locus) : VisItem (std::move (vis), std::move (outer_attrs)), has_unsafe (is_unsafe), has_auto (is_auto), name (std::move (name)), generic_params (std::move (generic_params)), @@ -3611,7 +3613,7 @@ protected: private: // doesn't really need to be protected as write access probably not needed - Location locus; + location_t locus; public: // Returns whether impl has generic parameters. @@ -3657,7 +3659,7 @@ protected: Impl (std::vector<std::unique_ptr<GenericParam>> generic_params, std::unique_ptr<Type> trait_type, WhereClause where_clause, Visibility vis, std::vector<Attribute> inner_attrs, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : VisItem (std::move (vis), std::move (outer_attrs)), generic_params (std::move (generic_params)), trait_type (std::move (trait_type)), @@ -3722,7 +3724,7 @@ public: std::vector<std::unique_ptr<GenericParam>> generic_params, std::unique_ptr<Type> trait_type, WhereClause where_clause, Visibility vis, std::vector<Attribute> inner_attrs, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : Impl (std::move (generic_params), std::move (trait_type), std::move (where_clause), std::move (vis), std::move (inner_attrs), std::move (outer_attrs), locus), @@ -3796,7 +3798,7 @@ public: std::vector<std::unique_ptr<GenericParam>> generic_params, std::unique_ptr<Type> trait_type, WhereClause where_clause, Visibility vis, std::vector<Attribute> inner_attrs, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : Impl (std::move (generic_params), std::move (trait_type), std::move (where_clause), std::move (vis), std::move (inner_attrs), std::move (outer_attrs), locus), @@ -3872,7 +3874,7 @@ class ExternalItem Visibility visibility; Identifier item_name; - Location locus; + location_t locus; public: virtual ~ExternalItem () {} @@ -3906,7 +3908,7 @@ public: protected: ExternalItem (Identifier item_name, Visibility vis, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : outer_attrs (std::move (outer_attrs)), visibility (std::move (vis)), item_name (std::move (item_name)), locus (locus) {} @@ -3948,13 +3950,13 @@ class ExternalTypeItem : public ExternalItem Visibility visibility; Identifier item_name; - Location locus; + location_t locus; bool marked_for_strip; public: ExternalTypeItem (Identifier item_name, Visibility vis, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : ExternalItem (), outer_attrs (std::move (outer_attrs)), visibility (vis), item_name (std::move (item_name)), locus (locus), marked_for_strip (false) {} @@ -4026,7 +4028,7 @@ class ExternalStaticItem : public ExternalItem Visibility visibility; Identifier item_name; - Location locus; + location_t locus; bool has_mut; std::unique_ptr<Type> item_type; @@ -4034,7 +4036,7 @@ class ExternalStaticItem : public ExternalItem public: ExternalStaticItem (Identifier item_name, std::unique_ptr<Type> item_type, bool is_mut, Visibility vis, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : ExternalItem (), outer_attrs (std::move (outer_attrs)), visibility (std::move (vis)), item_name (std::move (item_name)), locus (locus), has_mut (is_mut), item_type (std::move (item_type)) @@ -4130,7 +4132,7 @@ class NamedFunctionParam std::vector<Attribute> outer_attrs; NodeId node_id; - Location locus; + location_t locus; public: /* Returns whether the named function parameter has a name (i.e. name is not @@ -4157,7 +4159,7 @@ public: } NamedFunctionParam (std::string name, std::unique_ptr<Type> param_type, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : name (std::move (name)), param_type (std::move (param_type)), outer_attrs (std::move (outer_attrs)), node_id (Analysis::Mappings::get ()->get_next_node_id ()), locus (locus) @@ -4226,7 +4228,7 @@ class ExternalFunctionItem : public ExternalItem Visibility visibility; Identifier item_name; - Location locus; + location_t locus; // bool has_generics; // Generics generic_params; @@ -4279,7 +4281,7 @@ public: std::unique_ptr<Type> return_type, WhereClause where_clause, std::vector<NamedFunctionParam> function_params, bool has_variadics, std::vector<Attribute> variadic_outer_attrs, Visibility vis, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : ExternalItem (), outer_attrs (std::move (outer_attrs)), visibility (std::move (vis)), item_name (std::move (item_name)), locus (locus), generic_params (std::move (generic_params)), @@ -4405,7 +4407,7 @@ class ExternBlock : public VisItem // bool has_extern_items; std::vector<std::unique_ptr<ExternalItem>> extern_items; - Location locus; + location_t locus; // TODO: find another way to store this to save memory? bool marked_for_strip = false; @@ -4427,7 +4429,7 @@ public: ExternBlock (std::string abi, std::vector<std::unique_ptr<ExternalItem>> extern_items, Visibility vis, std::vector<Attribute> inner_attrs, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : VisItem (std::move (vis), std::move (outer_attrs)), abi (std::move (abi)), inner_attrs (std::move (inner_attrs)), extern_items (std::move (extern_items)), locus (locus) diff --git a/gcc/rust/ast/rust-macro.h b/gcc/rust/ast/rust-macro.h index 55fbd3a..b416208 100644 --- a/gcc/rust/ast/rust-macro.h +++ b/gcc/rust/ast/rust-macro.h @@ -167,10 +167,11 @@ class MacroMatchFragment : public MacroMatch { Identifier ident; MacroFragSpec frag_spec; - Location locus; + location_t locus; public: - MacroMatchFragment (Identifier ident, MacroFragSpec frag_spec, Location locus) + MacroMatchFragment (Identifier ident, MacroFragSpec frag_spec, + location_t locus) : ident (std::move (ident)), frag_spec (frag_spec), locus (locus) {} @@ -181,7 +182,7 @@ public: } // Creates an error state macro match fragment. - static MacroMatchFragment create_error (Location locus) + static MacroMatchFragment create_error (location_t locus) { return MacroMatchFragment (std::string (""), MacroFragSpec (MacroFragSpec::Kind::INVALID), @@ -230,7 +231,7 @@ private: typedef Token MacroRepSep; // any token except delimiters and repetition operators std::unique_ptr<MacroRepSep> sep; - Location locus; + location_t locus; public: // Returns whether macro match repetition has separator token. @@ -238,7 +239,7 @@ public: MacroMatchRepetition (std::vector<std::unique_ptr<MacroMatch>> matches, MacroRepOp op, std::unique_ptr<MacroRepSep> sep, - Location locus) + location_t locus) : matches (std::move (matches)), op (op), sep (std::move (sep)), locus (locus) {} @@ -311,7 +312,7 @@ class MacroMatcher : public MacroMatch { DelimType delim_type; std::vector<std::unique_ptr<MacroMatch>> matches; - Location locus; + location_t locus; // TODO: think of way to mark invalid that doesn't take up more space bool is_invalid; @@ -319,7 +320,7 @@ class MacroMatcher : public MacroMatch public: MacroMatcher (DelimType delim_type, std::vector<std::unique_ptr<MacroMatch>> matches, - Location locus) + location_t locus) : delim_type (delim_type), matches (std::move (matches)), locus (locus), is_invalid (false) {} @@ -351,7 +352,7 @@ public: MacroMatcher &operator= (MacroMatcher &&other) = default; // Creates an error state macro matcher. - static MacroMatcher create_error (Location locus) + static MacroMatcher create_error (location_t locus) { return MacroMatcher (true, locus); } @@ -385,7 +386,7 @@ protected: } // constructor only used to create error matcher - MacroMatcher (bool is_invalid, Location locus) + MacroMatcher (bool is_invalid, location_t locus) : delim_type (PARENS), locus (locus), is_invalid (is_invalid) {} }; @@ -395,10 +396,10 @@ struct MacroTranscriber { private: DelimTokenTree token_tree; - Location locus; + location_t locus; public: - MacroTranscriber (DelimTokenTree token_tree, Location locus) + MacroTranscriber (DelimTokenTree token_tree, location_t locus) : token_tree (std::move (token_tree)), locus (locus) {} @@ -416,10 +417,11 @@ struct MacroRule private: MacroMatcher matcher; MacroTranscriber transcriber; - Location locus; + location_t locus; public: - MacroRule (MacroMatcher matcher, MacroTranscriber transcriber, Location locus) + MacroRule (MacroMatcher matcher, MacroTranscriber transcriber, + location_t locus) : matcher (std::move (matcher)), transcriber (std::move (transcriber)), locus (locus) {} @@ -428,7 +430,7 @@ public: bool is_error () const { return matcher.is_error (); } // Creates an error state macro rule. - static MacroRule create_error (Location locus) + static MacroRule create_error (location_t locus) { return MacroRule (MacroMatcher::create_error (locus), MacroTranscriber (DelimTokenTree::create_empty (), @@ -464,7 +466,7 @@ private: DelimType delim_type; // MacroRules rules; std::vector<MacroRule> rules; // inlined form - Location locus; + location_t locus; std::function<Fragment (Location, MacroInvocData &)> associated_transcriber; // Since we can't compare std::functions, we need to use an extra boolean @@ -491,7 +493,7 @@ private: * is "extremely self-referential and non-intuitive". */ MacroRulesDefinition (Identifier rule_name, DelimType delim_type, std::vector<MacroRule> rules, - std::vector<Attribute> outer_attrs, Location locus, + std::vector<Attribute> outer_attrs, location_t locus, MacroKind kind, Visibility vis) : VisItem (std::move (vis), outer_attrs), outer_attrs (std::move (outer_attrs)), rule_name (std::move (rule_name)), @@ -516,7 +518,7 @@ public: static std::unique_ptr<MacroRulesDefinition> mbe (Identifier rule_name, DelimType delim_type, std::vector<MacroRule> rules, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) { return Rust::make_unique<MacroRulesDefinition> ( MacroRulesDefinition (rule_name, delim_type, rules, outer_attrs, locus, @@ -526,7 +528,7 @@ public: static std::unique_ptr<MacroRulesDefinition> decl_macro (Identifier rule_name, std::vector<MacroRule> rules, - std::vector<Attribute> outer_attrs, Location locus, + std::vector<Attribute> outer_attrs, location_t locus, Visibility vis) { return Rust::make_unique<MacroRulesDefinition> (MacroRulesDefinition ( @@ -619,7 +621,7 @@ public: */ static std::unique_ptr<MacroInvocation> Regular (MacroInvocData invoc_data, std::vector<Attribute> outer_attrs, - Location locus, bool is_semi_coloned = false) + location_t locus, bool is_semi_coloned = false) { return std::unique_ptr<MacroInvocation> ( new MacroInvocation (InvocKind::Regular, tl::nullopt, invoc_data, @@ -633,7 +635,7 @@ public: */ static std::unique_ptr<MacroInvocation> Builtin ( BuiltinMacro kind, MacroInvocData invoc_data, - std::vector<Attribute> outer_attrs, Location locus, + std::vector<Attribute> outer_attrs, location_t locus, std::vector<std::unique_ptr<MacroInvocation>> &&pending_eager_invocations = {}, bool is_semi_coloned = false) @@ -711,7 +713,7 @@ private: MacroInvocation ( InvocKind kind, tl::optional<BuiltinMacro> builtin_kind, MacroInvocData invoc_data, std::vector<Attribute> outer_attrs, - Location locus, bool is_semi_coloned, + location_t locus, bool is_semi_coloned, std::vector<std::unique_ptr<MacroInvocation>> &&pending_eager_invocs) : TraitItem (locus), outer_attrs (std::move (outer_attrs)), locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ()), @@ -733,7 +735,7 @@ private: } std::vector<Attribute> outer_attrs; - Location locus; + location_t locus; NodeId node_id; /* The data given to the macro invocation */ diff --git a/gcc/rust/ast/rust-path.cc b/gcc/rust/ast/rust-path.cc index 7c6d7e1..431480c 100644 --- a/gcc/rust/ast/rust-path.cc +++ b/gcc/rust/ast/rust-path.cc @@ -172,7 +172,7 @@ PathPattern::convert_to_simple_path (bool with_opening_scope_resolution) const } // kind of a HACK to get locus depending on opening scope resolution - Location locus = UNKNOWN_LOCATION; + location_t locus = UNKNOWN_LOCATION; if (with_opening_scope_resolution) locus = simple_segments[0].get_locus () - 2; // minus 2 chars for :: else diff --git a/gcc/rust/ast/rust-path.h b/gcc/rust/ast/rust-path.h index 5675fda..7f14a3f 100644 --- a/gcc/rust/ast/rust-path.h +++ b/gcc/rust/ast/rust-path.h @@ -31,11 +31,11 @@ namespace AST { class PathIdentSegment { std::string segment_name; - Location locus; + location_t locus; // only allow identifiers, "super", "self", "Self", "crate", or "$crate" public: - PathIdentSegment (std::string segment_name, Location locus) + PathIdentSegment (std::string segment_name, location_t locus) : segment_name (std::move (segment_name)), locus (locus) {} @@ -64,7 +64,7 @@ struct GenericArgsBinding private: Identifier identifier; std::unique_ptr<Type> type; - Location locus; + location_t locus; public: // Returns whether binding is in an error state. @@ -82,7 +82,7 @@ public: // Pointer type for type in constructor to enable polymorphism GenericArgsBinding (Identifier ident, std::unique_ptr<Type> type_ptr, - Location locus = UNDEF_LOCATION) + location_t locus = UNDEF_LOCATION) : identifier (std::move (ident)), type (std::move (type_ptr)), locus (locus) {} @@ -175,7 +175,7 @@ public: return GenericArg (nullptr, std::move (type), {""}, Kind::Type, locus); } - static GenericArg create_ambiguous (Identifier path, Location locus) + static GenericArg create_ambiguous (Identifier path, location_t locus) { return GenericArg (nullptr, nullptr, std::move (path), Kind::Either, locus); } @@ -280,7 +280,7 @@ public: private: GenericArg (std::unique_ptr<Expr> expression, std::unique_ptr<Type> type, - Identifier path, Kind kind, Location locus) + Identifier path, Kind kind, location_t locus) : expression (std::move (expression)), type (std::move (type)), path (std::move (path)), kind (kind), locus (locus) {} @@ -308,7 +308,7 @@ private: /* Which kind of const generic application are we dealing with */ Kind kind; - Location locus; + location_t locus; }; /** @@ -328,12 +328,12 @@ class ConstGenericParam : public GenericParam GenericArg default_value; Attribute outer_attr; - Location locus; + location_t locus; public: ConstGenericParam (Identifier name, std::unique_ptr<AST::Type> type, GenericArg default_value, Attribute outer_attr, - Location locus) + location_t locus) : name (name), type (std::move (type)), default_value (std::move (default_value)), outer_attr (outer_attr), locus (locus) @@ -394,7 +394,7 @@ struct GenericArgs std::vector<Lifetime> lifetime_args; std::vector<GenericArg> generic_args; std::vector<GenericArgsBinding> binding_args; - Location locus; + location_t locus; public: // Returns true if there are any generic arguments @@ -407,7 +407,7 @@ public: GenericArgs (std::vector<Lifetime> lifetime_args, std::vector<GenericArg> generic_args, std::vector<GenericArgsBinding> binding_args, - Location locus = UNDEF_LOCATION) + location_t locus = UNDEF_LOCATION) : lifetime_args (std::move (lifetime_args)), generic_args (std::move (generic_args)), binding_args (std::move (binding_args)), locus (locus) @@ -472,7 +472,7 @@ class PathExprSegment private: PathIdentSegment segment_name; GenericArgs generic_args; - Location locus; + location_t locus; NodeId node_id; public: @@ -480,7 +480,7 @@ public: bool has_generic_args () const { return generic_args.has_generic_args (); } // Constructor for segment (from IdentSegment and GenericArgs) - PathExprSegment (PathIdentSegment segment_name, Location locus, + PathExprSegment (PathIdentSegment segment_name, location_t locus, GenericArgs generic_args = GenericArgs::create_empty ()) : segment_name (std::move (segment_name)), generic_args (std::move (generic_args)), locus (locus), @@ -489,7 +489,7 @@ public: /* Constructor for segment with generic arguments (from segment name and all * args) */ - PathExprSegment (std::string segment_name, Location locus, + PathExprSegment (std::string segment_name, location_t locus, std::vector<Lifetime> lifetime_args = {}, std::vector<GenericArg> generic_args = {}, std::vector<GenericArgsBinding> binding_args = {}) @@ -583,7 +583,7 @@ class PathInExpression : public PathPattern, public PathExpr { std::vector<Attribute> outer_attrs; bool has_opening_scope_resolution; - Location locus; + location_t locus; NodeId _node_id; public: @@ -591,7 +591,7 @@ public: // Constructor PathInExpression (std::vector<PathExprSegment> path_segments, - std::vector<Attribute> outer_attrs, Location locus, + std::vector<Attribute> outer_attrs, location_t locus, bool has_opening_scope_resolution = false) : PathPattern (std::move (path_segments)), outer_attrs (std::move (outer_attrs)), @@ -681,7 +681,7 @@ public: private: PathIdentSegment ident_segment; - Location locus; + location_t locus; protected: /* This is protected because it is only really used by derived classes, not @@ -709,14 +709,14 @@ public: } TypePathSegment (PathIdentSegment ident_segment, - bool has_separating_scope_resolution, Location locus) + bool has_separating_scope_resolution, location_t locus) : ident_segment (std::move (ident_segment)), locus (locus), has_separating_scope_resolution (has_separating_scope_resolution), node_id (Analysis::Mappings::get ()->get_next_node_id ()) {} TypePathSegment (std::string segment_name, - bool has_separating_scope_resolution, Location locus) + bool has_separating_scope_resolution, location_t locus) : ident_segment (PathIdentSegment (std::move (segment_name), locus)), locus (locus), has_separating_scope_resolution (has_separating_scope_resolution), @@ -797,7 +797,7 @@ public: // Constructor with PathIdentSegment and GenericArgs TypePathSegmentGeneric (PathIdentSegment ident_segment, bool has_separating_scope_resolution, - GenericArgs generic_args, Location locus) + GenericArgs generic_args, location_t locus) : TypePathSegment (std::move (ident_segment), has_separating_scope_resolution, locus), generic_args (std::move (generic_args)) @@ -809,7 +809,7 @@ public: std::vector<Lifetime> lifetime_args, std::vector<GenericArg> generic_args, std::vector<GenericArgsBinding> binding_args, - Location locus) + location_t locus) : TypePathSegment (std::move (segment_name), has_separating_scope_resolution, locus), generic_args (GenericArgs (std::move (lifetime_args), @@ -868,11 +868,11 @@ private: // FIXME: think of better way to mark as invalid than taking up storage bool is_invalid; - Location locus; + location_t locus; protected: // Constructor only used to create invalid type path functions. - TypePathFunction (bool is_invalid, Location locus) + TypePathFunction (bool is_invalid, location_t locus) : is_invalid (is_invalid), locus (locus) {} @@ -893,8 +893,8 @@ public: } // Constructor - TypePathFunction (std::vector<std::unique_ptr<Type> > inputs, Location locus, - std::unique_ptr<Type> type = nullptr) + TypePathFunction (std::vector<std::unique_ptr<Type> > inputs, + location_t locus, std::unique_ptr<Type> type = nullptr) : inputs (std::move (inputs)), return_type (std::move (type)), is_invalid (false), locus (locus) {} @@ -966,7 +966,7 @@ public: // Constructor with PathIdentSegment and TypePathFn TypePathSegmentFunction (PathIdentSegment ident_segment, bool has_separating_scope_resolution, - TypePathFunction function_path, Location locus) + TypePathFunction function_path, location_t locus) : TypePathSegment (std::move (ident_segment), has_separating_scope_resolution, locus), function_path (std::move (function_path)) @@ -975,7 +975,7 @@ public: // Constructor with segment name and TypePathFn TypePathSegmentFunction (std::string segment_name, bool has_separating_scope_resolution, - TypePathFunction function_path, Location locus) + TypePathFunction function_path, location_t locus) : TypePathSegment (std::move (segment_name), has_separating_scope_resolution, locus), function_path (std::move (function_path)) @@ -1006,7 +1006,7 @@ class TypePath : public TypeNoBounds { bool has_opening_scope_resolution; std::vector<std::unique_ptr<TypePathSegment> > segments; - Location locus; + location_t locus; protected: /* Use covariance to implement clone function as returning this object @@ -1036,7 +1036,7 @@ public: // Constructor TypePath (std::vector<std::unique_ptr<TypePathSegment> > segments, - Location locus, bool has_opening_scope_resolution = false) + location_t locus, bool has_opening_scope_resolution = false) : TypeNoBounds (), has_opening_scope_resolution (has_opening_scope_resolution), segments (std::move (segments)), locus (locus) @@ -1102,13 +1102,13 @@ struct QualifiedPathType private: std::unique_ptr<Type> type_to_invoke_on; TypePath trait_path; - Location locus; + location_t locus; NodeId node_id; public: // Constructor QualifiedPathType (std::unique_ptr<Type> invoke_on_type, - Location locus = UNDEF_LOCATION, + location_t locus = UNDEF_LOCATION, TypePath trait_path = TypePath::create_error ()) : type_to_invoke_on (std::move (invoke_on_type)), trait_path (std::move (trait_path)), locus (locus), @@ -1187,7 +1187,7 @@ class QualifiedPathInExpression : public PathPattern, public PathExpr { std::vector<Attribute> outer_attrs; QualifiedPathType path_type; - Location locus; + location_t locus; NodeId _node_id; public: @@ -1195,7 +1195,8 @@ public: QualifiedPathInExpression (QualifiedPathType qual_path_type, std::vector<PathExprSegment> path_segments, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, + location_t locus) : PathPattern (std::move (path_segments)), outer_attrs (std::move (outer_attrs)), path_type (std::move (qual_path_type)), locus (locus), @@ -1275,7 +1276,7 @@ class QualifiedPathInType : public TypeNoBounds QualifiedPathType path_type; std::unique_ptr<TypePathSegment> associated_segment; std::vector<std::unique_ptr<TypePathSegment> > segments; - Location locus; + location_t locus; protected: /* Use covariance to implement clone function as returning this object @@ -1290,7 +1291,7 @@ public: QualifiedPathType qual_path_type, std::unique_ptr<TypePathSegment> associated_segment, std::vector<std::unique_ptr<TypePathSegment> > path_segments, - Location locus) + location_t locus) : path_type (std::move (qual_path_type)), associated_segment (std::move (associated_segment)), segments (std::move (path_segments)), locus (locus) diff --git a/gcc/rust/ast/rust-pattern.h b/gcc/rust/ast/rust-pattern.h index 0fd3c06..d35fbce 100644 --- a/gcc/rust/ast/rust-pattern.h +++ b/gcc/rust/ast/rust-pattern.h @@ -27,19 +27,19 @@ namespace AST { class LiteralPattern : public Pattern { Literal lit; - Location locus; + location_t locus; NodeId node_id; public: std::string as_string () const override; // Constructor for a literal pattern - LiteralPattern (Literal lit, Location locus) + LiteralPattern (Literal lit, location_t locus) : lit (std::move (lit)), locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ()) {} - LiteralPattern (std::string val, Literal::LitType type, Location locus, + LiteralPattern (std::string val, Literal::LitType type, location_t locus, PrimitiveCoreType type_hint) : lit (Literal (std::move (val), type, type_hint)), locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ()) @@ -75,7 +75,7 @@ class IdentifierPattern : public Pattern // bool has_pattern; std::unique_ptr<Pattern> to_bind; - Location locus; + location_t locus; NodeId node_id; public: @@ -85,7 +85,7 @@ public: bool has_pattern_to_bind () const { return to_bind != nullptr; } // Constructor - IdentifierPattern (Identifier ident, Location locus, bool is_ref = false, + IdentifierPattern (Identifier ident, location_t locus, bool is_ref = false, bool is_mut = false, std::unique_ptr<Pattern> to_bind = nullptr) : Pattern (), variable_ident (std::move (ident)), is_ref (is_ref), @@ -93,7 +93,7 @@ public: node_id (Analysis::Mappings::get ()->get_next_node_id ()) {} - IdentifierPattern (NodeId node_id, Identifier ident, Location locus, + IdentifierPattern (NodeId node_id, Identifier ident, location_t locus, bool is_ref = false, bool is_mut = false, std::unique_ptr<Pattern> to_bind = nullptr) : Pattern (), variable_ident (std::move (ident)), is_ref (is_ref), @@ -165,13 +165,13 @@ protected: // AST node for using the '_' wildcard "match any value" pattern class WildcardPattern : public Pattern { - Location locus; + location_t locus; NodeId node_id; public: std::string as_string () const override { return std::string (1, '_'); } - WildcardPattern (Location locus) + WildcardPattern (location_t locus) : locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ()) {} @@ -194,13 +194,13 @@ protected: class RestPattern : public Pattern { - Location locus; + location_t locus; NodeId node_id; public: std::string as_string () const override { return ".."; } - RestPattern (Location locus) + RestPattern (location_t locus) : locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ()) {} @@ -258,11 +258,11 @@ class RangePatternBoundLiteral : public RangePatternBound // Minus prefixed to literal (if integer or floating-point) bool has_minus; - Location locus; + location_t locus; public: // Constructor - RangePatternBoundLiteral (Literal literal, Location locus, + RangePatternBoundLiteral (Literal literal, location_t locus, bool has_minus = false) : literal (literal), has_minus (has_minus), locus (locus) {} @@ -373,7 +373,7 @@ class RangePattern : public Pattern /* location only stored to avoid a dereference - lower pattern should give * correct location so maybe change in future */ - Location locus; + location_t locus; NodeId node_id; public: @@ -381,7 +381,7 @@ public: // Constructor RangePattern (std::unique_ptr<RangePatternBound> lower, - std::unique_ptr<RangePatternBound> upper, Location locus, + std::unique_ptr<RangePatternBound> upper, location_t locus, bool has_ellipsis_syntax = false) : lower (std::move (lower)), upper (std::move (upper)), has_ellipsis_syntax (has_ellipsis_syntax), locus (locus), @@ -454,14 +454,14 @@ class ReferencePattern : public Pattern bool has_two_amps; bool is_mut; std::unique_ptr<Pattern> pattern; - Location locus; + location_t locus; NodeId node_id; public: std::string as_string () const override; ReferencePattern (std::unique_ptr<Pattern> pattern, bool is_mut_reference, - bool ref_has_two_amps, Location locus) + bool ref_has_two_amps, location_t locus) : has_two_amps (ref_has_two_amps), is_mut (is_mut_reference), pattern (std::move (pattern)), locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ()) @@ -544,7 +544,7 @@ public: class StructPatternField { std::vector<Attribute> outer_attrs; - Location locus; + location_t locus; protected: NodeId node_id; @@ -583,7 +583,7 @@ public: const std::vector<Attribute> &get_outer_attrs () const { return outer_attrs; } protected: - StructPatternField (std::vector<Attribute> outer_attribs, Location locus, + StructPatternField (std::vector<Attribute> outer_attribs, location_t locus, NodeId node_id) : outer_attrs (std::move (outer_attribs)), locus (locus), node_id (node_id) {} @@ -602,7 +602,7 @@ public: StructPatternFieldTuplePat (TupleIndex index, std::unique_ptr<Pattern> tuple_pattern, std::vector<Attribute> outer_attribs, - Location locus) + location_t locus) : StructPatternField (std::move (outer_attribs), locus, Analysis::Mappings::get ()->get_next_node_id ()), index (index), tuple_pattern (std::move (tuple_pattern)) @@ -682,7 +682,7 @@ public: StructPatternFieldIdentPat (Identifier ident, std::unique_ptr<Pattern> ident_pattern, std::vector<Attribute> outer_attrs, - Location locus) + location_t locus) : StructPatternField (std::move (outer_attrs), locus, Analysis::Mappings::get ()->get_next_node_id ()), ident (std::move (ident)), ident_pattern (std::move (ident_pattern)) @@ -761,7 +761,7 @@ class StructPatternFieldIdent : public StructPatternField public: StructPatternFieldIdent (Identifier ident, bool is_ref, bool is_mut, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : StructPatternField (std::move (outer_attrs), locus, Analysis::Mappings::get ()->get_next_node_id ()), has_ref (is_ref), has_mut (is_mut), ident (std::move (ident)) @@ -908,13 +908,13 @@ class StructPattern : public Pattern StructPatternElements elems; NodeId node_id; - Location locus; + location_t locus; public: std::string as_string () const override; // Constructs a struct pattern from specified StructPatternElements - StructPattern (PathInExpression struct_path, Location locus, + StructPattern (PathInExpression struct_path, location_t locus, StructPatternElements elems = StructPatternElements::create_empty ()) : path (std::move (struct_path)), elems (std::move (elems)), @@ -1379,7 +1379,7 @@ class TuplePattern : public Pattern { // bool has_tuple_pattern_items; std::unique_ptr<TuplePatternItems> items; - Location locus; + location_t locus; NodeId node_id; public: @@ -1388,7 +1388,7 @@ public: // Returns true if the tuple pattern has items bool has_tuple_pattern_items () const { return items != nullptr; } - TuplePattern (std::unique_ptr<TuplePatternItems> items, Location locus) + TuplePattern (std::unique_ptr<TuplePatternItems> items, location_t locus) : items (std::move (items)), locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ()) {} @@ -1445,7 +1445,7 @@ protected: class GroupedPattern : public Pattern { std::unique_ptr<Pattern> pattern_in_parens; - Location locus; + location_t locus; NodeId node_id; public: @@ -1454,7 +1454,7 @@ public: return "(" + pattern_in_parens->as_string () + ")"; } - GroupedPattern (std::unique_ptr<Pattern> pattern_in_parens, Location locus) + GroupedPattern (std::unique_ptr<Pattern> pattern_in_parens, location_t locus) : pattern_in_parens (std::move (pattern_in_parens)), locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ()) {} @@ -1507,13 +1507,13 @@ protected: class SlicePattern : public Pattern { std::vector<std::unique_ptr<Pattern>> items; - Location locus; + location_t locus; NodeId node_id; public: std::string as_string () const override; - SlicePattern (std::vector<std::unique_ptr<Pattern>> items, Location locus) + SlicePattern (std::vector<std::unique_ptr<Pattern>> items, location_t locus) : items (std::move (items)), locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ()) {} @@ -1574,13 +1574,13 @@ protected: class AltPattern : public Pattern { std::vector<std::unique_ptr<Pattern>> alts; - Location locus; + location_t locus; NodeId node_id; public: std::string as_string () const override; - AltPattern (std::vector<std::unique_ptr<Pattern>> alts, Location locus) + AltPattern (std::vector<std::unique_ptr<Pattern>> alts, location_t locus) : alts (std::move (alts)), locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ()) {} diff --git a/gcc/rust/ast/rust-stmt.h b/gcc/rust/ast/rust-stmt.h index 80395ab..e5b90b0 100644 --- a/gcc/rust/ast/rust-stmt.h +++ b/gcc/rust/ast/rust-stmt.h @@ -28,7 +28,7 @@ namespace AST { // Just a semi-colon, which apparently is a statement. class EmptyStmt : public Stmt { - Location locus; + location_t locus; // TODO: find another way to store this to save memory? bool marked_for_strip = false; @@ -36,7 +36,7 @@ class EmptyStmt : public Stmt public: std::string as_string () const override { return std::string (1, ';'); } - EmptyStmt (Location locus) : locus (locus) {} + EmptyStmt (location_t locus) : locus (locus) {} Location get_locus () const override final { return locus; } @@ -71,7 +71,7 @@ class LetStmt : public Stmt // bool has_init_expr; std::unique_ptr<Expr> init_expr; - Location locus; + location_t locus; public: Type *inferedType; @@ -89,7 +89,7 @@ public: LetStmt (std::unique_ptr<Pattern> variables_pattern, std::unique_ptr<Expr> init_expr, std::unique_ptr<Type> type, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : outer_attrs (std::move (outer_attrs)), variables_pattern (std::move (variables_pattern)), type (std::move (type)), init_expr (std::move (init_expr)), locus (locus) @@ -186,7 +186,7 @@ protected: class ExprStmt : public Stmt { std::unique_ptr<Expr> expr; - Location locus; + location_t locus; bool semicolon_followed; public: @@ -206,7 +206,7 @@ public: std::vector<LetStmt *> locals; - ExprStmt (std::unique_ptr<Expr> &&expr, Location locus, + ExprStmt (std::unique_ptr<Expr> &&expr, location_t locus, bool semicolon_followed) : expr (std::move (expr)), locus (locus), semicolon_followed (semicolon_followed) diff --git a/gcc/rust/ast/rust-type.h b/gcc/rust/ast/rust-type.h index d2a5f27..4902833 100644 --- a/gcc/rust/ast/rust-type.h +++ b/gcc/rust/ast/rust-type.h @@ -40,7 +40,7 @@ class TraitBound : public TypeParamBound TypePath type_path; - Location locus; + location_t locus; public: // Returns whether trait bound has "for" lifetimes @@ -48,7 +48,7 @@ public: std::vector<LifetimeParam> &get_for_lifetimes () { return for_lifetimes; } - TraitBound (TypePath type_path, Location locus, bool in_parens = false, + TraitBound (TypePath type_path, location_t locus, bool in_parens = false, bool opening_question_mark = false, std::vector<LifetimeParam> for_lifetimes = std::vector<LifetimeParam> ()) @@ -58,7 +58,7 @@ public: type_path (std::move (type_path)), locus (locus) {} - TraitBound (NodeId id, TypePath type_path, Location locus, + TraitBound (NodeId id, TypePath type_path, location_t locus, bool in_parens = false, bool opening_question_mark = false, std::vector<LifetimeParam> for_lifetimes = std::vector<LifetimeParam> ()) @@ -101,7 +101,7 @@ class ImplTraitType : public Type // inlined form std::vector<std::unique_ptr<TypeParamBound> > type_param_bounds; - Location locus; + location_t locus; protected: /* Use covariance to implement clone function as returning this object rather @@ -114,7 +114,7 @@ protected: public: ImplTraitType ( std::vector<std::unique_ptr<TypeParamBound> > type_param_bounds, - Location locus) + location_t locus) : type_param_bounds (std::move (type_param_bounds)), locus (locus) {} @@ -165,7 +165,7 @@ class TraitObjectType : public Type { bool has_dyn; std::vector<std::unique_ptr<TypeParamBound> > type_param_bounds; - Location locus; + location_t locus; protected: /* Use covariance to implement clone function as returning this object rather @@ -178,7 +178,7 @@ protected: public: TraitObjectType ( std::vector<std::unique_ptr<TypeParamBound> > type_param_bounds, - Location locus, bool is_dyn_dispatch) + location_t locus, bool is_dyn_dispatch) : has_dyn (is_dyn_dispatch), type_param_bounds (std::move (type_param_bounds)), locus (locus) {} @@ -232,7 +232,7 @@ public: class ParenthesisedType : public TypeNoBounds { std::unique_ptr<Type> type_in_parens; - Location locus; + location_t locus; protected: /* Use covariance to implement clone function as returning this object rather @@ -244,7 +244,7 @@ protected: public: // Constructor uses Type pointer for polymorphism - ParenthesisedType (std::unique_ptr<Type> type_inside_parens, Location locus) + ParenthesisedType (std::unique_ptr<Type> type_inside_parens, location_t locus) : type_in_parens (std::move (type_inside_parens)), locus (locus) {} @@ -296,7 +296,7 @@ public: class ImplTraitTypeOneBound : public TypeNoBounds { TraitBound trait_bound; - Location locus; + location_t locus; protected: /* Use covariance to implement clone function as returning this object rather @@ -307,7 +307,7 @@ protected: } public: - ImplTraitTypeOneBound (TraitBound trait_bound, Location locus) + ImplTraitTypeOneBound (TraitBound trait_bound, location_t locus) : trait_bound (std::move (trait_bound)), locus (locus) {} @@ -331,7 +331,7 @@ class TraitObjectTypeOneBound : public TypeNoBounds { bool has_dyn; TraitBound trait_bound; - Location locus; + location_t locus; protected: /* Use covariance to implement clone function as returning this object rather @@ -342,7 +342,7 @@ protected: } public: - TraitObjectTypeOneBound (TraitBound trait_bound, Location locus, + TraitObjectTypeOneBound (TraitBound trait_bound, location_t locus, bool is_dyn_dispatch = false) : has_dyn (is_dyn_dispatch), trait_bound (std::move (trait_bound)), locus (locus) @@ -379,13 +379,13 @@ class TypePath; // definition moved to "rust-path.h" class TupleType : public TypeNoBounds { std::vector<std::unique_ptr<Type> > elems; - Location locus; + location_t locus; public: // Returns whether the tuple type is the unit type, i.e. has no elements. bool is_unit_type () const { return elems.empty (); } - TupleType (std::vector<std::unique_ptr<Type> > elems, Location locus) + TupleType (std::vector<std::unique_ptr<Type> > elems, location_t locus) : elems (std::move (elems)), locus (locus) {} @@ -440,7 +440,7 @@ protected: * Represented as "!". */ class NeverType : public TypeNoBounds { - Location locus; + location_t locus; protected: /* Use covariance to implement clone function as returning this object rather @@ -451,7 +451,7 @@ protected: } public: - NeverType (Location locus) : locus (locus) {} + NeverType (location_t locus) : locus (locus) {} std::string as_string () const override { return "! (never type)"; } @@ -473,7 +473,7 @@ public: private: PointerType pointer_type; std::unique_ptr<TypeNoBounds> type; - Location locus; + location_t locus; public: // Returns whether the pointer is mutable or constant. @@ -481,7 +481,8 @@ public: // Constructor requires pointer for polymorphism reasons RawPointerType (PointerType pointer_type, - std::unique_ptr<TypeNoBounds> type_no_bounds, Location locus) + std::unique_ptr<TypeNoBounds> type_no_bounds, + location_t locus) : pointer_type (pointer_type), type (std::move (type_no_bounds)), locus (locus) {} @@ -535,7 +536,7 @@ class ReferenceType : public TypeNoBounds bool has_mut; std::unique_ptr<TypeNoBounds> type; - Location locus; + location_t locus; public: // Returns whether the reference is mutable or immutable. @@ -546,7 +547,7 @@ public: // Constructor ReferenceType (bool is_mut, std::unique_ptr<TypeNoBounds> type_no_bounds, - Location locus, Lifetime lifetime = Lifetime::error ()) + location_t locus, Lifetime lifetime = Lifetime::error ()) : lifetime (std::move (lifetime)), has_mut (is_mut), type (std::move (type_no_bounds)), locus (locus) {} @@ -605,12 +606,12 @@ class ArrayType : public TypeNoBounds { std::unique_ptr<Type> elem_type; std::unique_ptr<Expr> size; - Location locus; + location_t locus; public: // Constructor requires pointers for polymorphism ArrayType (std::unique_ptr<Type> type, std::unique_ptr<Expr> array_size, - Location locus) + location_t locus) : elem_type (std::move (type)), size (std::move (array_size)), locus (locus) {} @@ -667,11 +668,11 @@ protected: class SliceType : public TypeNoBounds { std::unique_ptr<Type> elem_type; - Location locus; + location_t locus; public: // Constructor requires pointer for polymorphism - SliceType (std::unique_ptr<Type> type, Location locus) + SliceType (std::unique_ptr<Type> type, location_t locus) : elem_type (std::move (type)), locus (locus) {} @@ -719,7 +720,7 @@ protected: * pattern) */ class InferredType : public TypeNoBounds { - Location locus; + location_t locus; // e.g. Vec<_> = whatever protected: @@ -731,7 +732,7 @@ protected: } public: - InferredType (Location locus) : locus (locus) {} + InferredType (location_t locus) : locus (locus) {} std::string as_string () const override; @@ -761,12 +762,12 @@ private: ParamKind param_kind; Identifier name; // technically, can be an identifier or '_' - Location locus; + location_t locus; public: MaybeNamedParam (Identifier name, ParamKind param_kind, std::unique_ptr<Type> param_type, - std::vector<Attribute> outer_attrs, Location locus) + std::vector<Attribute> outer_attrs, location_t locus) : outer_attrs (std::move (outer_attrs)), param_type (std::move (param_type)), param_kind (param_kind), name (std::move (name)), locus (locus) @@ -851,7 +852,7 @@ class BareFunctionType : public TypeNoBounds // BareFunctionReturnType return_type; std::unique_ptr<TypeNoBounds> return_type; // inlined version - Location locus; + location_t locus; public: // Whether a return type is defined with the function. @@ -874,7 +875,7 @@ public: FunctionQualifiers qualifiers, std::vector<MaybeNamedParam> named_params, bool is_variadic, std::vector<Attribute> variadic_attrs, - std::unique_ptr<TypeNoBounds> type, Location locus) + std::unique_ptr<TypeNoBounds> type, location_t locus) : for_lifetimes (std::move (lifetime_params)), function_qualifiers (std::move (qualifiers)), params (std::move (named_params)), _is_variadic (is_variadic), diff --git a/gcc/rust/backend/rust-compile-base.cc b/gcc/rust/backend/rust-compile-base.cc index 522487e..f20df32 100644 --- a/gcc/rust/backend/rust-compile-base.cc +++ b/gcc/rust/backend/rust-compile-base.cc @@ -358,7 +358,7 @@ HIRCompileBase::setup_abi_options (tree fndecl, ABI abi) // it is fine to use ARRAY_REFs for vector subscripts on vector // register variables. bool -HIRCompileBase::mark_addressable (tree exp, Location locus) +HIRCompileBase::mark_addressable (tree exp, location_t locus) { tree x = exp; @@ -429,7 +429,7 @@ HIRCompileBase::address_expression (tree expr, Location location) } tree -HIRCompileBase::indirect_expression (tree expr, Location locus) +HIRCompileBase::indirect_expression (tree expr, location_t locus) { if (expr == error_mark_node) return error_mark_node; @@ -483,7 +483,7 @@ HIRCompileBase::compile_function_body (tree fndecl, if (function_body.has_expr ()) { - Location locus = function_body.get_final_expr ()->get_locus (); + location_t locus = function_body.get_final_expr ()->get_locus (); tree return_value = CompileExpr::Compile (function_body.expr.get (), ctx); // we can only return this if non unit value return type @@ -523,7 +523,7 @@ HIRCompileBase::compile_function_body (tree fndecl, { // we can only do this if the function is of unit type otherwise other // errors should have occurred - Location locus = function_body.get_locus (); + location_t locus = function_body.get_locus (); tree return_value = unit_expression (ctx, locus); tree return_stmt = ctx->get_backend ()->return_statement (fndecl, return_value, locus); @@ -536,7 +536,7 @@ HIRCompileBase::compile_function ( const std::string &fn_name, HIR::SelfParam &self_param, std::vector<HIR::FunctionParam> &function_params, const HIR::FunctionQualifiers &qualifiers, HIR::Visibility &visibility, - AST::AttrVec &outer_attrs, Location locus, HIR::BlockExpr *function_body, + AST::AttrVec &outer_attrs, location_t locus, HIR::BlockExpr *function_body, const Resolver::CanonicalPath *canonical_path, TyTy::FnType *fntype) { tree compiled_fn_type = TyTyResolveCompile::compile (ctx, fntype); @@ -660,7 +660,7 @@ HIRCompileBase::compile_function ( tree HIRCompileBase::compile_constant_item ( TyTy::BaseType *resolved_type, const Resolver::CanonicalPath *canonical_path, - HIR::Expr *const_value_expr, Location locus) + HIR::Expr *const_value_expr, location_t locus) { const std::string &ident = canonical_path->get (); @@ -885,7 +885,7 @@ HIRCompileBase::resolve_method_address (TyTy::FnType *fntype, } tree -HIRCompileBase::unit_expression (Context *ctx, Location locus) +HIRCompileBase::unit_expression (Context *ctx, location_t locus) { tree unit_type = TyTyResolveCompile::get_unit_type (ctx); return ctx->get_backend ()->constructor_expression (unit_type, false, {}, -1, diff --git a/gcc/rust/backend/rust-compile-base.h b/gcc/rust/backend/rust-compile-base.h index 203705a..fa1375b 100644 --- a/gcc/rust/backend/rust-compile-base.h +++ b/gcc/rust/backend/rust-compile-base.h @@ -45,14 +45,16 @@ protected: Location rvalue_locus); tree coerce_to_dyn_object (tree compiled_ref, const TyTy::BaseType *actual, - const TyTy::DynamicObjectType *ty, Location locus); + const TyTy::DynamicObjectType *ty, + location_t locus); tree compute_address_for_trait_item ( const Resolver::TraitItemReference *ref, const TyTy::TypeBoundPredicate *predicate, std::vector<std::pair<Resolver::TraitReference *, HIR::ImplBlock *>> &receiver_bounds, - const TyTy::BaseType *receiver, const TyTy::BaseType *root, Location locus); + const TyTy::BaseType *receiver, const TyTy::BaseType *root, + location_t locus); bool verify_array_capacities (tree ltype, tree rtype, Location ltype_locus, Location rtype_locus); @@ -63,22 +65,22 @@ protected: Location expr_locus, bool is_qualified_path); tree resolve_adjustements (std::vector<Resolver::Adjustment> &adjustments, - tree expression, Location locus); + tree expression, location_t locus); tree resolve_deref_adjustment (Resolver::Adjustment &adjustment, - tree expression, Location locus); + tree expression, location_t locus); tree resolve_indirection_adjustment (Resolver::Adjustment &adjustment, - tree expression, Location locus); + tree expression, location_t locus); tree resolve_unsized_adjustment (Resolver::Adjustment &adjustment, - tree expression, Location locus); + tree expression, location_t locus); tree resolve_unsized_slice_adjustment (Resolver::Adjustment &adjustment, - tree expression, Location locus); + tree expression, location_t locus); tree resolve_unsized_dyn_adjustment (Resolver::Adjustment &adjustment, - tree expression, Location locus); + tree expression, location_t locus); tree resolve_method_address (TyTy::FnType *fntype, TyTy::BaseType *receiver, Location expr_locus); @@ -88,17 +90,17 @@ protected: tree compile_constant_item (TyTy::BaseType *resolved_type, const Resolver::CanonicalPath *canonical_path, - HIR::Expr *const_value_expr, Location locus); + HIR::Expr *const_value_expr, location_t locus); tree compile_function (const std::string &fn_name, HIR::SelfParam &self_param, std::vector<HIR::FunctionParam> &function_params, const HIR::FunctionQualifiers &qualifiers, HIR::Visibility &visibility, AST::AttrVec &outer_attrs, - Location locus, HIR::BlockExpr *function_body, + location_t locus, HIR::BlockExpr *function_body, const Resolver::CanonicalPath *canonical_path, TyTy::FnType *fntype); - static tree unit_expression (Context *ctx, Location locus); + static tree unit_expression (Context *ctx, location_t locus); static void setup_fndecl (tree fndecl, bool is_main_entry_point, bool is_generic_fn, HIR::Visibility &visibility, @@ -126,9 +128,9 @@ protected: static void setup_abi_options (tree fndecl, ABI abi); - static tree address_expression (tree expr, Location locus); + static tree address_expression (tree expr, location_t locus); - static tree indirect_expression (tree expr, Location locus); + static tree indirect_expression (tree expr, location_t locus); static bool mark_addressable (tree, Location); diff --git a/gcc/rust/backend/rust-compile-block.cc b/gcc/rust/backend/rust-compile-block.cc index d6a106e..71d9cde 100644 --- a/gcc/rust/backend/rust-compile-block.cc +++ b/gcc/rust/backend/rust-compile-block.cc @@ -74,7 +74,7 @@ CompileBlock::visit (HIR::BlockExpr &expr) tree compiled_expr = CompileExpr::Compile (expr.expr.get (), ctx); if (result != nullptr) { - Location locus = expr.get_final_expr ()->get_locus (); + location_t locus = expr.get_final_expr ()->get_locus (); tree result_reference = ctx->get_backend ()->var_expression (result, locus); @@ -87,7 +87,7 @@ CompileBlock::visit (HIR::BlockExpr &expr) } else if (result != nullptr) { - Location locus = expr.get_locus (); + location_t locus = expr.get_locus (); tree compiled_expr = unit_expression (ctx, expr.get_locus ()); tree result_reference = ctx->get_backend ()->var_expression (result, locus); diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 80cc608..c055580 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -2301,7 +2301,7 @@ CompileExpr::array_copied_expr (Location expr_locus, tree HIRCompileBase::resolve_adjustements ( std::vector<Resolver::Adjustment> &adjustments, tree expression, - Location locus) + location_t locus) { tree e = expression; for (auto &adjustment : adjustments) @@ -2340,7 +2340,7 @@ HIRCompileBase::resolve_adjustements ( tree HIRCompileBase::resolve_deref_adjustment (Resolver::Adjustment &adjustment, - tree expression, Location locus) + tree expression, location_t locus) { rust_assert (adjustment.is_deref_adjustment () || adjustment.is_deref_mut_adjustment ()); @@ -2366,14 +2366,14 @@ HIRCompileBase::resolve_deref_adjustment (Resolver::Adjustment &adjustment, tree HIRCompileBase::resolve_indirection_adjustment ( - Resolver::Adjustment &adjustment, tree expression, Location locus) + Resolver::Adjustment &adjustment, tree expression, location_t locus) { return indirect_expression (expression, locus); } tree HIRCompileBase::resolve_unsized_adjustment (Resolver::Adjustment &adjustment, - tree expression, Location locus) + tree expression, location_t locus) { bool expect_slice = adjustment.get_expected ()->get_kind () == TyTy::TypeKind::SLICE; @@ -2394,7 +2394,7 @@ HIRCompileBase::resolve_unsized_adjustment (Resolver::Adjustment &adjustment, tree HIRCompileBase::resolve_unsized_slice_adjustment ( - Resolver::Adjustment &adjustment, tree expression, Location locus) + Resolver::Adjustment &adjustment, tree expression, location_t locus) { // assumes this is an array tree expr_type = TREE_TYPE (expression); @@ -2426,7 +2426,7 @@ HIRCompileBase::resolve_unsized_slice_adjustment ( tree HIRCompileBase::resolve_unsized_dyn_adjustment ( - Resolver::Adjustment &adjustment, tree expression, Location locus) + Resolver::Adjustment &adjustment, tree expression, location_t locus) { tree rvalue = expression; Location rvalue_locus = locus; diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h index 95c0052..e596d17 100644 --- a/gcc/rust/backend/rust-compile-expr.h +++ b/gcc/rust/backend/rust-compile-expr.h @@ -124,7 +124,7 @@ protected: tree compile_byte_string_literal (const HIR::LiteralExpr &expr, const TyTy::BaseType *tyty); - tree type_cast_expression (tree type_to_cast_to, tree expr, Location locus); + tree type_cast_expression (tree type_to_cast_to, tree expr, location_t locus); tree array_value_expr (Location expr_locus, const TyTy::ArrayType &array_tyty, tree array_type, HIR::ArrayElemsValues &elems); diff --git a/gcc/rust/backend/rust-compile-fnparam.cc b/gcc/rust/backend/rust-compile-fnparam.cc index 9a9d5b3..1072ae0 100644 --- a/gcc/rust/backend/rust-compile-fnparam.cc +++ b/gcc/rust/backend/rust-compile-fnparam.cc @@ -25,14 +25,14 @@ namespace Rust { namespace Compile { CompileFnParam::CompileFnParam (Context *ctx, tree fndecl, tree decl_type, - Location locus) + location_t locus) : HIRCompileBase (ctx), fndecl (fndecl), decl_type (decl_type), locus (locus), compiled_param (ctx->get_backend ()->error_variable ()) {} Bvariable * CompileFnParam::compile (Context *ctx, tree fndecl, HIR::FunctionParam *param, - tree decl_type, Location locus) + tree decl_type, location_t locus) { CompileFnParam compiler (ctx, fndecl, decl_type, locus); param->get_param_name ()->accept_vis (compiler); @@ -41,7 +41,7 @@ CompileFnParam::compile (Context *ctx, tree fndecl, HIR::FunctionParam *param, Bvariable * CompileFnParam::compile (Context *ctx, tree fndecl, HIR::Pattern *param, - tree decl_type, Location locus) + tree decl_type, location_t locus) { CompileFnParam compiler (ctx, fndecl, decl_type, locus); param->accept_vis (compiler); @@ -90,7 +90,7 @@ CompileFnParam::visit (HIR::ReferencePattern &pattern) Bvariable * CompileSelfParam::compile (Context *ctx, tree fndecl, HIR::SelfParam &self, - tree decl_type, Location locus) + tree decl_type, location_t locus) { bool is_immutable = self.get_self_kind () == HIR::SelfParam::ImplicitSelfKind::IMM diff --git a/gcc/rust/backend/rust-compile-fnparam.h b/gcc/rust/backend/rust-compile-fnparam.h index 10b4efb..9b50b19 100644 --- a/gcc/rust/backend/rust-compile-fnparam.h +++ b/gcc/rust/backend/rust-compile-fnparam.h @@ -30,9 +30,9 @@ class CompileFnParam : private HIRCompileBase, protected HIR::HIRPatternVisitor public: static Bvariable *compile (Context *ctx, tree fndecl, HIR::FunctionParam *param, tree decl_type, - Location locus); + location_t locus); static Bvariable *compile (Context *ctx, tree fndecl, HIR::Pattern *param, - tree decl_type, Location locus); + tree decl_type, location_t locus); void visit (HIR::IdentifierPattern &pattern) override; void visit (HIR::WildcardPattern &pattern) override; @@ -50,13 +50,13 @@ public: void visit (HIR::TuplePattern &) override {} private: - CompileFnParam (Context *ctx, tree fndecl, tree decl_type, Location locus); + CompileFnParam (Context *ctx, tree fndecl, tree decl_type, location_t locus); tree create_tmp_param_var (tree decl_type); tree fndecl; tree decl_type; - Location locus; + location_t locus; Bvariable *compiled_param; }; @@ -64,7 +64,7 @@ class CompileSelfParam : private HIRCompileBase { public: static Bvariable *compile (Context *ctx, tree fndecl, HIR::SelfParam &self, - tree decl_type, Location locus); + tree decl_type, location_t locus); }; } // namespace Compile diff --git a/gcc/rust/backend/rust-compile-intrinsic.cc b/gcc/rust/backend/rust-compile-intrinsic.cc index 0521d85..4f680e7 100644 --- a/gcc/rust/backend/rust-compile-intrinsic.cc +++ b/gcc/rust/backend/rust-compile-intrinsic.cc @@ -52,8 +52,8 @@ is_basic_integer_type (TyTy::BaseType *type) } static bool -check_for_basic_integer_type (const std::string &intrinsic_str, Location locus, - TyTy::BaseType *type) +check_for_basic_integer_type (const std::string &intrinsic_str, + location_t locus, TyTy::BaseType *type) { auto is_basic_integer = is_basic_integer_type (type); if (!is_basic_integer) @@ -227,7 +227,7 @@ Intrinsics::compile (TyTy::FnType *fntype) if (it != generic_intrinsics.end ()) return it->second (ctx, fntype); - Location locus = ctx->get_mappings ()->lookup_location (fntype->get_ref ()); + location_t locus = ctx->get_mappings ()->lookup_location (fntype->get_ref ()); rust_error_at (locus, ErrorCode ("E0093"), "unrecognized intrinsic function: %<%s%>", fntype->get_identifier ().c_str ()); @@ -791,7 +791,7 @@ prefetch_data_handler (Context *ctx, TyTy::FnType *fntype, Prefetch kind) } static std::string -build_atomic_builtin_name (const std::string &prefix, Location locus, +build_atomic_builtin_name (const std::string &prefix, location_t locus, TyTy::BaseType *operand_type) { static const std::map<std::string, std::string> allowed_types = { diff --git a/gcc/rust/backend/rust-compile-pattern.cc b/gcc/rust/backend/rust-compile-pattern.cc index c655690..54bfda1 100644 --- a/gcc/rust/backend/rust-compile-pattern.cc +++ b/gcc/rust/backend/rust-compile-pattern.cc @@ -106,7 +106,7 @@ CompilePatternCaseLabelExpr::visit (HIR::LiteralPattern &pattern) static tree compile_range_pattern_bound (HIR::RangePatternBound *bound, - Analysis::NodeMapping mappings, Location locus, + Analysis::NodeMapping mappings, location_t locus, Context *ctx) { tree result = NULL_TREE; diff --git a/gcc/rust/backend/rust-compile-resolve-path.h b/gcc/rust/backend/rust-compile-resolve-path.h index 05c882e..ce559fc 100644 --- a/gcc/rust/backend/rust-compile-resolve-path.h +++ b/gcc/rust/backend/rust-compile-resolve-path.h @@ -62,7 +62,7 @@ public: {} tree resolve (const HIR::PathIdentSegment &final_segment, - const Analysis::NodeMapping &mappings, Location locus, + const Analysis::NodeMapping &mappings, location_t locus, bool is_qualified_path); tree resolved; diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc index b4c46e9..f406220 100644 --- a/gcc/rust/backend/rust-compile.cc +++ b/gcc/rust/backend/rust-compile.cc @@ -181,7 +181,7 @@ tree HIRCompileBase::coerce_to_dyn_object (tree compiled_ref, const TyTy::BaseType *actual, const TyTy::DynamicObjectType *ty, - Location locus) + location_t locus) { // DST's get wrapped in a pseudo reference that doesnt exist... const TyTy::ReferenceType r (ctx->get_mappings ()->get_next_hir_id (), @@ -232,7 +232,7 @@ HIRCompileBase::compute_address_for_trait_item ( const TyTy::TypeBoundPredicate *predicate, std::vector<std::pair<Resolver::TraitReference *, HIR::ImplBlock *>> &receiver_bounds, - const TyTy::BaseType *receiver, const TyTy::BaseType *root, Location locus) + const TyTy::BaseType *receiver, const TyTy::BaseType *root, location_t locus) { // There are two cases here one where its an item which has an implementation // within a trait-impl-block. Then there is the case where there is a default diff --git a/gcc/rust/checks/errors/rust-const-checker.cc b/gcc/rust/checks/errors/rust-const-checker.cc index a5b6f30..510b42d 100644 --- a/gcc/rust/checks/errors/rust-const-checker.cc +++ b/gcc/rust/checks/errors/rust-const-checker.cc @@ -301,7 +301,7 @@ ConstChecker::visit (StructExprStructBase &) {} void -ConstChecker::check_function_call (HirId fn_id, Location locus) +ConstChecker::check_function_call (HirId fn_id, location_t locus) { if (!const_context.is_in_context ()) return; diff --git a/gcc/rust/checks/errors/rust-const-checker.h b/gcc/rust/checks/errors/rust-const-checker.h index 8294f01..c199cb3 100644 --- a/gcc/rust/checks/errors/rust-const-checker.h +++ b/gcc/rust/checks/errors/rust-const-checker.h @@ -44,7 +44,7 @@ private: /** * Check that only const functions are called in const contexts */ - void check_function_call (HirId fn_id, Location locus); + void check_function_call (HirId fn_id, location_t locus); /* All possible const contexts */ enum class ConstGenericCtx diff --git a/gcc/rust/checks/errors/rust-unsafe-checker.cc b/gcc/rust/checks/errors/rust-unsafe-checker.cc index 5b259f7..4ac9e59 100644 --- a/gcc/rust/checks/errors/rust-unsafe-checker.cc +++ b/gcc/rust/checks/errors/rust-unsafe-checker.cc @@ -39,7 +39,7 @@ UnsafeChecker::go (HIR::Crate &crate) } static void -check_static_mut (HIR::Item *maybe_static, Location locus) +check_static_mut (HIR::Item *maybe_static, location_t locus) { if (maybe_static->get_hir_kind () == Node::BaseKind::VIS_ITEM) { @@ -55,7 +55,7 @@ check_static_mut (HIR::Item *maybe_static, Location locus) } static void -check_extern_static (HIR::ExternalItem *maybe_static, Location locus) +check_extern_static (HIR::ExternalItem *maybe_static, location_t locus) { if (maybe_static->get_extern_kind () == ExternalItem::ExternKind::Static) rust_error_at (locus, @@ -63,7 +63,7 @@ check_extern_static (HIR::ExternalItem *maybe_static, Location locus) } void -UnsafeChecker::check_use_of_static (HirId node_id, Location locus) +UnsafeChecker::check_use_of_static (HirId node_id, location_t locus) { if (unsafe_context.is_in_context ()) return; @@ -83,7 +83,7 @@ UnsafeChecker::check_use_of_static (HirId node_id, Location locus) } static void -check_unsafe_call (HIR::Function *fn, Location locus, const std::string &kind) +check_unsafe_call (HIR::Function *fn, location_t locus, const std::string &kind) { if (fn->get_qualifiers ().is_unsafe ()) rust_error_at (locus, ErrorCode ("E0133"), @@ -137,7 +137,7 @@ is_safe_intrinsic (const std::string &fn_name) static void check_extern_call (HIR::ExternalItem *maybe_fn, HIR::ExternBlock *parent_block, - Location locus) + location_t locus) { // We have multiple operations to perform here // 1. Is the item an actual function we're calling @@ -161,7 +161,7 @@ check_extern_call (HIR::ExternalItem *maybe_fn, HIR::ExternBlock *parent_block, } void -UnsafeChecker::check_function_call (HirId node_id, Location locus) +UnsafeChecker::check_function_call (HirId node_id, location_t locus) { if (unsafe_context.is_in_context ()) return; @@ -181,7 +181,7 @@ UnsafeChecker::check_function_call (HirId node_id, Location locus) } static void -check_target_attr (HIR::Function *fn, Location locus) +check_target_attr (HIR::Function *fn, location_t locus) { if (std::any_of (fn->get_outer_attrs ().begin (), fn->get_outer_attrs ().end (), @@ -194,7 +194,7 @@ check_target_attr (HIR::Function *fn, Location locus) } void -UnsafeChecker::check_function_attr (HirId node_id, Location locus) +UnsafeChecker::check_function_attr (HirId node_id, location_t locus) { if (unsafe_context.is_in_context ()) return; diff --git a/gcc/rust/checks/errors/rust-unsafe-checker.h b/gcc/rust/checks/errors/rust-unsafe-checker.h index 4399581..2d5b484 100644 --- a/gcc/rust/checks/errors/rust-unsafe-checker.h +++ b/gcc/rust/checks/errors/rust-unsafe-checker.h @@ -38,18 +38,18 @@ private: * Check if a mutable static or external static item is used outside of an * unsafe context */ - void check_use_of_static (HirId node_id, Location locus); + void check_use_of_static (HirId node_id, location_t locus); /** * Check if a call to an unsafe or external function is outside of an unsafe * context */ - void check_function_call (HirId node_id, Location locus); + void check_function_call (HirId node_id, location_t locus); /** * Check if any unsafe attributes are present on a function */ - void check_function_attr (HirId node_id, Location locus); + void check_function_attr (HirId node_id, location_t locus); StackedContexts<HirId> unsafe_context; diff --git a/gcc/rust/expand/rust-macro-builtins.cc b/gcc/rust/expand/rust-macro-builtins.cc index 7fe023a..82bb8d8 100644 --- a/gcc/rust/expand/rust-macro-builtins.cc +++ b/gcc/rust/expand/rust-macro-builtins.cc @@ -167,7 +167,7 @@ make_token (const TokenPtr tok) } std::unique_ptr<AST::Expr> -make_string (Location locus, std::string value) +make_string (location_t locus, std::string value) { return std::unique_ptr<AST::Expr> ( new AST::LiteralExpr (value, AST::Literal::STRING, @@ -177,7 +177,7 @@ make_string (Location locus, std::string value) // TODO: Is this correct? static AST::Fragment make_eager_builtin_invocation ( - BuiltinMacro kind, Location locus, AST::DelimTokenTree arguments, + BuiltinMacro kind, location_t locus, AST::DelimTokenTree arguments, std::vector<std::unique_ptr<AST::MacroInvocation>> &&pending_invocations) { auto path_str = make_macro_path_str (kind); @@ -352,7 +352,7 @@ parse_single_string_literal (BuiltinMacro kind, compiled, and return the absolute path for it. */ std::string -source_relative_path (std::string path, Location locus) +source_relative_path (std::string path, location_t locus) { std::string compile_fname = LOCATION_FILE (locus); diff --git a/gcc/rust/expand/rust-macro-expand.h b/gcc/rust/expand/rust-macro-expand.h index 781d201..30d2970 100644 --- a/gcc/rust/expand/rust-macro-expand.h +++ b/gcc/rust/expand/rust-macro-expand.h @@ -319,7 +319,7 @@ struct MacroExpander void expand_invoc (AST::MacroInvocation &invoc, bool has_semicolon); // Expands a single declarative macro. - AST::Fragment expand_decl_macro (Location locus, AST::MacroInvocData &invoc, + AST::Fragment expand_decl_macro (location_t locus, AST::MacroInvocData &invoc, AST::MacroRulesDefinition &rules_def, bool semicolon); diff --git a/gcc/rust/hir/rust-ast-lower-base.h b/gcc/rust/hir/rust-ast-lower-base.h index 7ed9cef..4fb2f97 100644 --- a/gcc/rust/hir/rust-ast-lower-base.h +++ b/gcc/rust/hir/rust-ast-lower-base.h @@ -49,7 +49,7 @@ public: private: const Analysis::NodeMapping &mappings; - Location locus; + location_t locus; const AST::AttrVec &outer_attrs; }; diff --git a/gcc/rust/hir/rust-ast-lower-implitem.h b/gcc/rust/hir/rust-ast-lower-implitem.h index 53cb8ea..9aef2cb 100644 --- a/gcc/rust/hir/rust-ast-lower-implitem.h +++ b/gcc/rust/hir/rust-ast-lower-implitem.h @@ -153,7 +153,7 @@ public: generic_params = lower_generic_params (function.get_generic_params ()); } Identifier function_name = function.get_function_name (); - Location locus = function.get_locus (); + location_t locus = function.get_locus (); std::unique_ptr<HIR::Type> return_type = function.has_return_type () ? std::unique_ptr<HIR::Type> ( @@ -237,7 +237,7 @@ public: generic_params = lower_generic_params (method.get_generic_params ()); } Identifier method_name = method.get_method_name (); - Location locus = method.get_locus (); + location_t locus = method.get_locus (); HIR::SelfParam self_param = lower_self (method.get_self_param ()); diff --git a/gcc/rust/hir/rust-ast-lower-item.cc b/gcc/rust/hir/rust-ast-lower-item.cc index c906964..93659c2 100644 --- a/gcc/rust/hir/rust-ast-lower-item.cc +++ b/gcc/rust/hir/rust-ast-lower-item.cc @@ -412,7 +412,7 @@ ASTLoweringItem::visit (AST::Function &function) generic_params = lower_generic_params (function.get_generic_params ()); } Identifier function_name = function.get_function_name (); - Location locus = function.get_locus (); + location_t locus = function.get_locus (); std::unique_ptr<HIR::Type> return_type = function.has_return_type () ? std::unique_ptr<HIR::Type> ( diff --git a/gcc/rust/hir/tree/rust-hir-expr.h b/gcc/rust/hir/tree/rust-hir-expr.h index 46d7a80..f4f08d5 100644 --- a/gcc/rust/hir/tree/rust-hir-expr.h +++ b/gcc/rust/hir/tree/rust-hir-expr.h @@ -64,7 +64,7 @@ public: class LiteralExpr : public ExprWithoutBlock { Literal literal; - Location locus; + location_t locus; public: std::string as_string () const override @@ -77,13 +77,13 @@ public: LiteralExpr (Analysis::NodeMapping mappings, std::string value_as_string, Literal::LitType type, PrimitiveCoreType type_hint, - Location locus, AST::AttrVec outer_attrs) + location_t locus, AST::AttrVec outer_attrs) : ExprWithoutBlock (std::move (mappings), std::move (outer_attrs)), literal (std::move (value_as_string), type, type_hint), locus (locus) {} - LiteralExpr (Analysis::NodeMapping mappings, Literal literal, Location locus, - AST::AttrVec outer_attrs) + LiteralExpr (Analysis::NodeMapping mappings, Literal literal, + location_t locus, AST::AttrVec outer_attrs) : ExprWithoutBlock (std::move (mappings), std::move (outer_attrs)), literal (std::move (literal)), locus (locus) {} @@ -133,7 +133,7 @@ class OperatorExpr : public ExprWithoutBlock { // TODO: create binary and unary operator subclasses? public: - Location locus; + location_t locus; protected: /* Variable must be protected to allow derived classes to use it as a first @@ -143,7 +143,7 @@ protected: // Constructor (only for initialisation of expr purposes) OperatorExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> main_or_left_expr, - AST::AttrVec outer_attribs, Location locus) + AST::AttrVec outer_attribs, location_t locus) : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)), locus (locus), main_or_left_expr (std::move (main_or_left_expr)) {} @@ -192,7 +192,7 @@ public: BorrowExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> borrow_lvalue, Mutability mut, - AST::AttrVec outer_attribs, Location locus) + AST::AttrVec outer_attribs, location_t locus) : OperatorExpr (std::move (mappings), std::move (borrow_lvalue), std::move (outer_attribs), locus), mut (mut) @@ -231,7 +231,7 @@ public: // Constructor calls OperatorExpr's protected constructor DereferenceExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> deref_lvalue, - AST::AttrVec outer_attribs, Location locus) + AST::AttrVec outer_attribs, location_t locus) : OperatorExpr (std::move (mappings), std::move (deref_lvalue), std::move (outer_attribs), locus) {} @@ -264,7 +264,7 @@ public: // Constructor calls OperatorExpr's protected constructor ErrorPropagationExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> potential_error_value, - AST::AttrVec outer_attribs, Location locus) + AST::AttrVec outer_attribs, location_t locus) : OperatorExpr (std::move (mappings), std::move (potential_error_value), std::move (outer_attribs), locus) {} @@ -308,7 +308,7 @@ public: // Constructor calls OperatorExpr's protected constructor NegationExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> negated_value, ExprType expr_kind, - AST::AttrVec outer_attribs, Location locus) + AST::AttrVec outer_attribs, location_t locus) : OperatorExpr (std::move (mappings), std::move (negated_value), std::move (outer_attribs), locus), expr_type (expr_kind) @@ -354,7 +354,7 @@ public: ArithmeticOrLogicalExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> left_value, std::unique_ptr<Expr> right_value, - ExprType expr_kind, Location locus) + ExprType expr_kind, location_t locus) : OperatorExpr (std::move (mappings), std::move (left_value), AST::AttrVec (), locus), expr_type (expr_kind), right_expr (std::move (right_value)) @@ -429,7 +429,7 @@ public: ComparisonExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> left_value, std::unique_ptr<Expr> right_value, ExprType comparison_kind, - Location locus) + location_t locus) : OperatorExpr (std::move (mappings), std::move (left_value), AST::AttrVec (), locus), expr_type (comparison_kind), right_expr (std::move (right_value)) @@ -500,7 +500,7 @@ public: LazyBooleanExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> left_bool_expr, std::unique_ptr<Expr> right_bool_expr, ExprType expr_kind, - Location locus) + location_t locus) : OperatorExpr (std::move (mappings), std::move (left_bool_expr), AST::AttrVec (), locus), expr_type (expr_kind), right_expr (std::move (right_bool_expr)) @@ -566,7 +566,7 @@ public: // Constructor requires calling protected constructor of OperatorExpr TypeCastExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> expr_to_cast, - std::unique_ptr<Type> type_to_cast_to, Location locus) + std::unique_ptr<Type> type_to_cast_to, location_t locus) : OperatorExpr (std::move (mappings), std::move (expr_to_cast), AST::AttrVec (), locus), type_to_convert_to (std::move (type_to_cast_to)) @@ -631,7 +631,7 @@ public: // Call OperatorExpr constructor to initialise left_expr AssignmentExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> value_to_assign_to, - std::unique_ptr<Expr> value_to_assign, Location locus) + std::unique_ptr<Expr> value_to_assign, location_t locus) : OperatorExpr (std::move (mappings), std::move (value_to_assign_to), AST::AttrVec (), locus), right_expr (std::move (value_to_assign)) @@ -702,7 +702,7 @@ public: CompoundAssignmentExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> value_to_assign_to, std::unique_ptr<Expr> value_to_assign, - ExprType expr_kind, Location locus) + ExprType expr_kind, location_t locus) : OperatorExpr (std::move (mappings), std::move (value_to_assign_to), AST::AttrVec (), locus), expr_type (expr_kind), right_expr (std::move (value_to_assign)) @@ -755,7 +755,7 @@ class GroupedExpr : public ExprWithoutBlock, public WithInnerAttrs { std::unique_ptr<Expr> expr_in_parens; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -763,7 +763,7 @@ public: GroupedExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> parenthesised_expr, AST::AttrVec inner_attribs, AST::AttrVec outer_attribs, - Location locus) + location_t locus) : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)), WithInnerAttrs (std::move (inner_attribs)), expr_in_parens (std::move (parenthesised_expr)), locus (locus) @@ -969,7 +969,7 @@ class ArrayExpr : public ExprWithoutBlock, public WithInnerAttrs { std::unique_ptr<ArrayElems> internal_elements; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -981,7 +981,7 @@ public: ArrayExpr (Analysis::NodeMapping mappings, std::unique_ptr<ArrayElems> array_elems, AST::AttrVec inner_attribs, AST::AttrVec outer_attribs, - Location locus) + location_t locus) : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)), WithInnerAttrs (std::move (inner_attribs)), internal_elements (std::move (array_elems)), locus (locus) @@ -1046,7 +1046,7 @@ class ArrayIndexExpr : public ExprWithoutBlock std::unique_ptr<Expr> array_expr; std::unique_ptr<Expr> index_expr; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -1054,7 +1054,7 @@ public: ArrayIndexExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> array_expr, std::unique_ptr<Expr> array_index_expr, - AST::AttrVec outer_attribs, Location locus) + AST::AttrVec outer_attribs, location_t locus) : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)), array_expr (std::move (array_expr)), index_expr (std::move (array_index_expr)), locus (locus) @@ -1117,7 +1117,7 @@ class TupleExpr : public ExprWithoutBlock, public WithInnerAttrs std::vector<std::unique_ptr<Expr> > tuple_elems; // replaces (inlined version of) TupleElements - Location locus; + location_t locus; public: std::string as_string () const override; @@ -1125,7 +1125,7 @@ public: TupleExpr (Analysis::NodeMapping mappings, std::vector<std::unique_ptr<Expr> > tuple_elements, AST::AttrVec inner_attribs, AST::AttrVec outer_attribs, - Location locus) + location_t locus) : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)), WithInnerAttrs (std::move (inner_attribs)), tuple_elems (std::move (tuple_elements)), locus (locus) @@ -1200,7 +1200,7 @@ class TupleIndexExpr : public ExprWithoutBlock { std::unique_ptr<Expr> tuple_expr; TupleIndex tuple_index; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -1209,7 +1209,7 @@ public: TupleIndexExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> tuple_expr, TupleIndex index, - AST::AttrVec outer_attribs, Location locus) + AST::AttrVec outer_attribs, location_t locus) : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)), tuple_expr (std::move (tuple_expr)), tuple_index (index), locus (locus) {} @@ -1291,7 +1291,7 @@ public: // Actual HIR node of the struct creator (with no fields). Not abstract! class StructExprStruct : public StructExpr, public WithInnerAttrs { - Location locus; + location_t locus; public: std::string as_string () const override; @@ -1299,7 +1299,7 @@ public: // Constructor has to call protected constructor of base class StructExprStruct (Analysis::NodeMapping mappings, PathInExpression struct_path, AST::AttrVec inner_attribs, - AST::AttrVec outer_attribs, Location locus) + AST::AttrVec outer_attribs, location_t locus) : StructExpr (std::move (mappings), std::move (struct_path), std::move (outer_attribs)), WithInnerAttrs (std::move (inner_attribs)), locus (locus) @@ -1408,12 +1408,12 @@ protected: // pure virtual clone implementation virtual StructExprField *clone_struct_expr_field_impl () const = 0; - StructExprField (Analysis::NodeMapping mapping, Location locus) + StructExprField (Analysis::NodeMapping mapping, location_t locus) : mappings (mapping), locus (locus) {} Analysis::NodeMapping mappings; - Location locus; + location_t locus; }; // Identifier-only variant of StructExprField HIR node @@ -1425,7 +1425,7 @@ private: // TODO: should this store location data? public: StructExprFieldIdentifier (Analysis::NodeMapping mapping, - Identifier field_identifier, Location locus) + Identifier field_identifier, location_t locus) : StructExprField (mapping, locus), field_name (std::move (field_identifier)) {} @@ -1459,7 +1459,7 @@ class StructExprFieldWithVal : public StructExprField protected: StructExprFieldWithVal (Analysis::NodeMapping mapping, - std::unique_ptr<Expr> field_value, Location locus) + std::unique_ptr<Expr> field_value, location_t locus) : StructExprField (mapping, locus), value (std::move (field_value)) {} @@ -1500,7 +1500,7 @@ public: StructExprFieldIdentifierValue (Analysis::NodeMapping mapping, Identifier field_identifier, std::unique_ptr<Expr> field_value, - Location locus) + location_t locus) : StructExprFieldWithVal (mapping, std::move (field_value), locus), field_name (std::move (field_identifier)) {} @@ -1534,7 +1534,8 @@ public: StructExprFieldIndexValue (Analysis::NodeMapping mapping, TupleIndex tuple_index, - std::unique_ptr<Expr> field_value, Location locus) + std::unique_ptr<Expr> field_value, + location_t locus) : StructExprFieldWithVal (mapping, std::move (field_value), locus), index (tuple_index) {} @@ -1582,8 +1583,9 @@ public: // Constructor for StructExprStructFields when no struct base is used StructExprStructFields ( Analysis::NodeMapping mappings, PathInExpression struct_path, - std::vector<std::unique_ptr<StructExprField> > expr_fields, Location locus, - StructBase *base_struct, AST::AttrVec inner_attribs = AST::AttrVec (), + std::vector<std::unique_ptr<StructExprField> > expr_fields, + location_t locus, StructBase *base_struct, + AST::AttrVec inner_attribs = AST::AttrVec (), AST::AttrVec outer_attribs = AST::AttrVec ()) : StructExprStruct (std::move (mappings), std::move (struct_path), std::move (inner_attribs), std::move (outer_attribs), @@ -1671,7 +1673,7 @@ public: StructExprStructBase (Analysis::NodeMapping mappings, PathInExpression struct_path, StructBase base_struct, AST::AttrVec inner_attribs, AST::AttrVec outer_attribs, - Location locus) + location_t locus) : StructExprStruct (std::move (mappings), std::move (struct_path), std::move (inner_attribs), std::move (outer_attribs), locus), @@ -1704,14 +1706,14 @@ class CallExpr : public ExprWithoutBlock { std::unique_ptr<Expr> function; std::vector<std::unique_ptr<Expr> > params; - Location locus; + location_t locus; public: std::string as_string () const override; CallExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> function_expr, std::vector<std::unique_ptr<Expr> > function_params, - AST::AttrVec outer_attribs, Location locus) + AST::AttrVec outer_attribs, location_t locus) : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)), function (std::move (function_expr)), params (std::move (function_params)), locus (locus) @@ -1790,7 +1792,7 @@ class MethodCallExpr : public ExprWithoutBlock std::unique_ptr<Expr> receiver; PathExprSegment method_name; std::vector<std::unique_ptr<Expr> > params; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -1799,7 +1801,7 @@ public: std::unique_ptr<Expr> call_receiver, PathExprSegment method_path, std::vector<std::unique_ptr<Expr> > method_params, - AST::AttrVec outer_attribs, Location locus) + AST::AttrVec outer_attribs, location_t locus) : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)), receiver (std::move (call_receiver)), method_name (std::move (method_path)), params (std::move (method_params)), @@ -1885,7 +1887,7 @@ class FieldAccessExpr : public ExprWithoutBlock std::unique_ptr<Expr> receiver; Identifier field; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -1893,7 +1895,7 @@ public: FieldAccessExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> field_access_receiver, Identifier field_name, AST::AttrVec outer_attribs, - Location locus) + location_t locus) : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)), receiver (std::move (field_access_receiver)), field (std::move (field_name)), locus (locus) @@ -1958,14 +1960,14 @@ private: std::vector<AST::Attribute> outer_attrs; std::unique_ptr<Pattern> pattern; std::unique_ptr<Type> type; - Location locus; + location_t locus; public: // Returns whether the type of the parameter has been given. bool has_type_given () const { return type != nullptr; } // Constructor for closure parameter - ClosureParam (std::unique_ptr<Pattern> param_pattern, Location locus, + ClosureParam (std::unique_ptr<Pattern> param_pattern, location_t locus, std::unique_ptr<Type> param_type = nullptr, std::vector<AST::Attribute> outer_attrs = {}) : outer_attrs (std::move (outer_attrs)), @@ -2029,7 +2031,7 @@ class ClosureExpr : public ExprWithoutBlock private: bool has_move; std::vector<ClosureParam> params; - Location locus; + location_t locus; std::unique_ptr<Type> return_type; std::unique_ptr<Expr> expr; @@ -2038,7 +2040,7 @@ public: std::vector<ClosureParam> closure_params, std::unique_ptr<Type> closure_return_type, std::unique_ptr<Expr> closure_expr, bool has_move, - AST::AttrVec outer_attribs, Location locus) + AST::AttrVec outer_attribs, location_t locus) : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)), has_move (has_move), params (std::move (closure_params)), locus (locus), return_type (std::move (closure_return_type)), @@ -2236,7 +2238,7 @@ protected: class ContinueExpr : public ExprWithoutBlock { Lifetime label; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -2245,8 +2247,8 @@ public: bool has_label () const { return !label.is_error (); } // Constructor for a ContinueExpr with a label. - ContinueExpr (Analysis::NodeMapping mappings, Location locus, Lifetime label, - AST::AttrVec outer_attribs = AST::AttrVec ()) + ContinueExpr (Analysis::NodeMapping mappings, location_t locus, + Lifetime label, AST::AttrVec outer_attribs = AST::AttrVec ()) : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)), label (std::move (label)), locus (locus) {} @@ -2288,7 +2290,7 @@ class BreakExpr : public ExprWithoutBlock // bool has_break_expr; std::unique_ptr<Expr> break_expr; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -2301,7 +2303,7 @@ public: bool has_break_expr () const { return break_expr != nullptr; } // Constructor for a break expression - BreakExpr (Analysis::NodeMapping mappings, Location locus, + BreakExpr (Analysis::NodeMapping mappings, location_t locus, Lifetime break_label, std::unique_ptr<Expr> expr_in_break = nullptr, AST::AttrVec outer_attribs = AST::AttrVec ()) @@ -2365,11 +2367,11 @@ protected: // Base range expression HIR node object - abstract class RangeExpr : public ExprWithoutBlock { - Location locus; + location_t locus; protected: // outer attributes not allowed before range expressions - RangeExpr (Analysis::NodeMapping mappings, Location locus) + RangeExpr (Analysis::NodeMapping mappings, location_t locus) : ExprWithoutBlock (std::move (mappings), AST::AttrVec ()), locus (locus) {} @@ -2394,7 +2396,7 @@ public: RangeFromToExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> range_from, - std::unique_ptr<Expr> range_to, Location locus) + std::unique_ptr<Expr> range_to, location_t locus) : RangeExpr (std::move (mappings), locus), from (std::move (range_from)), to (std::move (range_to)) {} @@ -2451,7 +2453,7 @@ public: std::string as_string () const override; RangeFromExpr (Analysis::NodeMapping mappings, - std::unique_ptr<Expr> range_from, Location locus) + std::unique_ptr<Expr> range_from, location_t locus) : RangeExpr (std::move (mappings), locus), from (std::move (range_from)) {} @@ -2505,7 +2507,7 @@ public: // outer attributes not allowed RangeToExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> range_to, - Location locus) + location_t locus) : RangeExpr (std::move (mappings), locus), to (std::move (range_to)) {} @@ -2555,7 +2557,7 @@ class RangeFullExpr : public RangeExpr public: std::string as_string () const override; - RangeFullExpr (Analysis::NodeMapping mappings, Location locus) + RangeFullExpr (Analysis::NodeMapping mappings, location_t locus) : RangeExpr (std::move (mappings), locus) {} // outer attributes not allowed @@ -2591,7 +2593,7 @@ public: RangeFromToInclExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> range_from, - std::unique_ptr<Expr> range_to, Location locus) + std::unique_ptr<Expr> range_to, location_t locus) : RangeExpr (std::move (mappings), locus), from (std::move (range_from)), to (std::move (range_to)) {} @@ -2649,7 +2651,7 @@ public: std::string as_string () const override; RangeToInclExpr (Analysis::NodeMapping mappings, - std::unique_ptr<Expr> range_to, Location locus) + std::unique_ptr<Expr> range_to, location_t locus) : RangeExpr (std::move (mappings), locus), to (std::move (range_to)) {} // outer attributes not allowed @@ -2699,7 +2701,7 @@ class ReturnExpr : public ExprWithoutBlock public: std::unique_ptr<Expr> return_expr; - Location locus; + location_t locus; std::string as_string () const override; @@ -2708,7 +2710,7 @@ public: bool has_return_expr () const { return return_expr != nullptr; } // Constructor for ReturnExpr. - ReturnExpr (Analysis::NodeMapping mappings, Location locus, + ReturnExpr (Analysis::NodeMapping mappings, location_t locus, std::unique_ptr<Expr> returned_expr = nullptr, AST::AttrVec outer_attribs = AST::AttrVec ()) : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)), @@ -2772,14 +2774,14 @@ class UnsafeBlockExpr : public ExprWithBlock { // Or just have it extend BlockExpr std::unique_ptr<BlockExpr> expr; - Location locus; + location_t locus; public: std::string as_string () const override; UnsafeBlockExpr (Analysis::NodeMapping mappings, std::unique_ptr<BlockExpr> block_expr, - AST::AttrVec outer_attribs, Location locus) + AST::AttrVec outer_attribs, location_t locus) : ExprWithBlock (std::move (mappings), std::move (outer_attribs)), expr (std::move (block_expr)), locus (locus) {} @@ -2839,14 +2841,15 @@ class LoopLabel /*: public Node*/ { Lifetime label; // or type LIFETIME_OR_LABEL - Location locus; + location_t locus; Analysis::NodeMapping mappings; public: std::string as_string () const; - LoopLabel (Analysis::NodeMapping mapping, Lifetime loop_label, Location locus) + LoopLabel (Analysis::NodeMapping mapping, Lifetime loop_label, + location_t locus) : label (std::move (loop_label)), locus (locus), mappings (mapping) {} @@ -2868,12 +2871,12 @@ protected: std::unique_ptr<BlockExpr> loop_block; private: - Location locus; + location_t locus; protected: // Constructor for BaseLoopExpr BaseLoopExpr (Analysis::NodeMapping mappings, - std::unique_ptr<BlockExpr> loop_block, Location locus, + std::unique_ptr<BlockExpr> loop_block, location_t locus, LoopLabel loop_label, AST::AttrVec outer_attribs = AST::AttrVec ()) : ExprWithBlock (std::move (mappings), std::move (outer_attribs)), @@ -2926,7 +2929,7 @@ public: // Constructor for LoopExpr LoopExpr (Analysis::NodeMapping mappings, - std::unique_ptr<BlockExpr> loop_block, Location locus, + std::unique_ptr<BlockExpr> loop_block, location_t locus, LoopLabel loop_label, AST::AttrVec outer_attribs = AST::AttrVec ()) : BaseLoopExpr (std::move (mappings), std::move (loop_block), locus, std::move (loop_label), std::move (outer_attribs)) @@ -2959,7 +2962,7 @@ public: // Constructor for while loop with loop label WhileLoopExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> loop_condition, - std::unique_ptr<BlockExpr> loop_block, Location locus, + std::unique_ptr<BlockExpr> loop_block, location_t locus, LoopLabel loop_label, AST::AttrVec outer_attribs = AST::AttrVec ()) : BaseLoopExpr (std::move (mappings), std::move (loop_block), locus, @@ -3023,7 +3026,7 @@ public: WhileLetLoopExpr (Analysis::NodeMapping mappings, std::vector<std::unique_ptr<Pattern> > match_arm_patterns, std::unique_ptr<Expr> condition, - std::unique_ptr<BlockExpr> loop_block, Location locus, + std::unique_ptr<BlockExpr> loop_block, location_t locus, LoopLabel loop_label, AST::AttrVec outer_attribs = AST::AttrVec ()) : BaseLoopExpr (std::move (mappings), std::move (loop_block), locus, @@ -3102,7 +3105,7 @@ public: ForLoopExpr (Analysis::NodeMapping mappings, std::unique_ptr<Pattern> loop_pattern, std::unique_ptr<Expr> iterator_expr, - std::unique_ptr<BlockExpr> loop_body, Location locus, + std::unique_ptr<BlockExpr> loop_body, location_t locus, LoopLabel loop_label, AST::AttrVec outer_attribs = AST::AttrVec ()) : BaseLoopExpr (std::move (mappings), std::move (loop_body), locus, @@ -3165,13 +3168,13 @@ class IfExpr : public ExprWithBlock std::unique_ptr<Expr> condition; std::unique_ptr<BlockExpr> if_block; - Location locus; + location_t locus; public: std::string as_string () const override; IfExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> condition, - std::unique_ptr<BlockExpr> if_block, Location locus) + std::unique_ptr<BlockExpr> if_block, location_t locus) : ExprWithBlock (std::move (mappings), AST::AttrVec ()), condition (std::move (condition)), if_block (std::move (if_block)), locus (locus) @@ -3249,7 +3252,7 @@ public: IfExprConseqElse (Analysis::NodeMapping mappings, std::unique_ptr<Expr> condition, std::unique_ptr<BlockExpr> if_block, - std::unique_ptr<ExprWithBlock> else_block, Location locus) + std::unique_ptr<ExprWithBlock> else_block, location_t locus) : IfExpr (std::move (mappings), std::move (condition), std::move (if_block), locus), else_block (std::move (else_block)) @@ -3314,7 +3317,7 @@ class IfLetExpr : public ExprWithBlock std::unique_ptr<Expr> value; std::unique_ptr<BlockExpr> if_block; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -3322,7 +3325,7 @@ public: IfLetExpr (Analysis::NodeMapping mappings, std::vector<std::unique_ptr<Pattern> > match_arm_patterns, std::unique_ptr<Expr> value, std::unique_ptr<BlockExpr> if_block, - Location locus) + location_t locus) : ExprWithBlock (std::move (mappings), AST::AttrVec ()), match_arm_patterns (std::move (match_arm_patterns)), value (std::move (value)), if_block (std::move (if_block)), locus (locus) @@ -3418,7 +3421,7 @@ public: Analysis::NodeMapping mappings, std::vector<std::unique_ptr<Pattern> > match_arm_patterns, std::unique_ptr<Expr> value, std::unique_ptr<BlockExpr> if_block, - std::unique_ptr<ExprWithBlock> else_block, Location locus) + std::unique_ptr<ExprWithBlock> else_block, location_t locus) : IfLetExpr (std::move (mappings), std::move (match_arm_patterns), std::move (value), std::move (if_block), locus), else_block (std::move (else_block)) @@ -3484,7 +3487,7 @@ private: AST::AttrVec outer_attrs; std::vector<std::unique_ptr<Pattern> > match_arm_patterns; std::unique_ptr<Expr> guard_expr; - Location locus; + location_t locus; public: // Returns whether the MatchArm has a match arm guard expression @@ -3492,7 +3495,7 @@ public: // Constructor for match arm with a guard expression MatchArm (std::vector<std::unique_ptr<Pattern> > match_arm_patterns, - Location locus, std::unique_ptr<Expr> guard_expr = nullptr, + location_t locus, std::unique_ptr<Expr> guard_expr = nullptr, AST::AttrVec outer_attrs = AST::AttrVec ()) : outer_attrs (std::move (outer_attrs)), match_arm_patterns (std::move (match_arm_patterns)), @@ -3541,7 +3544,7 @@ public: // Creates a match arm in an error state. static MatchArm create_error () { - Location locus = UNDEF_LOCATION; + location_t locus = UNDEF_LOCATION; return MatchArm (std::vector<std::unique_ptr<Pattern> > (), locus); } @@ -3604,7 +3607,7 @@ class MatchExpr : public ExprWithBlock, public WithInnerAttrs { std::unique_ptr<Expr> branch_value; std::vector<MatchCase> match_arms; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -3613,7 +3616,7 @@ public: MatchExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> branch_value, std::vector<MatchCase> match_arms, AST::AttrVec inner_attrs, - AST::AttrVec outer_attrs, Location locus) + AST::AttrVec outer_attrs, location_t locus) : ExprWithBlock (std::move (mappings), std::move (outer_attrs)), WithInnerAttrs (std::move (inner_attrs)), branch_value (std::move (branch_value)), @@ -3684,12 +3687,12 @@ protected: class AwaitExpr : public ExprWithoutBlock { std::unique_ptr<Expr> awaited_expr; - Location locus; + location_t locus; public: // TODO: ensure outer attributes are actually allowed AwaitExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> awaited_expr, - AST::AttrVec outer_attrs, Location locus) + AST::AttrVec outer_attrs, location_t locus) : ExprWithoutBlock (std::move (mappings), std::move (outer_attrs)), awaited_expr (std::move (awaited_expr)), locus (locus) {} @@ -3742,12 +3745,12 @@ class AsyncBlockExpr : public ExprWithBlock { bool has_move; std::unique_ptr<BlockExpr> block_expr; - Location locus; + location_t locus; public: AsyncBlockExpr (Analysis::NodeMapping mappings, std::unique_ptr<BlockExpr> block_expr, bool has_move, - AST::AttrVec outer_attrs, Location locus) + AST::AttrVec outer_attrs, location_t locus) : ExprWithBlock (std::move (mappings), std::move (outer_attrs)), has_move (has_move), block_expr (std::move (block_expr)), locus (locus) {} @@ -3843,7 +3846,7 @@ public: private: const Analysis::NodeMapping node_mappings; const Analysis::NodeMapping lvalue_mappings; - Location locus; + location_t locus; }; class InlineAsmReg @@ -3919,7 +3922,7 @@ struct InlineAsmRegOrRegClass }; Identifier name; - Location locus; + location_t locus; }; // Inline Assembly Node diff --git a/gcc/rust/hir/tree/rust-hir-item.h b/gcc/rust/hir/tree/rust-hir-item.h index 3ba7571..70393f3 100644 --- a/gcc/rust/hir/tree/rust-hir-item.h +++ b/gcc/rust/hir/tree/rust-hir-item.h @@ -48,7 +48,7 @@ class TypeParam : public GenericParam // bool has_type; std::unique_ptr<Type> type; - Location locus; + location_t locus; public: // Returns whether the type of the type param has been specified. @@ -62,7 +62,7 @@ public: AST::Attribute &get_outer_attribute () { return outer_attr; } TypeParam (Analysis::NodeMapping mappings, Identifier type_representation, - Location locus = UNDEF_LOCATION, + location_t locus = UNDEF_LOCATION, std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds = std::vector<std::unique_ptr<TypeParamBound>> (), std::unique_ptr<Type> type = nullptr, @@ -177,13 +177,13 @@ class LifetimeWhereClauseItem : public WhereClauseItem { Lifetime lifetime; std::vector<Lifetime> lifetime_bounds; - Location locus; + location_t locus; Analysis::NodeMapping mappings; public: LifetimeWhereClauseItem (Analysis::NodeMapping mappings, Lifetime lifetime, std::vector<Lifetime> lifetime_bounds, - Location locus) + location_t locus) : lifetime (std::move (lifetime)), lifetime_bounds (std::move (lifetime_bounds)), locus (locus), mappings (std::move (mappings)) @@ -222,7 +222,7 @@ class TypeBoundWhereClauseItem : public WhereClauseItem std::unique_ptr<Type> bound_type; std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds; Analysis::NodeMapping mappings; - Location locus; + location_t locus; public: // Returns whether the item has ForLifetimes @@ -235,7 +235,7 @@ public: Analysis::NodeMapping mappings, std::vector<LifetimeParam> for_lifetimes, std::unique_ptr<Type> bound_type, std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds, - Location locus) + location_t locus) : for_lifetimes (std::move (for_lifetimes)), bound_type (std::move (bound_type)), type_param_bounds (std::move (type_param_bounds)), @@ -376,7 +376,7 @@ private: ImplicitSelfKind self_kind; Lifetime lifetime; std::unique_ptr<Type> type; - Location locus; + location_t locus; Analysis::NodeMapping mappings; SelfParam (Analysis::NodeMapping mappings, ImplicitSelfKind self_kind, @@ -388,7 +388,7 @@ private: public: // Type-based self parameter (not ref, no lifetime) SelfParam (Analysis::NodeMapping mappings, std::unique_ptr<Type> type, - bool is_mut, Location locus) + bool is_mut, location_t locus) : self_kind (is_mut ? ImplicitSelfKind::MUT : ImplicitSelfKind::IMM), lifetime ( Lifetime (mappings, AST::Lifetime::LifetimeType::NAMED, "", locus)), @@ -397,7 +397,7 @@ public: // Lifetime-based self parameter (is ref, no type) SelfParam (Analysis::NodeMapping mappings, Lifetime lifetime, bool is_mut, - Location locus) + location_t locus) : self_kind (is_mut ? ImplicitSelfKind::MUT_REF : ImplicitSelfKind::IMM_REF), lifetime (std::move (lifetime)), locus (locus), mappings (mappings) @@ -507,13 +507,13 @@ struct FunctionParam { std::unique_ptr<Pattern> param_name; std::unique_ptr<Type> type; - Location locus; + location_t locus; Analysis::NodeMapping mappings; public: FunctionParam (Analysis::NodeMapping mappings, std::unique_ptr<Pattern> param_name, - std::unique_ptr<Type> param_type, Location locus) + std::unique_ptr<Type> param_type, location_t locus) : param_name (std::move (param_name)), type (std::move (param_type)), locus (locus), mappings (mappings) {} @@ -566,14 +566,14 @@ public: private: VisType vis_type; HIR::SimplePath path; - Location locus; + location_t locus; // should this store location info? public: Visibility (VisType vis_type, HIR::SimplePath path = HIR::SimplePath::create_empty (), - Location locus = UNDEF_LOCATION) + location_t locus = UNDEF_LOCATION) : vis_type (vis_type), path (std::move (path)), locus (locus) {} @@ -655,7 +655,7 @@ public: class Module : public VisItem, public WithInnerAttrs { Identifier module_name; - Location locus; + location_t locus; // bool has_items; std::vector<std::unique_ptr<Item>> items; @@ -667,7 +667,7 @@ public: // Full constructor Module (Analysis::NodeMapping mappings, Identifier module_name, - Location locus, std::vector<std::unique_ptr<Item>> items, + location_t locus, std::vector<std::unique_ptr<Item>> items, Visibility visibility = Visibility::create_error (), AST::AttrVec inner_attrs = AST::AttrVec (), AST::AttrVec outer_attrs = AST::AttrVec ()) @@ -740,7 +740,7 @@ class ExternCrate : public VisItem // this is either an identifier or "_", with _ parsed to string std::string as_clause_name; - Location locus; + location_t locus; /* e.g. "extern crate foo as _" @@ -758,8 +758,8 @@ public: // Constructor ExternCrate (Analysis::NodeMapping mappings, std::string referenced_crate, - Visibility visibility, AST::AttrVec outer_attrs, Location locus, - std::string as_clause_name = std::string ()) + Visibility visibility, AST::AttrVec outer_attrs, + location_t locus, std::string as_clause_name = std::string ()) : VisItem (std::move (mappings), std::move (visibility), std::move (outer_attrs)), referenced_crate (std::move (referenced_crate)), @@ -800,7 +800,7 @@ protected: // The path-ish thing referred to in a use declaration - abstract base class class UseTree : public FullVisitable { - Location locus; + location_t locus; public: virtual ~UseTree () {} @@ -819,7 +819,7 @@ protected: // Clone function implementation as pure virtual method virtual UseTree *clone_use_tree_impl () const = 0; - UseTree (Location locus) : locus (locus) {} + UseTree (location_t locus) : locus (locus) {} }; // Use tree with a glob (wildcard) operator @@ -838,7 +838,7 @@ private: AST::SimplePath path; public: - UseTreeGlob (PathType glob_type, AST::SimplePath path, Location locus) + UseTreeGlob (PathType glob_type, AST::SimplePath path, location_t locus) : UseTree (locus), glob_type (glob_type), path (std::move (path)) { if (this->glob_type != PATH_PREFIXED) @@ -892,7 +892,7 @@ private: public: UseTreeList (PathType path_type, AST::SimplePath path, - std::vector<std::unique_ptr<UseTree>> trees, Location locus) + std::vector<std::unique_ptr<UseTree>> trees, location_t locus) : UseTree (locus), path_type (path_type), path (std::move (path)), trees (std::move (trees)) { @@ -976,7 +976,7 @@ private: Identifier identifier; // only if NewBindType is IDENTIFIER public: - UseTreeRebind (NewBindType bind_type, AST::SimplePath path, Location locus, + UseTreeRebind (NewBindType bind_type, AST::SimplePath path, location_t locus, Identifier identifier = std::string ()) : UseTree (locus), path (std::move (path)), bind_type (bind_type), identifier (std::move (identifier)) @@ -1013,14 +1013,14 @@ protected: class UseDeclaration : public VisItem { std::unique_ptr<UseTree> use_tree; - Location locus; + location_t locus; public: std::string as_string () const override; UseDeclaration (Analysis::NodeMapping mappings, std::unique_ptr<UseTree> use_tree, Visibility visibility, - AST::AttrVec outer_attrs, Location locus) + AST::AttrVec outer_attrs, location_t locus) : VisItem (std::move (mappings), std::move (visibility), std::move (outer_attrs)), use_tree (std::move (use_tree)), locus (locus) @@ -1084,7 +1084,7 @@ class Function : public VisItem, public ImplItem WhereClause where_clause; std::unique_ptr<BlockExpr> function_body; SelfParam self; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -1115,7 +1115,7 @@ public: std::vector<FunctionParam> function_params, std::unique_ptr<Type> return_type, WhereClause where_clause, std::unique_ptr<BlockExpr> function_body, Visibility vis, - AST::AttrVec outer_attrs, SelfParam self, Location locus) + AST::AttrVec outer_attrs, SelfParam self, location_t locus) : VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)), qualifiers (std::move (qualifiers)), function_name (std::move (function_name)), @@ -1255,7 +1255,7 @@ class TypeAlias : public VisItem, public ImplItem std::unique_ptr<Type> existing_type; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -1275,7 +1275,7 @@ public: TypeAlias (Analysis::NodeMapping mappings, Identifier new_type_name, std::vector<std::unique_ptr<GenericParam>> generic_params, WhereClause where_clause, std::unique_ptr<Type> existing_type, - Visibility vis, AST::AttrVec outer_attrs, Location locus) + Visibility vis, AST::AttrVec outer_attrs, location_t locus) : VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)), new_type_name (std::move (new_type_name)), generic_params (std::move (generic_params)), @@ -1375,7 +1375,7 @@ protected: // bool has_where_clause; WhereClause where_clause; - Location locus; + location_t locus; public: Identifier get_identifier () const { return struct_name; } @@ -1399,7 +1399,7 @@ public: protected: Struct (Analysis::NodeMapping mappings, Identifier struct_name, std::vector<std::unique_ptr<GenericParam>> generic_params, - WhereClause where_clause, Visibility vis, Location locus, + WhereClause where_clause, Visibility vis, location_t locus, AST::AttrVec outer_attrs = AST::AttrVec ()) : VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)), struct_name (std::move (struct_name)), @@ -1453,7 +1453,7 @@ public: Analysis::NodeMapping mappings; - Location locus; + location_t locus; // Returns whether struct field has any outer attributes. bool has_outer_attributes () const { return !outer_attrs.empty (); } @@ -1462,8 +1462,8 @@ public: bool has_visibility () const { return !visibility.is_error (); } StructField (Analysis::NodeMapping mappings, Identifier field_name, - std::unique_ptr<Type> field_type, Visibility vis, Location locus, - AST::AttrVec outer_attrs = AST::AttrVec ()) + std::unique_ptr<Type> field_type, Visibility vis, + location_t locus, AST::AttrVec outer_attrs = AST::AttrVec ()) : outer_attrs (std::move (outer_attrs)), visibility (std::move (vis)), field_name (std::move (field_name)), field_type (std::move (field_type)), mappings (mappings), locus (locus) @@ -1521,7 +1521,7 @@ public: Identifier struct_name, std::vector<std::unique_ptr<GenericParam>> generic_params, WhereClause where_clause, bool is_unit, Visibility vis, - AST::AttrVec outer_attrs, Location locus) + AST::AttrVec outer_attrs, location_t locus) : Struct (std::move (mappings), std::move (struct_name), std::move (generic_params), std::move (where_clause), std::move (vis), locus, std::move (outer_attrs)), @@ -1532,7 +1532,7 @@ public: StructStruct (Analysis::NodeMapping mappings, Identifier struct_name, std::vector<std::unique_ptr<GenericParam>> generic_params, WhereClause where_clause, Visibility vis, - AST::AttrVec outer_attrs, Location locus) + AST::AttrVec outer_attrs, location_t locus) : Struct (std::move (mappings), std::move (struct_name), std::move (generic_params), std::move (where_clause), std::move (vis), locus, std::move (outer_attrs)), @@ -1578,7 +1578,7 @@ private: std::unique_ptr<Type> field_type; - Location locus; + location_t locus; Analysis::NodeMapping mappings; @@ -1592,7 +1592,7 @@ public: // Complete constructor TupleField (Analysis::NodeMapping mapping, std::unique_ptr<Type> field_type, - Visibility vis, Location locus, + Visibility vis, location_t locus, AST::AttrVec outer_attrs = AST::AttrVec ()) : outer_attrs (std::move (outer_attrs)), visibility (std::move (vis)), field_type (std::move (field_type)), locus (locus), mappings (mapping) @@ -1651,7 +1651,7 @@ public: Identifier struct_name, std::vector<std::unique_ptr<GenericParam>> generic_params, WhereClause where_clause, Visibility vis, - AST::AttrVec outer_attrs, Location locus) + AST::AttrVec outer_attrs, location_t locus) : Struct (std::move (mappings), std::move (struct_name), std::move (generic_params), std::move (where_clause), std::move (vis), locus, std::move (outer_attrs)), @@ -1687,7 +1687,7 @@ protected: class EnumItem : public Item { Identifier variant_name; - Location locus; + location_t locus; public: virtual ~EnumItem () {} @@ -1701,7 +1701,7 @@ public: }; EnumItem (Analysis::NodeMapping mappings, Identifier variant_name, - AST::AttrVec outer_attrs, Location locus) + AST::AttrVec outer_attrs, location_t locus) : Item (std::move (mappings), std::move (outer_attrs)), variant_name (std::move (variant_name)), locus (locus) {} @@ -1747,7 +1747,7 @@ public: EnumItemTuple (Analysis::NodeMapping mappings, Identifier variant_name, std::vector<TupleField> tuple_fields, AST::AttrVec outer_attrs, - Location locus) + location_t locus) : EnumItem (std::move (mappings), std::move (variant_name), std::move (outer_attrs), locus), tuple_fields (std::move (tuple_fields)) @@ -1785,7 +1785,7 @@ public: EnumItemStruct (Analysis::NodeMapping mappings, Identifier variant_name, std::vector<StructField> struct_fields, - AST::AttrVec outer_attrs, Location locus) + AST::AttrVec outer_attrs, location_t locus) : EnumItem (std::move (mappings), std::move (variant_name), std::move (outer_attrs), locus), struct_fields (std::move (struct_fields)) @@ -1814,7 +1814,7 @@ class EnumItemDiscriminant : public EnumItem public: EnumItemDiscriminant (Analysis::NodeMapping mappings, Identifier variant_name, std::unique_ptr<Expr> expr, AST::AttrVec outer_attrs, - Location locus) + location_t locus) : EnumItem (std::move (mappings), std::move (variant_name), std::move (outer_attrs), locus), expression (std::move (expr)) @@ -1874,7 +1874,7 @@ class Enum : public VisItem std::vector<std::unique_ptr<EnumItem>> items; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -1893,7 +1893,7 @@ public: Enum (Analysis::NodeMapping mappings, Identifier enum_name, Visibility vis, std::vector<std::unique_ptr<GenericParam>> generic_params, WhereClause where_clause, std::vector<std::unique_ptr<EnumItem>> items, - AST::AttrVec outer_attrs, Location locus) + AST::AttrVec outer_attrs, location_t locus) : VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)), enum_name (std::move (enum_name)), generic_params (std::move (generic_params)), @@ -1988,7 +1988,7 @@ class Union : public VisItem std::vector<StructField> variants; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -2002,7 +2002,7 @@ public: Union (Analysis::NodeMapping mappings, Identifier union_name, Visibility vis, std::vector<std::unique_ptr<GenericParam>> generic_params, WhereClause where_clause, std::vector<StructField> variants, - AST::AttrVec outer_attrs, Location locus) + AST::AttrVec outer_attrs, location_t locus) : VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)), union_name (std::move (union_name)), generic_params (std::move (generic_params)), @@ -2071,7 +2071,7 @@ class ConstantItem : public VisItem, public ImplItem Identifier identifier; std::unique_ptr<Type> type; std::unique_ptr<Expr> const_expr; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -2079,7 +2079,7 @@ public: ConstantItem (Analysis::NodeMapping mappings, Identifier ident, Visibility vis, std::unique_ptr<Type> type, std::unique_ptr<Expr> const_expr, AST::AttrVec outer_attrs, - Location locus) + location_t locus) : VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)), identifier (std::move (ident)), type (std::move (type)), const_expr (std::move (const_expr)), locus (locus) @@ -2168,14 +2168,14 @@ class StaticItem : public VisItem Identifier name; std::unique_ptr<Type> type; std::unique_ptr<Expr> expr; - Location locus; + location_t locus; public: std::string as_string () const override; StaticItem (Analysis::NodeMapping mappings, Identifier name, Mutability mut, std::unique_ptr<Type> type, std::unique_ptr<Expr> expr, - Visibility vis, AST::AttrVec outer_attrs, Location locus) + Visibility vis, AST::AttrVec outer_attrs, location_t locus) : VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)), mut (mut), name (std::move (name)), type (std::move (type)), expr (std::move (expr)), locus (locus) @@ -2332,7 +2332,7 @@ class TraitItemFunc : public TraitItem AST::AttrVec outer_attrs; TraitFunctionDecl decl; std::unique_ptr<BlockExpr> block_expr; - Location locus; + location_t locus; public: // Returns whether function has a definition or is just a declaration. @@ -2340,7 +2340,7 @@ public: TraitItemFunc (Analysis::NodeMapping mappings, TraitFunctionDecl decl, std::unique_ptr<BlockExpr> block_expr, - AST::AttrVec outer_attrs, Location locus) + AST::AttrVec outer_attrs, location_t locus) : TraitItem (mappings), outer_attrs (std::move (outer_attrs)), decl (std::move (decl)), block_expr (std::move (block_expr)), locus (locus) @@ -2421,7 +2421,7 @@ class TraitItemConst : public TraitItem Identifier name; std::unique_ptr<Type> type; std::unique_ptr<Expr> expr; - Location locus; + location_t locus; public: // Whether the constant item has an associated expression. @@ -2429,7 +2429,7 @@ public: TraitItemConst (Analysis::NodeMapping mappings, Identifier name, std::unique_ptr<Type> type, std::unique_ptr<Expr> expr, - AST::AttrVec outer_attrs, Location locus) + AST::AttrVec outer_attrs, location_t locus) : TraitItem (mappings), outer_attrs (std::move (outer_attrs)), name (std::move (name)), type (std::move (type)), expr (std::move (expr)), locus (locus) @@ -2509,7 +2509,7 @@ class TraitItemType : public TraitItem Identifier name; std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds; // inlined form - Location locus; + location_t locus; public: // Returns whether trait item type has type param bounds. @@ -2517,7 +2517,7 @@ public: TraitItemType (Analysis::NodeMapping mappings, Identifier name, std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds, - AST::AttrVec outer_attrs, Location locus) + AST::AttrVec outer_attrs, location_t locus) : TraitItem (mappings), outer_attrs (std::move (outer_attrs)), name (std::move (name)), type_param_bounds (std::move (type_param_bounds)), locus (locus) @@ -2602,7 +2602,7 @@ class Trait : public VisItem std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds; WhereClause where_clause; std::vector<std::unique_ptr<TraitItem>> trait_items; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -2635,7 +2635,7 @@ public: std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds, WhereClause where_clause, std::vector<std::unique_ptr<TraitItem>> trait_items, Visibility vis, - AST::AttrVec outer_attrs, Location locus) + AST::AttrVec outer_attrs, location_t locus) : VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)), unsafety (unsafety), name (std::move (name)), generic_params (std::move (generic_params)), @@ -2732,7 +2732,7 @@ class ImplBlock : public VisItem, public WithInnerAttrs std::unique_ptr<TypePath> trait_ref; WhereClause where_clause; Polarity polarity; - Location locus; + location_t locus; std::vector<std::unique_ptr<ImplItem>> impl_items; public: @@ -2742,7 +2742,7 @@ public: std::unique_ptr<Type> impl_type, std::unique_ptr<TypePath> trait_ref, WhereClause where_clause, Polarity polarity, Visibility vis, AST::AttrVec inner_attrs, - AST::AttrVec outer_attrs, Location locus) + AST::AttrVec outer_attrs, location_t locus) : VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)), WithInnerAttrs (std::move (inner_attrs)), generic_params (std::move (generic_params)), @@ -2845,7 +2845,7 @@ class ExternalItem : public Node AST::AttrVec outer_attrs; Visibility visibility; Identifier item_name; - Location locus; + location_t locus; public: enum class ExternKind @@ -2888,7 +2888,7 @@ public: protected: ExternalItem (Analysis::NodeMapping mappings, Identifier item_name, - Visibility vis, AST::AttrVec outer_attrs, Location locus) + Visibility vis, AST::AttrVec outer_attrs, location_t locus) : mappings (mappings), outer_attrs (std::move (outer_attrs)), visibility (std::move (vis)), item_name (std::move (item_name)), locus (locus) @@ -2930,7 +2930,8 @@ class ExternalStaticItem : public ExternalItem public: ExternalStaticItem (Analysis::NodeMapping mappings, Identifier item_name, std::unique_ptr<Type> item_type, Mutability mut, - Visibility vis, AST::AttrVec outer_attrs, Location locus) + Visibility vis, AST::AttrVec outer_attrs, + location_t locus) : ExternalItem (std::move (mappings), std::move (item_name), std::move (vis), std::move (outer_attrs), locus), mut (mut), item_type (std::move (item_type)) @@ -3059,7 +3060,7 @@ public: std::vector<std::unique_ptr<GenericParam>> generic_params, std::unique_ptr<Type> return_type, WhereClause where_clause, std::vector<NamedFunctionParam> function_params, bool has_variadics, - Visibility vis, AST::AttrVec outer_attrs, Location locus) + Visibility vis, AST::AttrVec outer_attrs, location_t locus) : ExternalItem (std::move (mappings), std::move (item_name), std::move (vis), std::move (outer_attrs), locus), generic_params (std::move (generic_params)), @@ -3136,7 +3137,7 @@ class ExternBlock : public VisItem, public WithInnerAttrs { ABI abi; std::vector<std::unique_ptr<ExternalItem>> extern_items; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -3149,7 +3150,7 @@ public: ExternBlock (Analysis::NodeMapping mappings, ABI abi, std::vector<std::unique_ptr<ExternalItem>> extern_items, Visibility vis, AST::AttrVec inner_attrs, - AST::AttrVec outer_attrs, Location locus) + AST::AttrVec outer_attrs, location_t locus) : VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)), WithInnerAttrs (std::move (inner_attrs)), abi (abi), extern_items (std::move (extern_items)), locus (locus) diff --git a/gcc/rust/hir/tree/rust-hir-path.h b/gcc/rust/hir/tree/rust-hir-path.h index a41aa2d1..f726a43 100644 --- a/gcc/rust/hir/tree/rust-hir-path.h +++ b/gcc/rust/hir/tree/rust-hir-path.h @@ -58,7 +58,7 @@ class GenericArgsBinding Identifier identifier; std::unique_ptr<Type> type; - Location locus; + location_t locus; public: // Returns whether binding is in an error state. @@ -76,7 +76,7 @@ public: // Pointer type for type in constructor to enable polymorphism GenericArgsBinding (Identifier ident, std::unique_ptr<Type> type_ptr, - Location locus = UNDEF_LOCATION) + location_t locus = UNDEF_LOCATION) : identifier (std::move (ident)), type (std::move (type_ptr)), locus (locus) {} @@ -119,7 +119,7 @@ class ConstGenericArg // at name-resolution, hence no need for ambiguities here public: - ConstGenericArg (std::unique_ptr<Expr> expression, Location locus) + ConstGenericArg (std::unique_ptr<Expr> expression, location_t locus) : expression (std::move (expression)), locus (locus) {} @@ -140,7 +140,7 @@ public: private: std::unique_ptr<Expr> expression; - Location locus; + location_t locus; }; class GenericArgs @@ -149,7 +149,7 @@ class GenericArgs std::vector<std::unique_ptr<Type> > type_args; std::vector<GenericArgsBinding> binding_args; std::vector<ConstGenericArg> const_args; - Location locus; + location_t locus; public: // Returns true if there are any generic arguments @@ -162,7 +162,7 @@ public: GenericArgs (std::vector<Lifetime> lifetime_args, std::vector<std::unique_ptr<Type> > type_args, std::vector<GenericArgsBinding> binding_args, - std::vector<ConstGenericArg> const_args, Location locus) + std::vector<ConstGenericArg> const_args, location_t locus) : lifetime_args (std::move (lifetime_args)), type_args (std::move (type_args)), binding_args (std::move (binding_args)), @@ -204,7 +204,7 @@ public: GenericArgs &operator= (GenericArgs &&other) = default; // Creates an empty GenericArgs (no arguments) - static GenericArgs create_empty (Location locus = UNDEF_LOCATION) + static GenericArgs create_empty (location_t locus = UNDEF_LOCATION) { return GenericArgs ({}, {}, {}, {}, locus); } @@ -236,11 +236,11 @@ private: Analysis::NodeMapping mappings; PathIdentSegment segment_name; GenericArgs generic_args; - Location locus; + location_t locus; public: PathExprSegment (Analysis::NodeMapping mappings, - PathIdentSegment segment_name, Location locus, + PathIdentSegment segment_name, location_t locus, GenericArgs generic_args) : mappings (std::move (mappings)), segment_name (std::move (segment_name)), generic_args (std::move (generic_args)), locus (locus) @@ -334,7 +334,7 @@ public: class PathInExpression : public PathPattern, public PathExpr { bool has_opening_scope_resolution; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -342,7 +342,7 @@ public: // Constructor PathInExpression (Analysis::NodeMapping mappings, std::vector<PathExprSegment> path_segments, - Location locus = UNDEF_LOCATION, + location_t locus = UNDEF_LOCATION, bool has_opening_scope_resolution = false, std::vector<AST::Attribute> outer_attrs = std::vector<AST::Attribute> ()) @@ -426,7 +426,7 @@ public: private: Analysis::NodeMapping mappings; PathIdentSegment ident_segment; - Location locus; + location_t locus; protected: bool has_separating_scope_resolution; @@ -452,7 +452,7 @@ public: TypePathSegment (Analysis::NodeMapping mappings, PathIdentSegment ident_segment, - bool has_separating_scope_resolution, Location locus) + bool has_separating_scope_resolution, location_t locus) : mappings (std::move (mappings)), ident_segment (std::move (ident_segment)), locus (locus), has_separating_scope_resolution (has_separating_scope_resolution), @@ -460,7 +460,7 @@ public: {} TypePathSegment (Analysis::NodeMapping mappings, std::string segment_name, - bool has_separating_scope_resolution, Location locus) + bool has_separating_scope_resolution, location_t locus) : mappings (std::move (mappings)), ident_segment (PathIdentSegment (std::move (segment_name))), locus (locus), @@ -507,7 +507,7 @@ public: TypePathSegmentGeneric (Analysis::NodeMapping mappings, PathIdentSegment ident_segment, bool has_separating_scope_resolution, - GenericArgs generic_args, Location locus) + GenericArgs generic_args, location_t locus) : TypePathSegment (std::move (mappings), std::move (ident_segment), has_separating_scope_resolution, locus), generic_args (std::move (generic_args)) @@ -521,7 +521,7 @@ public: std::vector<std::unique_ptr<Type> > type_args, std::vector<GenericArgsBinding> binding_args, std::vector<ConstGenericArg> const_args, - Location locus) + location_t locus) : TypePathSegment (std::move (mappings), std::move (segment_name), has_separating_scope_resolution, locus), generic_args ( @@ -620,7 +620,7 @@ public: TypePathSegmentFunction (Analysis::NodeMapping mappings, PathIdentSegment ident_segment, bool has_separating_scope_resolution, - TypePathFunction function_path, Location locus) + TypePathFunction function_path, location_t locus) : TypePathSegment (std::move (mappings), std::move (ident_segment), has_separating_scope_resolution, locus), function_path (std::move (function_path)) @@ -630,7 +630,7 @@ public: TypePathSegmentFunction (Analysis::NodeMapping mappings, std::string segment_name, bool has_separating_scope_resolution, - TypePathFunction function_path, Location locus) + TypePathFunction function_path, location_t locus) : TypePathSegment (std::move (mappings), std::move (segment_name), has_separating_scope_resolution, locus), function_path (std::move (function_path)) @@ -694,7 +694,7 @@ public: // Constructor TypePath (Analysis::NodeMapping mappings, std::vector<std::unique_ptr<TypePathSegment> > segments, - Location locus, bool has_opening_scope_resolution = false) + location_t locus, bool has_opening_scope_resolution = false) : TypeNoBounds (mappings, locus), has_opening_scope_resolution (has_opening_scope_resolution), segments (std::move (segments)) @@ -757,13 +757,13 @@ class QualifiedPathType { std::unique_ptr<Type> type; std::unique_ptr<TypePath> trait; - Location locus; + location_t locus; Analysis::NodeMapping mappings; public: // Constructor QualifiedPathType (Analysis::NodeMapping mappings, std::unique_ptr<Type> type, - std::unique_ptr<TypePath> trait, Location locus) + std::unique_ptr<TypePath> trait, location_t locus) : type (std::move (type)), trait (std::move (trait)), locus (locus), mappings (mappings) {} @@ -838,7 +838,7 @@ public: class QualifiedPathInExpression : public PathPattern, public PathExpr { QualifiedPathType path_type; - Location locus; + location_t locus; public: std::string as_string () const override; @@ -846,7 +846,7 @@ public: QualifiedPathInExpression (Analysis::NodeMapping mappings, QualifiedPathType qual_path_type, std::vector<PathExprSegment> path_segments, - Location locus = UNDEF_LOCATION, + location_t locus = UNDEF_LOCATION, std::vector<AST::Attribute> outer_attrs = std::vector<AST::Attribute> ()) : PathPattern (std::move (path_segments)), @@ -913,7 +913,7 @@ public: Analysis::NodeMapping mappings, QualifiedPathType qual_path_type, std::unique_ptr<TypePathSegment> associated_segment, std::vector<std::unique_ptr<TypePathSegment> > path_segments, - Location locus = UNDEF_LOCATION) + location_t locus = UNDEF_LOCATION) : TypeNoBounds (mappings, locus), path_type (std::move (qual_path_type)), associated_segment (std::move (associated_segment)), segments (std::move (path_segments)) @@ -984,11 +984,11 @@ class SimplePath { std::vector<SimplePathSegment> segments; Analysis::NodeMapping mappings; - Location locus; + location_t locus; public: SimplePath (std::vector<SimplePathSegment> segments, - Analysis::NodeMapping mappings, Location locus) + Analysis::NodeMapping mappings, location_t locus) : segments (std::move (segments)), mappings (mappings), locus (locus) {} diff --git a/gcc/rust/hir/tree/rust-hir-pattern.h b/gcc/rust/hir/tree/rust-hir-pattern.h index 93770a0..882aa11 100644 --- a/gcc/rust/hir/tree/rust-hir-pattern.h +++ b/gcc/rust/hir/tree/rust-hir-pattern.h @@ -29,19 +29,19 @@ namespace HIR { class LiteralPattern : public Pattern { Literal lit; - Location locus; + location_t locus; Analysis::NodeMapping mappings; public: std::string as_string () const override; // Constructor for a literal pattern - LiteralPattern (Analysis::NodeMapping mappings, Literal lit, Location locus) + LiteralPattern (Analysis::NodeMapping mappings, Literal lit, location_t locus) : lit (std::move (lit)), locus (locus), mappings (mappings) {} LiteralPattern (Analysis::NodeMapping mappings, std::string val, - Literal::LitType type, Location locus) + Literal::LitType type, location_t locus) : lit (Literal (std::move (val), type, PrimitiveCoreType::CORETYPE_STR)), locus (locus), mappings (mappings) {} @@ -80,7 +80,7 @@ class IdentifierPattern : public Pattern bool is_ref; Mutability mut; std::unique_ptr<Pattern> to_bind; - Location locus; + location_t locus; Analysis::NodeMapping mappings; public: @@ -91,7 +91,7 @@ public: // Constructor IdentifierPattern (Analysis::NodeMapping mappings, Identifier ident, - Location locus, bool is_ref = false, + location_t locus, bool is_ref = false, Mutability mut = Mutability::Imm, std::unique_ptr<Pattern> to_bind = nullptr) : variable_ident (std::move (ident)), is_ref (is_ref), mut (mut), @@ -161,13 +161,13 @@ protected: // HIR node for using the '_' wildcard "match any value" pattern class WildcardPattern : public Pattern { - Location locus; + location_t locus; Analysis::NodeMapping mappings; public: std::string as_string () const override { return std::string (1, '_'); } - WildcardPattern (Analysis::NodeMapping mappings, Location locus) + WildcardPattern (Analysis::NodeMapping mappings, location_t locus) : locus (locus), mappings (mappings) {} @@ -236,11 +236,11 @@ class RangePatternBoundLiteral : public RangePatternBound // Minus prefixed to literal (if integer or floating-point) bool has_minus; - Location locus; + location_t locus; public: // Constructor - RangePatternBoundLiteral (Literal literal, Location locus, + RangePatternBoundLiteral (Literal literal, location_t locus, bool has_minus = false) : literal (literal), has_minus (has_minus), locus (locus) {} @@ -348,7 +348,7 @@ class RangePattern : public Pattern /* location only stored to avoid a dereference - lower pattern should give * correct location so maybe change in future */ - Location locus; + location_t locus; Analysis::NodeMapping mappings; public: @@ -357,7 +357,7 @@ public: // Constructor RangePattern (Analysis::NodeMapping mappings, std::unique_ptr<RangePatternBound> lower, - std::unique_ptr<RangePatternBound> upper, Location locus, + std::unique_ptr<RangePatternBound> upper, location_t locus, bool has_ellipsis_syntax = false) : lower (std::move (lower)), upper (std::move (upper)), has_ellipsis_syntax (has_ellipsis_syntax), locus (locus), @@ -423,7 +423,7 @@ class ReferencePattern : public Pattern { Mutability mut; std::unique_ptr<Pattern> pattern; - Location locus; + location_t locus; Analysis::NodeMapping mappings; public: @@ -431,7 +431,7 @@ public: ReferencePattern (Analysis::NodeMapping mappings, std::unique_ptr<Pattern> pattern, Mutability reference_mut, - Location locus) + location_t locus) : mut (reference_mut), pattern (std::move (pattern)), locus (locus), mappings (mappings) {} @@ -491,7 +491,7 @@ protected: class StructPatternField { AST::AttrVec outer_attrs; - Location locus; + location_t locus; Analysis::NodeMapping mappings; public: @@ -521,7 +521,7 @@ public: protected: StructPatternField (Analysis::NodeMapping mappings, - AST::AttrVec outer_attribs, Location locus) + AST::AttrVec outer_attribs, location_t locus) : outer_attrs (std::move (outer_attribs)), locus (locus), mappings (mappings) {} @@ -539,7 +539,7 @@ class StructPatternFieldTuplePat : public StructPatternField public: StructPatternFieldTuplePat (Analysis::NodeMapping mappings, TupleIndex index, std::unique_ptr<Pattern> tuple_pattern, - AST::AttrVec outer_attribs, Location locus) + AST::AttrVec outer_attribs, location_t locus) : StructPatternField (mappings, std::move (outer_attribs), locus), index (index), tuple_pattern (std::move (tuple_pattern)) {} @@ -594,7 +594,7 @@ class StructPatternFieldIdentPat : public StructPatternField public: StructPatternFieldIdentPat (Analysis::NodeMapping mappings, Identifier ident, std::unique_ptr<Pattern> ident_pattern, - AST::AttrVec outer_attrs, Location locus) + AST::AttrVec outer_attrs, location_t locus) : StructPatternField (mappings, std::move (outer_attrs), locus), ident (std::move (ident)), ident_pattern (std::move (ident_pattern)) {} @@ -651,7 +651,7 @@ class StructPatternFieldIdent : public StructPatternField public: StructPatternFieldIdent (Analysis::NodeMapping mappings, Identifier ident, bool is_ref, Mutability mut, - AST::AttrVec outer_attrs, Location locus) + AST::AttrVec outer_attrs, location_t locus) : StructPatternField (mappings, std::move (outer_attrs), locus), has_ref (is_ref), mut (mut), ident (std::move (ident)) {} @@ -1184,7 +1184,7 @@ protected: class TuplePattern : public Pattern { std::unique_ptr<TuplePatternItems> items; - Location locus; + location_t locus; Analysis::NodeMapping mappings; public: @@ -1194,7 +1194,7 @@ public: bool has_tuple_pattern_items () const { return items != nullptr; } TuplePattern (Analysis::NodeMapping mappings, - std::unique_ptr<TuplePatternItems> items, Location locus) + std::unique_ptr<TuplePatternItems> items, location_t locus) : items (std::move (items)), locus (locus), mappings (mappings) {} @@ -1245,14 +1245,14 @@ protected: class SlicePattern : public Pattern { std::vector<std::unique_ptr<Pattern>> items; - Location locus; + location_t locus; Analysis::NodeMapping mappings; public: std::string as_string () const override; SlicePattern (Analysis::NodeMapping mappings, - std::vector<std::unique_ptr<Pattern>> items, Location locus) + std::vector<std::unique_ptr<Pattern>> items, location_t locus) : items (std::move (items)), locus (locus), mappings (mappings) {} @@ -1317,14 +1317,14 @@ protected: class AltPattern : public Pattern { std::vector<std::unique_ptr<Pattern>> alts; - Location locus; + location_t locus; Analysis::NodeMapping mappings; public: std::string as_string () const override; AltPattern (Analysis::NodeMapping mappings, - std::vector<std::unique_ptr<Pattern>> alts, Location locus) + std::vector<std::unique_ptr<Pattern>> alts, location_t locus) : alts (std::move (alts)), locus (locus), mappings (mappings) {} diff --git a/gcc/rust/hir/tree/rust-hir-stmt.h b/gcc/rust/hir/tree/rust-hir-stmt.h index 3e27438..212bf2a 100644 --- a/gcc/rust/hir/tree/rust-hir-stmt.h +++ b/gcc/rust/hir/tree/rust-hir-stmt.h @@ -28,12 +28,12 @@ namespace HIR { // Just a semi-colon, which apparently is a statement. class EmptyStmt : public Stmt { - Location locus; + location_t locus; public: std::string as_string () const override { return std::string (1, ';'); } - EmptyStmt (Analysis::NodeMapping mappings, Location locus) + EmptyStmt (Analysis::NodeMapping mappings, location_t locus) : Stmt (std::move (mappings)), locus (locus) {} @@ -65,7 +65,7 @@ class LetStmt : public Stmt // bool has_init_expr; std::unique_ptr<Expr> init_expr; - Location locus; + location_t locus; public: // Returns whether let statement has outer attributes. @@ -82,7 +82,7 @@ public: LetStmt (Analysis::NodeMapping mappings, std::unique_ptr<Pattern> variables_pattern, std::unique_ptr<Expr> init_expr, std::unique_ptr<Type> type, - AST::AttrVec outer_attrs, Location locus) + AST::AttrVec outer_attrs, location_t locus) : Stmt (std::move (mappings)), outer_attrs (std::move (outer_attrs)), variables_pattern (std::move (variables_pattern)), type (std::move (type)), init_expr (std::move (init_expr)), locus (locus) @@ -162,18 +162,18 @@ protected: class ExprStmt : public Stmt { std::unique_ptr<Expr> expr; - Location locus; + location_t locus; bool must_be_unit; public: ExprStmt (Analysis::NodeMapping mappings, std::unique_ptr<Expr> expr, - Location locus, bool must_be_unit) + location_t locus, bool must_be_unit) : Stmt (std::move (mappings)), expr (std::move (expr)), locus (locus), must_be_unit (must_be_unit) {} ExprStmt (Analysis::NodeMapping mappings, std::unique_ptr<Expr> expr, - Location locus) + location_t locus) : ExprStmt (std::move (mappings), std::move (expr), locus, false) {} diff --git a/gcc/rust/hir/tree/rust-hir-type.h b/gcc/rust/hir/tree/rust-hir-type.h index f6d5ab2..91ac1d4 100644 --- a/gcc/rust/hir/tree/rust-hir-type.h +++ b/gcc/rust/hir/tree/rust-hir-type.h @@ -36,7 +36,7 @@ class TraitBound : public TypeParamBound bool opening_question_mark; std::vector<LifetimeParam> for_lifetimes; TypePath type_path; - Location locus; + location_t locus; Analysis::NodeMapping mappings; @@ -44,8 +44,9 @@ public: // Returns whether trait bound has "for" lifetimes bool has_for_lifetimes () const { return !for_lifetimes.empty (); } - TraitBound (Analysis::NodeMapping mapping, TypePath type_path, Location locus, - bool in_parens = false, bool opening_question_mark = false, + TraitBound (Analysis::NodeMapping mapping, TypePath type_path, + location_t locus, bool in_parens = false, + bool opening_question_mark = false, std::vector<LifetimeParam> for_lifetimes = std::vector<LifetimeParam> ()) : in_parens (in_parens), opening_question_mark (opening_question_mark), @@ -104,7 +105,7 @@ protected: public: ImplTraitType (Analysis::NodeMapping mappings, std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds, - Location locus) + location_t locus) : Type (mappings, locus), type_param_bounds (std::move (type_param_bounds)) {} @@ -161,7 +162,7 @@ public: TraitObjectType ( Analysis::NodeMapping mappings, std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds, - Location locus, bool is_dyn_dispatch) + location_t locus, bool is_dyn_dispatch) : Type (mappings, locus), has_dyn (is_dyn_dispatch), type_param_bounds (std::move (type_param_bounds)) {} @@ -232,7 +233,7 @@ protected: public: // Constructor uses Type pointer for polymorphism ParenthesisedType (Analysis::NodeMapping mappings, - std::unique_ptr<Type> type_inside_parens, Location locus) + std::unique_ptr<Type> type_inside_parens, location_t locus) : TypeNoBounds (mappings, locus), type_in_parens (std::move (type_inside_parens)) {} @@ -297,7 +298,7 @@ protected: public: ImplTraitTypeOneBound (Analysis::NodeMapping mappings, TraitBound trait_bound, - Location locus) + location_t locus) : TypeNoBounds (mappings, locus), trait_bound (std::move (trait_bound)) {} @@ -320,7 +321,7 @@ public: bool is_unit_type () const { return elems.empty (); } TupleType (Analysis::NodeMapping mappings, - std::vector<std::unique_ptr<Type>> elems, Location locus) + std::vector<std::unique_ptr<Type>> elems, location_t locus) : TypeNoBounds (mappings, locus), elems (std::move (elems)) {} @@ -389,7 +390,7 @@ protected: } public: - NeverType (Analysis::NodeMapping mappings, Location locus) + NeverType (Analysis::NodeMapping mappings, location_t locus) : TypeNoBounds (mappings, locus) {} @@ -409,7 +410,7 @@ private: public: // Constructor requires pointer for polymorphism reasons RawPointerType (Analysis::NodeMapping mappings, Mutability mut, - std::unique_ptr<Type> type, Location locus) + std::unique_ptr<Type> type, location_t locus) : TypeNoBounds (mappings, locus), mut (mut), type (std::move (type)) {} @@ -482,7 +483,7 @@ public: // Constructor ReferenceType (Analysis::NodeMapping mappings, Mutability mut, - std::unique_ptr<Type> type_no_bounds, Location locus, + std::unique_ptr<Type> type_no_bounds, location_t locus, Lifetime lifetime) : TypeNoBounds (mappings, locus), lifetime (std::move (lifetime)), mut (mut), type (std::move (type_no_bounds)) @@ -546,7 +547,7 @@ class ArrayType : public TypeNoBounds public: // Constructor requires pointers for polymorphism ArrayType (Analysis::NodeMapping mappings, std::unique_ptr<Type> type, - std::unique_ptr<Expr> array_size, Location locus) + std::unique_ptr<Expr> array_size, location_t locus) : TypeNoBounds (mappings, locus), elem_type (std::move (type)), size (std::move (array_size)) {} @@ -603,7 +604,7 @@ class SliceType : public TypeNoBounds public: // Constructor requires pointer for polymorphism SliceType (Analysis::NodeMapping mappings, std::unique_ptr<Type> type, - Location locus) + location_t locus) : TypeNoBounds (mappings, locus), elem_type (std::move (type)) {} @@ -668,7 +669,7 @@ protected: } public: - InferredType (Analysis::NodeMapping mappings, Location locus) + InferredType (Analysis::NodeMapping mappings, location_t locus) : TypeNoBounds (mappings, locus) {} @@ -697,11 +698,11 @@ private: ParamKind param_kind; Identifier name; // technically, can be an identifier or '_' - Location locus; + location_t locus; public: MaybeNamedParam (Identifier name, ParamKind param_kind, - std::unique_ptr<Type> param_type, Location locus) + std::unique_ptr<Type> param_type, location_t locus) : param_type (std::move (param_type)), param_kind (param_kind), name (std::move (name)), locus (locus) {} @@ -774,7 +775,7 @@ public: std::vector<LifetimeParam> lifetime_params, FunctionQualifiers qualifiers, std::vector<MaybeNamedParam> named_params, bool is_variadic, - std::unique_ptr<Type> type, Location locus) + std::unique_ptr<Type> type, location_t locus) : TypeNoBounds (mappings, locus), for_lifetimes (std::move (lifetime_params)), function_qualifiers (std::move (qualifiers)), diff --git a/gcc/rust/hir/tree/rust-hir.cc b/gcc/rust/hir/tree/rust-hir.cc index b5e88d4..276c1a7 100644 --- a/gcc/rust/hir/tree/rust-hir.cc +++ b/gcc/rust/hir/tree/rust-hir.cc @@ -2173,7 +2173,7 @@ PathPattern::convert_to_simple_path (bool with_opening_scope_resolution) const } // kind of a HACK to get locus depending on opening scope resolution - Location locus = UNKNOWN_LOCATION; + location_t locus = UNKNOWN_LOCATION; if (with_opening_scope_resolution) { locus = simple_segments[0].get_locus () - 2; // minus 2 chars for :: diff --git a/gcc/rust/hir/tree/rust-hir.h b/gcc/rust/hir/tree/rust-hir.h index 578e126..c5a027a 100644 --- a/gcc/rust/hir/tree/rust-hir.h +++ b/gcc/rust/hir/tree/rust-hir.h @@ -467,7 +467,7 @@ public: virtual Location get_locus () const { return locus; } protected: - Type (Analysis::NodeMapping mappings, Location locus) + Type (Analysis::NodeMapping mappings, location_t locus) : mappings (mappings), locus (locus) {} @@ -475,7 +475,7 @@ protected: virtual Type *clone_type_impl () const = 0; Analysis::NodeMapping mappings; - Location locus; + location_t locus; }; // A type without parentheses? - abstract @@ -489,7 +489,7 @@ public: } protected: - TypeNoBounds (Analysis::NodeMapping mappings, Location locus) + TypeNoBounds (Analysis::NodeMapping mappings, location_t locus) : Type (mappings, locus) {} @@ -544,13 +544,13 @@ class Lifetime : public TypeParamBound private: AST::Lifetime::LifetimeType lifetime_type; std::string lifetime_name; - Location locus; + location_t locus; Analysis::NodeMapping mappings; public: // Constructor Lifetime (Analysis::NodeMapping mapping, AST::Lifetime::LifetimeType type, - std::string name, Location locus) + std::string name, location_t locus) : lifetime_type (type), lifetime_name (std::move (name)), locus (locus), mappings (mapping) {} @@ -654,7 +654,7 @@ class LifetimeParam : public GenericParam // std::unique_ptr<Attribute> outer_attr; AST::Attribute outer_attr; - Location locus; + location_t locus; public: Lifetime get_lifetime () { return lifetime; } @@ -670,7 +670,7 @@ public: // Constructor LifetimeParam (Analysis::NodeMapping mappings, Lifetime lifetime, - Location locus = UNDEF_LOCATION, + location_t locus = UNDEF_LOCATION, std::vector<Lifetime> lifetime_bounds = std::vector<Lifetime> (), AST::Attribute outer_attr = AST::Attribute::create_empty ()) @@ -725,7 +725,7 @@ class ConstGenericParam : public GenericParam public: ConstGenericParam (std::string name, std::unique_ptr<Type> type, std::unique_ptr<Expr> default_expression, - Analysis::NodeMapping mapping, Location locus) + Analysis::NodeMapping mapping, location_t locus) : GenericParam (mapping, GenericKind::CONST), name (std::move (name)), type (std::move (type)), default_expression (std::move (default_expression)), locus (locus) @@ -772,7 +772,7 @@ private: /* Optional - can be a null pointer if there is no default expression */ std::unique_ptr<Expr> default_expression; - Location locus; + location_t locus; }; // Item used in trait declarations - abstract base class diff --git a/gcc/rust/lex/rust-token.h b/gcc/rust/lex/rust-token.h index 30a6e77..3d48610 100644 --- a/gcc/rust/lex/rust-token.h +++ b/gcc/rust/lex/rust-token.h @@ -243,7 +243,7 @@ private: // Token kind. TokenId token_id; // Token location. - Location locus; + location_t locus; // Associated text (if any) of token. std::unique_ptr<std::string> str; // TODO: maybe remove issues and just store std::string as value? @@ -300,21 +300,21 @@ public: * private constructor */ // Makes and returns a new TokenPtr (with null string). - static TokenPtr make (TokenId token_id, Location locus) + static TokenPtr make (TokenId token_id, location_t locus) { // return std::make_shared<Token> (token_id, locus); return TokenPtr (new Token (token_id, locus)); } // Makes and returns a new TokenPtr of type IDENTIFIER. - static TokenPtr make_identifier (Location locus, std::string &&str) + static TokenPtr make_identifier (location_t locus, std::string &&str) { // return std::make_shared<Token> (IDENTIFIER, locus, str); return TokenPtr (new Token (IDENTIFIER, locus, std::move (str))); } // Makes and returns a new TokenPtr of type INT_LITERAL. - static TokenPtr make_int (Location locus, std::string &&str, + static TokenPtr make_int (location_t locus, std::string &&str, PrimitiveCoreType type_hint = CORETYPE_UNKNOWN) { // return std::make_shared<Token> (INT_LITERAL, locus, str, type_hint); @@ -323,7 +323,7 @@ public: } // Makes and returns a new TokenPtr of type FLOAT_LITERAL. - static TokenPtr make_float (Location locus, std::string &&str, + static TokenPtr make_float (location_t locus, std::string &&str, PrimitiveCoreType type_hint = CORETYPE_UNKNOWN) { // return std::make_shared<Token> (FLOAT_LITERAL, locus, str, type_hint); @@ -332,7 +332,7 @@ public: } // Makes and returns a new TokenPtr of type STRING_LITERAL. - static TokenPtr make_string (Location locus, std::string &&str) + static TokenPtr make_string (location_t locus, std::string &&str) { // return std::make_shared<Token> (STRING_LITERAL, locus, str, // CORETYPE_STR); @@ -341,40 +341,40 @@ public: } // Makes and returns a new TokenPtr of type CHAR_LITERAL. - static TokenPtr make_char (Location locus, Codepoint char_lit) + static TokenPtr make_char (location_t locus, Codepoint char_lit) { // return std::make_shared<Token> (CHAR_LITERAL, locus, char_lit); return TokenPtr (new Token (CHAR_LITERAL, locus, char_lit)); } // Makes and returns a new TokenPtr of type BYTE_CHAR_LITERAL. - static TokenPtr make_byte_char (Location locus, char byte_char) + static TokenPtr make_byte_char (location_t locus, char byte_char) { // return std::make_shared<Token> (BYTE_CHAR_LITERAL, locus, byte_char); return TokenPtr (new Token (BYTE_CHAR_LITERAL, locus, byte_char)); } // Makes and returns a new TokenPtr of type BYTE_STRING_LITERAL (fix). - static TokenPtr make_byte_string (Location locus, std::string &&str) + static TokenPtr make_byte_string (location_t locus, std::string &&str) { // return std::make_shared<Token> (BYTE_STRING_LITERAL, locus, str); return TokenPtr (new Token (BYTE_STRING_LITERAL, locus, std::move (str))); } // Makes and returns a new TokenPtr of type INNER_DOC_COMMENT. - static TokenPtr make_inner_doc_comment (Location locus, std::string &&str) + static TokenPtr make_inner_doc_comment (location_t locus, std::string &&str) { return TokenPtr (new Token (INNER_DOC_COMMENT, locus, std::move (str))); } // Makes and returns a new TokenPtr of type OUTER_DOC_COMMENT. - static TokenPtr make_outer_doc_comment (Location locus, std::string &&str) + static TokenPtr make_outer_doc_comment (location_t locus, std::string &&str) { return TokenPtr (new Token (OUTER_DOC_COMMENT, locus, std::move (str))); } // Makes and returns a new TokenPtr of type LIFETIME. - static TokenPtr make_lifetime (Location locus, std::string &&str) + static TokenPtr make_lifetime (location_t locus, std::string &&str) { // return std::make_shared<Token> (LIFETIME, locus, str); return TokenPtr (new Token (LIFETIME, locus, std::move (str))); @@ -387,7 +387,7 @@ public: Location get_locus () const { return locus; } // Set location of the token. - void set_locus (Location locus) { this->locus = locus; } + void set_locus (location_t locus) { this->locus = locus; } // Gets string description of the token. const std::string & diff --git a/gcc/rust/metadata/rust-extern-crate.cc b/gcc/rust/metadata/rust-extern-crate.cc index 8a76bec..be4f393 100644 --- a/gcc/rust/metadata/rust-extern-crate.cc +++ b/gcc/rust/metadata/rust-extern-crate.cc @@ -36,7 +36,7 @@ ExternCrate::ok () const } bool -ExternCrate::load (Location locus) +ExternCrate::load (location_t locus) { // match header import_stream.require_bytes (locus, Metadata::kMagicHeader, @@ -155,7 +155,7 @@ ExternCrate::get_metadata () const // Turn a string into a integer with appropriate error handling. bool -ExternCrate::string_to_int (Location locus, const std::string &s, +ExternCrate::string_to_int (location_t locus, const std::string &s, bool is_neg_ok, int *ret) { char *end; diff --git a/gcc/rust/metadata/rust-extern-crate.h b/gcc/rust/metadata/rust-extern-crate.h index c017653..31dbbf8 100644 --- a/gcc/rust/metadata/rust-extern-crate.h +++ b/gcc/rust/metadata/rust-extern-crate.h @@ -33,13 +33,13 @@ public: bool ok () const; - bool load (Location locus); + bool load (location_t locus); const std::string &get_crate_name () const; const std::string &get_metadata () const; - static bool string_to_int (Location locus, const std::string &s, + static bool string_to_int (location_t locus, const std::string &s, bool is_neg_ok, int *ret); private: diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 6dfc2b0..21310e3 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -489,7 +489,7 @@ std::tuple<AST::SimplePath, std::unique_ptr<AST::AttrInput>, Location> Parser<ManagedTokenSource>::parse_doc_comment () { const_TokenPtr token = lexer.peek_token (); - Location locus = token->get_locus (); + location_t locus = token->get_locus (); AST::SimplePathSegment segment ("doc", locus); std::vector<AST::SimplePathSegment> segments; segments.push_back (std::move (segment)); @@ -559,7 +559,7 @@ template <typename ManagedTokenSource> std::tuple<AST::SimplePath, std::unique_ptr<AST::AttrInput>, Location> Parser<ManagedTokenSource>::parse_attribute_body () { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); AST::SimplePath attr_path = parse_simple_path (); // ensure path is valid to parse attribute input @@ -606,7 +606,7 @@ AST::SimplePath Parser<ManagedTokenSource>::parse_simple_path () { bool has_opening_scope_resolution = false; - Location locus = UNKNOWN_LOCATION; + location_t locus = UNKNOWN_LOCATION; // don't parse anything if not a path upfront if (!is_simple_path_segment (lexer.peek_token ()->get_id ()) @@ -1605,7 +1605,7 @@ Parser<ManagedTokenSource>::parse_decl_macro_def (AST::Visibility vis, // e.g. `macro foo($e:expr) {}` // parse macro matcher - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); AST::MacroMatcher matcher = parse_macro_matcher (); if (matcher.is_error ()) return nullptr; @@ -1890,7 +1890,7 @@ template <typename ManagedTokenSource> AST::MacroRule Parser<ManagedTokenSource>::parse_macro_rule () { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); // parse macro matcher AST::MacroMatcher matcher = parse_macro_matcher (); @@ -1924,7 +1924,7 @@ Parser<ManagedTokenSource>::parse_macro_matcher () // Map tokens to DelimType const_TokenPtr t = lexer.peek_token (); - Location locus = t->get_locus (); + location_t locus = t->get_locus (); switch (t->get_id ()) { case LEFT_PAREN: @@ -2403,7 +2403,7 @@ std::unique_ptr<AST::Module> Parser<ManagedTokenSource>::parse_module (AST::Visibility vis, AST::AttrVec outer_attrs) { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); skip_token (MOD); const_TokenPtr module_name = expect_token (IDENTIFIER); @@ -2500,7 +2500,7 @@ std::unique_ptr<AST::ExternCrate> Parser<ManagedTokenSource>::parse_extern_crate (AST::Visibility vis, AST::AttrVec outer_attrs) { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); if (!skip_token (EXTERN_TOK)) { skip_after_semicolon (); @@ -2596,7 +2596,7 @@ std::unique_ptr<AST::UseDeclaration> Parser<ManagedTokenSource>::parse_use_decl (AST::Visibility vis, AST::AttrVec outer_attrs) { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); if (!skip_token (USE)) { skip_after_semicolon (); @@ -2656,7 +2656,7 @@ Parser<ManagedTokenSource>::parse_use_tree () // TODO: I think this function is too complex, probably should split it - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); // bool has_path = false; AST::SimplePath path = parse_simple_path (); @@ -2869,7 +2869,7 @@ std::unique_ptr<AST::Function> Parser<ManagedTokenSource>::parse_function (AST::Visibility vis, AST::AttrVec outer_attrs) { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); // Get qualifiers for function if they exist AST::FunctionQualifiers qualifiers = parse_function_qualifiers (); @@ -2945,7 +2945,7 @@ Parser<ManagedTokenSource>::parse_function_qualifiers () // Check in order of const, unsafe, then extern const_TokenPtr t = lexer.peek_token (); - Location locus = t->get_locus (); + location_t locus = t->get_locus (); switch (t->get_id ()) { case CONST: @@ -3604,7 +3604,7 @@ Parser<ManagedTokenSource>::parse_function_param () AST::AttrVec outer_attrs = parse_outer_attributes (); // TODO: should saved location be at start of outer attributes or pattern? - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); std::unique_ptr<AST::Pattern> param_pattern = parse_pattern (); // create error function param if it doesn't exist @@ -3737,7 +3737,7 @@ Parser<ManagedTokenSource>::parse_lifetime_where_clause_item () std::vector<AST::Lifetime> lifetime_bounds = parse_lifetime_bounds (); // TODO: have end token passed in? - Location locus = lifetime.get_locus (); + location_t locus = lifetime.get_locus (); return std::unique_ptr<AST::LifetimeWhereClauseItem> ( new AST::LifetimeWhereClauseItem (std::move (lifetime), @@ -3770,7 +3770,7 @@ Parser<ManagedTokenSource>::parse_type_bound_where_clause_item () std::vector<std::unique_ptr<AST::TypeParamBound>> type_param_bounds = parse_type_param_bounds (); - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); return std::unique_ptr<AST::TypeBoundWhereClauseItem> ( new AST::TypeBoundWhereClauseItem (std::move (for_lifetimes), @@ -3939,7 +3939,7 @@ Parser<ManagedTokenSource>::parse_trait_bound () bool has_parens = false; bool has_question_mark = false; - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); // handle trait bound being in parentheses if (lexer.peek_token ()->get_id () == LEFT_PAREN) @@ -4065,7 +4065,7 @@ template <typename ManagedTokenSource> AST::Lifetime Parser<ManagedTokenSource>::lifetime_from_token (const_TokenPtr tok) { - Location locus = tok->get_locus (); + location_t locus = tok->get_locus (); std::string lifetime_ident = tok->get_str (); if (lifetime_ident == "'static") @@ -4088,7 +4088,7 @@ std::unique_ptr<AST::ExternalTypeItem> Parser<ManagedTokenSource>::parse_external_type_item (AST::Visibility vis, AST::AttrVec outer_attrs) { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); skip_token (TYPE); const_TokenPtr alias_name_tok = expect_token (IDENTIFIER); @@ -4116,7 +4116,7 @@ std::unique_ptr<AST::TypeAlias> Parser<ManagedTokenSource>::parse_type_alias (AST::Visibility vis, AST::AttrVec outer_attrs) { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); skip_token (TYPE); // TODO: use this token for identifier when finished that @@ -4176,7 +4176,7 @@ Parser<ManagedTokenSource>::parse_struct (AST::Visibility vis, * struct_fields? '}' | ';' ) */ /* Tuple struct <- 'struct' IDENTIFIER generic_params? '(' tuple_fields? ')' * where_clause? ';' */ - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); skip_token (STRUCT_TOK); // parse struct name @@ -4376,7 +4376,7 @@ Parser<ManagedTokenSource>::parse_struct_field () // parse visibility, if it exists AST::Visibility vis = parse_visibility (); - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); // parse field name const_TokenPtr field_name_tok = lexer.peek_token (); @@ -4479,7 +4479,7 @@ Parser<ManagedTokenSource>::parse_tuple_field () // parse visibility if it exists AST::Visibility vis = parse_visibility (); - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); // parse type, which is required std::unique_ptr<AST::Type> field_type = parse_type (); @@ -4504,7 +4504,7 @@ std::unique_ptr<AST::Enum> Parser<ManagedTokenSource>::parse_enum (AST::Visibility vis, AST::AttrVec outer_attrs) { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); skip_token (ENUM_TOK); // parse enum name @@ -4717,7 +4717,7 @@ Parser<ManagedTokenSource>::parse_union (AST::Visibility vis, * item switch) */ const_TokenPtr union_keyword = expect_token (IDENTIFIER); rust_assert (union_keyword->get_str () == "union"); - Location locus = union_keyword->get_locus (); + location_t locus = union_keyword->get_locus (); // parse actual union name const_TokenPtr union_name_tok = expect_token (IDENTIFIER); @@ -4765,7 +4765,7 @@ std::unique_ptr<AST::ConstantItem> Parser<ManagedTokenSource>::parse_const_item (AST::Visibility vis, AST::AttrVec outer_attrs) { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); skip_token (CONST); /* get constant identifier - this is either a proper identifier or the _ @@ -4829,7 +4829,7 @@ std::unique_ptr<AST::StaticItem> Parser<ManagedTokenSource>::parse_static_item (AST::Visibility vis, AST::AttrVec outer_attrs) { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); skip_token (STATIC_TOK); // determine whether static item is mutable @@ -4882,7 +4882,7 @@ std::unique_ptr<AST::Trait> Parser<ManagedTokenSource>::parse_trait (AST::Visibility vis, AST::AttrVec outer_attrs) { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); bool is_unsafe = false; bool is_auto_trait = false; @@ -5154,7 +5154,7 @@ template <typename ManagedTokenSource> std::unique_ptr<AST::TraitItemType> Parser<ManagedTokenSource>::parse_trait_type (AST::AttrVec outer_attrs) { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); skip_token (TYPE); const_TokenPtr ident_tok = expect_token (IDENTIFIER); @@ -5192,7 +5192,7 @@ template <typename ManagedTokenSource> std::unique_ptr<AST::TraitItemConst> Parser<ManagedTokenSource>::parse_trait_const (AST::AttrVec outer_attrs) { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); skip_token (CONST); // parse constant item name @@ -5243,7 +5243,7 @@ Parser<ManagedTokenSource>::parse_impl (AST::Visibility vis, /* Note that only trait impls are allowed to be unsafe. So if unsafe, it * must be a trait impl. However, this isn't enough for full disambiguation, * so don't branch here. */ - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); bool is_unsafe = false; if (lexer.peek_token ()->get_id () == UNSAFE) { @@ -5556,7 +5556,7 @@ std::unique_ptr<AST::InherentImplItem> Parser<ManagedTokenSource>::parse_inherent_impl_function_or_method ( AST::Visibility vis, AST::AttrVec outer_attrs) { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); // parse function or method qualifiers AST::FunctionQualifiers qualifiers = parse_function_qualifiers (); @@ -5741,7 +5741,7 @@ Parser<ManagedTokenSource>::parse_trait_impl_function_or_method ( // this shares virtually all logic with // parse_inherent_impl_function_or_method // - template? - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); auto is_default = false; auto t = lexer.peek_token (); @@ -5900,7 +5900,7 @@ std::unique_ptr<AST::ExternBlock> Parser<ManagedTokenSource>::parse_extern_block (AST::Visibility vis, AST::AttrVec outer_attrs) { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); skip_token (EXTERN_TOK); // detect optional abi name @@ -5965,7 +5965,7 @@ Parser<ManagedTokenSource>::parse_external_item () // parse optional outer attributes AST::AttrVec outer_attrs = parse_outer_attributes (); - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); // parse optional visibility AST::Visibility vis = parse_visibility (); @@ -6286,7 +6286,7 @@ std::unique_ptr<AST::LetStmt> Parser<ManagedTokenSource>::parse_let_stmt (AST::AttrVec outer_attrs, ParseRestrictions restrictions) { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); skip_token (LET); // parse pattern (required) @@ -6362,7 +6362,7 @@ AST::TypePath Parser<ManagedTokenSource>::parse_type_path () { bool has_opening_scope_resolution = false; - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); if (lexer.peek_token ()->get_id () == SCOPE_RESOLUTION) { has_opening_scope_resolution = true; @@ -6509,7 +6509,7 @@ Parser<ManagedTokenSource>::parse_path_generic_args () std::vector<AST::Lifetime> lifetime_args; const_TokenPtr t = lexer.peek_token (); - Location locus = t->get_locus (); + location_t locus = t->get_locus (); while (!is_right_angle_tok (t->get_id ())) { AST::Lifetime lifetime = parse_lifetime (); @@ -6646,7 +6646,7 @@ template <typename ManagedTokenSource> std::unique_ptr<AST::TypePathSegment> Parser<ManagedTokenSource>::parse_type_path_segment () { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); // parse ident segment part AST::PathIdentSegment ident_segment = parse_path_ident_segment (); if (ident_segment.is_error ()) @@ -6764,7 +6764,7 @@ template <typename ManagedTokenSource> AST::PathInExpression Parser<ManagedTokenSource>::parse_path_in_expression () { - Location locus = UNKNOWN_LOCATION; + location_t locus = UNKNOWN_LOCATION; bool has_opening_scope_resolution = false; if (lexer.peek_token ()->get_id () == SCOPE_RESOLUTION) { @@ -6829,7 +6829,7 @@ template <typename ManagedTokenSource> AST::PathExprSegment Parser<ManagedTokenSource>::parse_path_expr_segment () { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); // parse ident segment AST::PathIdentSegment ident = parse_path_ident_segment (); if (ident.is_error ()) @@ -6883,7 +6883,7 @@ Parser<ManagedTokenSource>::parse_qualified_path_in_expression ( // TODO: should this create a parse error? return AST::QualifiedPathInExpression::create_error (); } - Location locus = qual_path_type.get_locus (); + location_t locus = qual_path_type.get_locus (); // parse path segments std::vector<AST::PathExprSegment> segments; @@ -6946,7 +6946,7 @@ AST::QualifiedPathType Parser<ManagedTokenSource>::parse_qualified_path_type ( Location pratt_parsed_loc) { - Location locus = pratt_parsed_loc; + location_t locus = pratt_parsed_loc; /* TODO: should this actually be error? is there anywhere where this could * be valid? */ if (locus == UNKNOWN_LOCATION) @@ -7010,7 +7010,7 @@ template <typename ManagedTokenSource> AST::QualifiedPathInType Parser<ManagedTokenSource>::parse_qualified_path_in_type () { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); // parse the qualified path type (required) AST::QualifiedPathType qual_path_type = parse_qualified_path_type (); if (qual_path_type.is_error ()) @@ -7081,7 +7081,7 @@ Parser<ManagedTokenSource>::parse_self_param () bool has_reference = false; AST::Lifetime lifetime = AST::Lifetime::error (); - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); // test if self is a reference parameter if (lexer.peek_token ()->get_id () == AMP) @@ -7175,7 +7175,7 @@ template <typename ManagedTokenSource> AST::Method Parser<ManagedTokenSource>::parse_method () { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); /* Note: as a result of the above, this will not attempt to disambiguate a * function parse qualifiers */ AST::FunctionQualifiers qualifiers = parse_function_qualifiers (); @@ -7267,7 +7267,7 @@ std::unique_ptr<AST::Stmt> Parser<ManagedTokenSource>::parse_expr_stmt (AST::AttrVec outer_attrs, ParseRestrictions restrictions) { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); std::unique_ptr<AST::Expr> expr; @@ -7380,7 +7380,7 @@ std::unique_ptr<AST::BlockExpr> Parser<ManagedTokenSource>::parse_block_expr (AST::AttrVec outer_attrs, Location pratt_parsed_loc) { - Location locus = pratt_parsed_loc; + location_t locus = pratt_parsed_loc; if (locus == UNKNOWN_LOCATION) { locus = lexer.peek_token ()->get_locus (); @@ -7454,7 +7454,7 @@ template <typename ManagedTokenSource> std::unique_ptr<AST::GroupedExpr> Parser<ManagedTokenSource>::parse_grouped_expr (AST::AttrVec outer_attrs) { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); skip_token (LEFT_PAREN); AST::AttrVec inner_attrs = parse_inner_attributes (); @@ -7484,7 +7484,7 @@ template <typename ManagedTokenSource> std::unique_ptr<AST::ClosureExpr> Parser<ManagedTokenSource>::parse_closure_expr (AST::AttrVec outer_attrs) { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); // detect optional "move" bool has_move = false; if (lexer.peek_token ()->get_id () == MOVE) @@ -7684,7 +7684,7 @@ std::unique_ptr<AST::ReturnExpr> Parser<ManagedTokenSource>::parse_return_expr (AST::AttrVec outer_attrs, Location pratt_parsed_loc) { - Location locus = pratt_parsed_loc; + location_t locus = pratt_parsed_loc; if (locus == UNKNOWN_LOCATION) { locus = lexer.peek_token ()->get_locus (); @@ -7709,7 +7709,7 @@ std::unique_ptr<AST::BreakExpr> Parser<ManagedTokenSource>::parse_break_expr (AST::AttrVec outer_attrs, Location pratt_parsed_loc) { - Location locus = pratt_parsed_loc; + location_t locus = pratt_parsed_loc; if (locus == UNKNOWN_LOCATION) { locus = lexer.peek_token ()->get_locus (); @@ -7740,7 +7740,7 @@ std::unique_ptr<AST::ContinueExpr> Parser<ManagedTokenSource>::parse_continue_expr (AST::AttrVec outer_attrs, Location pratt_parsed_loc) { - Location locus = pratt_parsed_loc; + location_t locus = pratt_parsed_loc; if (locus == UNKNOWN_LOCATION) { locus = lexer.peek_token ()->get_locus (); @@ -7791,7 +7791,7 @@ Parser<ManagedTokenSource>::parse_if_expr (AST::AttrVec outer_attrs, Location pratt_parsed_loc) { // TODO: make having outer attributes an error? - Location locus = pratt_parsed_loc; + location_t locus = pratt_parsed_loc; if (locus == UNKNOWN_LOCATION) { locus = lexer.peek_token ()->get_locus (); @@ -7949,7 +7949,7 @@ Parser<ManagedTokenSource>::parse_if_let_expr (AST::AttrVec outer_attrs, Location pratt_parsed_loc) { // TODO: make having outer attributes an error? - Location locus = pratt_parsed_loc; + location_t locus = pratt_parsed_loc; if (locus == UNKNOWN_LOCATION) { locus = lexer.peek_token ()->get_locus (); @@ -8135,7 +8135,7 @@ Parser<ManagedTokenSource>::parse_loop_expr (AST::AttrVec outer_attrs, AST::LoopLabel label, Location pratt_parsed_loc) { - Location locus = pratt_parsed_loc; + location_t locus = pratt_parsed_loc; if (locus == UNKNOWN_LOCATION) { if (label.is_error ()) @@ -8179,7 +8179,7 @@ Parser<ManagedTokenSource>::parse_while_loop_expr (AST::AttrVec outer_attrs, AST::LoopLabel label, Location pratt_parsed_loc) { - Location locus = pratt_parsed_loc; + location_t locus = pratt_parsed_loc; if (locus == UNKNOWN_LOCATION) { if (label.is_error ()) @@ -8251,7 +8251,7 @@ std::unique_ptr<AST::WhileLetLoopExpr> Parser<ManagedTokenSource>::parse_while_let_loop_expr (AST::AttrVec outer_attrs, AST::LoopLabel label) { - Location locus = UNKNOWN_LOCATION; + location_t locus = UNKNOWN_LOCATION; if (label.is_error ()) locus = lexer.peek_token ()->get_locus (); else @@ -8325,7 +8325,7 @@ std::unique_ptr<AST::ForLoopExpr> Parser<ManagedTokenSource>::parse_for_loop_expr (AST::AttrVec outer_attrs, AST::LoopLabel label) { - Location locus = UNKNOWN_LOCATION; + location_t locus = UNKNOWN_LOCATION; if (label.is_error ()) locus = lexer.peek_token ()->get_locus (); else @@ -8455,7 +8455,7 @@ std::unique_ptr<AST::MatchExpr> Parser<ManagedTokenSource>::parse_match_expr (AST::AttrVec outer_attrs, Location pratt_parsed_loc) { - Location locus = pratt_parsed_loc; + location_t locus = pratt_parsed_loc; if (locus == UNKNOWN_LOCATION) { locus = lexer.peek_token ()->get_locus (); @@ -8706,7 +8706,7 @@ template <typename ManagedTokenSource> std::unique_ptr<AST::AsyncBlockExpr> Parser<ManagedTokenSource>::parse_async_block_expr (AST::AttrVec outer_attrs) { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); skip_token (ASYNC); // detect optional move token @@ -8741,7 +8741,7 @@ std::unique_ptr<AST::UnsafeBlockExpr> Parser<ManagedTokenSource>::parse_unsafe_block_expr (AST::AttrVec outer_attrs, Location pratt_parsed_loc) { - Location locus = pratt_parsed_loc; + location_t locus = pratt_parsed_loc; if (locus == UNKNOWN_LOCATION) { locus = lexer.peek_token ()->get_locus (); @@ -8772,7 +8772,7 @@ std::unique_ptr<AST::ArrayExpr> Parser<ManagedTokenSource>::parse_array_expr (AST::AttrVec outer_attrs, Location pratt_parsed_loc) { - Location locus = pratt_parsed_loc; + location_t locus = pratt_parsed_loc; if (locus == UNKNOWN_LOCATION) { locus = lexer.peek_token ()->get_locus (); @@ -8958,7 +8958,7 @@ Parser<ManagedTokenSource>::parse_grouped_or_tuple_expr ( AST::AttrVec outer_attrs, Location pratt_parsed_loc) { // adjustment to allow Pratt parsing to reuse function without copy-paste - Location locus = pratt_parsed_loc; + location_t locus = pratt_parsed_loc; if (locus == UNKNOWN_LOCATION) { locus = lexer.peek_token ()->get_locus (); @@ -9178,7 +9178,7 @@ Parser<ManagedTokenSource>::parse_type (bool save_errors) return nullptr; } - Location locus = path.get_locus (); + location_t locus = path.get_locus (); // branch on next token t = lexer.peek_token (); @@ -9289,7 +9289,7 @@ Parser<ManagedTokenSource>::parse_type (bool save_errors) return nullptr; } - Location locus = t->get_locus (); + location_t locus = t->get_locus (); // short cut if next token isn't '+' t = lexer.peek_token (); @@ -9787,7 +9787,7 @@ Parser<ManagedTokenSource>::parse_bare_function_type ( template <typename ManagedTokenSource> std::unique_ptr<AST::ReferenceType> -Parser<ManagedTokenSource>::parse_reference_type_inner (Location locus) +Parser<ManagedTokenSource>::parse_reference_type_inner (location_t locus) { // parse optional lifetime AST::Lifetime lifetime = AST::Lifetime::error (); @@ -9855,7 +9855,7 @@ template <typename ManagedTokenSource> std::unique_ptr<AST::RawPointerType> Parser<ManagedTokenSource>::parse_raw_pointer_type () { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); skip_token (ASTERISK); AST::RawPointerType::PointerType kind = AST::RawPointerType::CONST; @@ -9901,7 +9901,7 @@ template <typename ManagedTokenSource> std::unique_ptr<AST::TypeNoBounds> Parser<ManagedTokenSource>::parse_slice_or_array_type () { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); skip_token (LEFT_SQUARE); // parse inner type (required) @@ -10039,7 +10039,7 @@ Parser<ManagedTokenSource>::parse_type_no_bounds () return nullptr; } - Location locus = path.get_locus (); + location_t locus = path.get_locus (); // branch on next token t = lexer.peek_token (); @@ -10115,7 +10115,7 @@ Parser<ManagedTokenSource>::parse_type_no_bounds () return nullptr; } - Location locus = t->get_locus (); + location_t locus = t->get_locus (); // ensure not a trait with multiple bounds t = lexer.peek_token (); @@ -10169,7 +10169,7 @@ Parser<ManagedTokenSource>::parse_type_no_bounds () return nullptr; } - Location locus = t->get_locus (); + location_t locus = t->get_locus (); // detect error with plus as next token t = lexer.peek_token (); @@ -11067,7 +11067,7 @@ template <typename ManagedTokenSource> std::unique_ptr<AST::IdentifierPattern> Parser<ManagedTokenSource>::parse_identifier_pattern () { - Location locus = lexer.peek_token ()->get_locus (); + location_t locus = lexer.peek_token ()->get_locus (); bool has_ref = false; if (lexer.peek_token ()->get_id () == REF) @@ -12991,7 +12991,7 @@ Parser<ManagedTokenSource>::parse_arithmetic_or_logical_expr ( return nullptr; // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::ArithmeticOrLogicalExpr> ( new AST::ArithmeticOrLogicalExpr (std::move (left), std::move (right), @@ -13012,7 +13012,7 @@ Parser<ManagedTokenSource>::parse_binary_plus_expr ( return nullptr; // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::ArithmeticOrLogicalExpr> ( new AST::ArithmeticOrLogicalExpr (std::move (left), std::move (right), @@ -13033,7 +13033,7 @@ Parser<ManagedTokenSource>::parse_binary_minus_expr ( return nullptr; // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::ArithmeticOrLogicalExpr> ( new AST::ArithmeticOrLogicalExpr (std::move (left), std::move (right), @@ -13055,7 +13055,7 @@ Parser<ManagedTokenSource>::parse_binary_mult_expr ( return nullptr; // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::ArithmeticOrLogicalExpr> ( new AST::ArithmeticOrLogicalExpr (std::move (left), std::move (right), @@ -13077,7 +13077,7 @@ Parser<ManagedTokenSource>::parse_binary_div_expr ( return nullptr; // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::ArithmeticOrLogicalExpr> ( new AST::ArithmeticOrLogicalExpr (std::move (left), std::move (right), @@ -13099,7 +13099,7 @@ Parser<ManagedTokenSource>::parse_binary_mod_expr ( return nullptr; // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::ArithmeticOrLogicalExpr> ( new AST::ArithmeticOrLogicalExpr (std::move (left), std::move (right), @@ -13122,7 +13122,7 @@ Parser<ManagedTokenSource>::parse_bitwise_and_expr ( return nullptr; // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::ArithmeticOrLogicalExpr> ( new AST::ArithmeticOrLogicalExpr (std::move (left), std::move (right), @@ -13145,7 +13145,7 @@ Parser<ManagedTokenSource>::parse_bitwise_or_expr ( return nullptr; // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::ArithmeticOrLogicalExpr> ( new AST::ArithmeticOrLogicalExpr (std::move (left), std::move (right), @@ -13168,7 +13168,7 @@ Parser<ManagedTokenSource>::parse_bitwise_xor_expr ( return nullptr; // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::ArithmeticOrLogicalExpr> ( new AST::ArithmeticOrLogicalExpr (std::move (left), std::move (right), @@ -13190,7 +13190,7 @@ Parser<ManagedTokenSource>::parse_left_shift_expr ( return nullptr; // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::ArithmeticOrLogicalExpr> ( new AST::ArithmeticOrLogicalExpr (std::move (left), std::move (right), @@ -13212,7 +13212,7 @@ Parser<ManagedTokenSource>::parse_right_shift_expr ( return nullptr; // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::ArithmeticOrLogicalExpr> ( new AST::ArithmeticOrLogicalExpr (std::move (left), std::move (right), @@ -13264,7 +13264,7 @@ Parser<ManagedTokenSource>::parse_comparison_expr ( return nullptr; // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::ComparisonExpr> ( new AST::ComparisonExpr (std::move (left), std::move (right), expr_type, @@ -13285,7 +13285,7 @@ Parser<ManagedTokenSource>::parse_binary_equal_expr ( return nullptr; // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::ComparisonExpr> ( new AST::ComparisonExpr (std::move (left), std::move (right), @@ -13306,7 +13306,7 @@ Parser<ManagedTokenSource>::parse_binary_not_equal_expr ( return nullptr; // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::ComparisonExpr> ( new AST::ComparisonExpr (std::move (left), std::move (right), @@ -13327,7 +13327,7 @@ Parser<ManagedTokenSource>::parse_binary_greater_than_expr ( return nullptr; // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::ComparisonExpr> ( new AST::ComparisonExpr (std::move (left), std::move (right), @@ -13348,7 +13348,7 @@ Parser<ManagedTokenSource>::parse_binary_less_than_expr ( return nullptr; // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::ComparisonExpr> ( new AST::ComparisonExpr (std::move (left), std::move (right), @@ -13369,7 +13369,7 @@ Parser<ManagedTokenSource>::parse_binary_greater_equal_expr ( return nullptr; // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::ComparisonExpr> ( new AST::ComparisonExpr (std::move (left), std::move (right), @@ -13390,7 +13390,7 @@ Parser<ManagedTokenSource>::parse_binary_less_equal_expr ( return nullptr; // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::ComparisonExpr> ( new AST::ComparisonExpr (std::move (left), std::move (right), @@ -13411,7 +13411,7 @@ Parser<ManagedTokenSource>::parse_lazy_or_expr ( return nullptr; // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::LazyBooleanExpr> ( new AST::LazyBooleanExpr (std::move (left), std::move (right), @@ -13432,7 +13432,7 @@ Parser<ManagedTokenSource>::parse_lazy_and_expr ( return nullptr; // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::LazyBooleanExpr> ( new AST::LazyBooleanExpr (std::move (left), std::move (right), @@ -13454,7 +13454,7 @@ Parser<ManagedTokenSource>::parse_type_cast_expr ( // FIXME: how do I get precedence put in here? // TODO: check types. actually, do so during semantic analysis - Location locus = expr_to_cast->get_locus (); + location_t locus = expr_to_cast->get_locus (); return std::unique_ptr<AST::TypeCastExpr> ( new AST::TypeCastExpr (std::move (expr_to_cast), std::move (type), locus)); @@ -13475,7 +13475,7 @@ Parser<ManagedTokenSource>::parse_assig_expr ( // FIXME: ensure right-associativity for this - 'LBP - 1' may do this? // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::AssignmentExpr> ( new AST::AssignmentExpr (std::move (left), std::move (right), @@ -13535,7 +13535,7 @@ Parser<ManagedTokenSource>::parse_compound_assignment_expr ( // FIXME: ensure right-associativity for this - 'LBP - 1' may do this? // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::CompoundAssignmentExpr> ( new AST::CompoundAssignmentExpr (std::move (left), std::move (right), @@ -13557,7 +13557,7 @@ Parser<ManagedTokenSource>::parse_plus_assig_expr ( // FIXME: ensure right-associativity for this - 'LBP - 1' may do this? // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::CompoundAssignmentExpr> ( new AST::CompoundAssignmentExpr (std::move (left), std::move (right), @@ -13579,7 +13579,7 @@ Parser<ManagedTokenSource>::parse_minus_assig_expr ( // FIXME: ensure right-associativity for this - 'LBP - 1' may do this? // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::CompoundAssignmentExpr> ( new AST::CompoundAssignmentExpr (std::move (left), std::move (right), @@ -13602,7 +13602,7 @@ Parser<ManagedTokenSource>::parse_mult_assig_expr ( // FIXME: ensure right-associativity for this - 'LBP - 1' may do this? // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::CompoundAssignmentExpr> ( new AST::CompoundAssignmentExpr (std::move (left), std::move (right), @@ -13625,7 +13625,7 @@ Parser<ManagedTokenSource>::parse_div_assig_expr ( // FIXME: ensure right-associativity for this - 'LBP - 1' may do this? // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::CompoundAssignmentExpr> ( new AST::CompoundAssignmentExpr (std::move (left), std::move (right), @@ -13648,7 +13648,7 @@ Parser<ManagedTokenSource>::parse_mod_assig_expr ( // FIXME: ensure right-associativity for this - 'LBP - 1' may do this? // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::CompoundAssignmentExpr> ( new AST::CompoundAssignmentExpr (std::move (left), std::move (right), @@ -13671,7 +13671,7 @@ Parser<ManagedTokenSource>::parse_and_assig_expr ( // FIXME: ensure right-associativity for this - 'LBP - 1' may do this? // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::CompoundAssignmentExpr> ( new AST::CompoundAssignmentExpr (std::move (left), std::move (right), @@ -13694,7 +13694,7 @@ Parser<ManagedTokenSource>::parse_or_assig_expr ( // FIXME: ensure right-associativity for this - 'LBP - 1' may do this? // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::CompoundAssignmentExpr> ( new AST::CompoundAssignmentExpr (std::move (left), std::move (right), @@ -13717,7 +13717,7 @@ Parser<ManagedTokenSource>::parse_xor_assig_expr ( // FIXME: ensure right-associativity for this - 'LBP - 1' may do this? // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::CompoundAssignmentExpr> ( new AST::CompoundAssignmentExpr (std::move (left), std::move (right), @@ -13740,7 +13740,7 @@ Parser<ManagedTokenSource>::parse_left_shift_assig_expr ( // FIXME: ensure right-associativity for this - 'LBP - 1' may do this? // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::CompoundAssignmentExpr> ( new AST::CompoundAssignmentExpr (std::move (left), std::move (right), @@ -13763,7 +13763,7 @@ Parser<ManagedTokenSource>::parse_right_shift_assig_expr ( // FIXME: ensure right-associativity for this - 'LBP - 1' may do this? // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::CompoundAssignmentExpr> ( new AST::CompoundAssignmentExpr (std::move (left), std::move (right), @@ -13792,7 +13792,7 @@ Parser<ManagedTokenSource>::parse_await_expr ( } // TODO: check inside async block in semantic analysis - Location locus = expr_to_await->get_locus (); + location_t locus = expr_to_await->get_locus (); return std::unique_ptr<AST::AwaitExpr> ( new AST::AwaitExpr (std::move (expr_to_await), std::move (outer_attrs), @@ -13815,7 +13815,7 @@ Parser<ManagedTokenSource>::parse_led_range_exclusive_expr ( std::unique_ptr<AST::Expr> right = parse_expr (LBP_DOT_DOT, AST::AttrVec (), restrictions); - Location locus = left->get_locus (); + location_t locus = left->get_locus (); if (right == nullptr) { @@ -13846,7 +13846,7 @@ Parser<ManagedTokenSource>::parse_nud_range_exclusive_expr ( std::unique_ptr<AST::Expr> right = parse_expr (LBP_DOT_DOT, AST::AttrVec (), restrictions); - Location locus = tok->get_locus (); + location_t locus = tok->get_locus (); if (right == nullptr) { @@ -13877,7 +13877,7 @@ Parser<ManagedTokenSource>::parse_range_inclusive_expr ( // FIXME: make non-associative // TODO: check types. actually, do so during semantic analysis - Location locus = left->get_locus (); + location_t locus = left->get_locus (); return std::unique_ptr<AST::RangeFromToInclExpr> ( new AST::RangeFromToInclExpr (std::move (left), std::move (right), locus)); @@ -13925,7 +13925,7 @@ Parser<ManagedTokenSource>::parse_tuple_index_expr ( } int index_int = atoi (index.c_str ()); - Location locus = tuple_expr->get_locus (); + location_t locus = tuple_expr->get_locus (); return std::unique_ptr<AST::TupleIndexExpr> ( new AST::TupleIndexExpr (std::move (tuple_expr), index_int, @@ -13956,7 +13956,7 @@ Parser<ManagedTokenSource>::parse_index_expr ( } // TODO: check types. actually, do so during semantic analysis - Location locus = array_expr->get_locus (); + location_t locus = array_expr->get_locus (); return std::unique_ptr<AST::ArrayIndexExpr> ( new AST::ArrayIndexExpr (std::move (array_expr), std::move (index_expr), @@ -13978,7 +13978,7 @@ Parser<ManagedTokenSource>::parse_field_access_expr ( Identifier ident{ident_tok}; - Location locus = struct_expr->get_locus (); + location_t locus = struct_expr->get_locus (); // TODO: check types. actually, do so during semantic analysis return std::unique_ptr<AST::FieldAccessExpr> ( @@ -14041,7 +14041,7 @@ Parser<ManagedTokenSource>::parse_method_call_expr ( } // TODO: check types. actually do so in semantic analysis pass. - Location locus = receiver_expr->get_locus (); + location_t locus = receiver_expr->get_locus (); return std::unique_ptr<AST::MethodCallExpr> ( new AST::MethodCallExpr (std::move (receiver_expr), std::move (segment), @@ -14088,7 +14088,7 @@ Parser<ManagedTokenSource>::parse_function_call_expr ( } // TODO: check types. actually, do so during semantic analysis - Location locus = function_expr->get_locus (); + location_t locus = function_expr->get_locus (); return std::unique_ptr<AST::CallExpr> ( new AST::CallExpr (std::move (function_expr), std::move (params), @@ -14444,7 +14444,7 @@ Parser<ManagedTokenSource>::parse_closure_expr_pratt (const_TokenPtr tok, { // TODO: does this need pratt parsing (for precedence)? probably not, but // idk - Location locus = tok->get_locus (); + location_t locus = tok->get_locus (); bool has_move = false; if (tok->get_id () == MOVE) { @@ -14589,7 +14589,7 @@ Parser<ManagedTokenSource>::parse_tuple_index_expr_float ( // get int from string int index = atoi (index_str.c_str ()); - Location locus = tuple_expr->get_locus (); + location_t locus = tuple_expr->get_locus (); return std::unique_ptr<AST::TupleIndexExpr> ( new AST::TupleIndexExpr (std::move (tuple_expr), index, diff --git a/gcc/rust/parse/rust-parse.h b/gcc/rust/parse/rust-parse.h index 21540a3..b8913afe 100644 --- a/gcc/rust/parse/rust-parse.h +++ b/gcc/rust/parse/rust-parse.h @@ -204,7 +204,7 @@ private: AST::GenericArg parse_generic_arg (); AST::GenericArgs parse_path_generic_args (); AST::GenericArgsBinding parse_generic_args_binding (); - AST::TypePathFunction parse_type_path_function (Location locus); + AST::TypePathFunction parse_type_path_function (location_t locus); AST::PathExprSegment parse_path_expr_segment (); AST::QualifiedPathInExpression // When given a pratt_parsed_loc, use it as the location of the @@ -630,7 +630,7 @@ private: std::unique_ptr<AST::TypeNoBounds> parse_slice_or_array_type (); std::unique_ptr<AST::RawPointerType> parse_raw_pointer_type (); std::unique_ptr<AST::ReferenceType> - parse_reference_type_inner (Location locus); + parse_reference_type_inner (location_t locus); std::unique_ptr<AST::ReferenceType> parse_reference_type (); std::unique_ptr<AST::BareFunctionType> parse_bare_function_type (std::vector<AST::LifetimeParam> for_lifetimes); diff --git a/gcc/rust/resolve/rust-ast-resolve-expr.cc b/gcc/rust/resolve/rust-ast-resolve-expr.cc index de93843..7333cf4 100644 --- a/gcc/rust/resolve/rust-ast-resolve-expr.cc +++ b/gcc/rust/resolve/rust-ast-resolve-expr.cc @@ -424,7 +424,7 @@ ResolveExpr::visit (AST::LoopExpr &expr) resolver->get_label_scope ().insert ( CanonicalPath::new_seg (expr.get_node_id (), label_name), label_lifetime_node_id, label.get_locus (), false, Rib::ItemType::Label, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rust_error_at (label.get_locus (), "label redefined multiple times"); rust_error_at (locus, "was defined here"); }); @@ -498,7 +498,7 @@ ResolveExpr::visit (AST::WhileLoopExpr &expr) resolver->get_label_scope ().insert ( CanonicalPath::new_seg (label.get_node_id (), label_name), label_lifetime_node_id, label.get_locus (), false, Rib::ItemType::Label, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rust_error_at (label.get_locus (), "label redefined multiple times"); rust_error_at (locus, "was defined here"); }); @@ -527,7 +527,7 @@ ResolveExpr::visit (AST::ForLoopExpr &expr) resolver->get_label_scope ().insert ( CanonicalPath::new_seg (label.get_node_id (), label_name), label_lifetime_node_id, label.get_locus (), false, Rib::ItemType::Label, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rust_error_at (label.get_locus (), "label redefined multiple times"); rust_error_at (locus, "was defined here"); }); diff --git a/gcc/rust/resolve/rust-ast-resolve-implitem.h b/gcc/rust/resolve/rust-ast-resolve-implitem.h index 585db5a..f03c293 100644 --- a/gcc/rust/resolve/rust-ast-resolve-implitem.h +++ b/gcc/rust/resolve/rust-ast-resolve-implitem.h @@ -57,7 +57,7 @@ public: resolver->get_type_scope ().insert ( path, type.get_node_id (), type.get_locus (), false, Rib::ItemType::Type, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, type.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -73,7 +73,7 @@ public: resolver->get_name_scope ().insert ( path, constant.get_node_id (), constant.get_locus (), false, Rib::ItemType::Const, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, constant.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -90,7 +90,7 @@ public: resolver->get_name_scope ().insert ( path, function.get_node_id (), function.get_locus (), false, Rib::ItemType::Function, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, function.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -106,7 +106,7 @@ public: resolver->get_name_scope ().insert ( path, method.get_node_id (), method.get_locus (), false, Rib::ItemType::Function, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, method.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -146,7 +146,7 @@ public: resolver->get_name_scope ().insert ( path, function.get_node_id (), function.get_locus (), false, Rib::ItemType::Function, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, function.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -166,7 +166,7 @@ public: resolver->get_name_scope ().insert ( path, method.get_node_id (), method.get_locus (), false, Rib::ItemType::Function, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, method.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -186,7 +186,7 @@ public: resolver->get_name_scope ().insert ( path, constant.get_node_id (), constant.get_locus (), false, Rib::ItemType::Const, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, constant.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -204,7 +204,7 @@ public: resolver->get_type_scope ().insert ( path, type.get_node_id (), type.get_locus (), false, Rib::ItemType::Type, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, type.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -244,7 +244,7 @@ public: resolver->get_name_scope ().insert ( path, function.get_node_id (), function.get_locus (), false, Rib::ItemType::Function, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, function.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -263,7 +263,7 @@ public: resolver->get_name_scope ().insert ( path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Static, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, item.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); diff --git a/gcc/rust/resolve/rust-ast-resolve-pattern.h b/gcc/rust/resolve/rust-ast-resolve-pattern.h index bcf862b..78db070 100644 --- a/gcc/rust/resolve/rust-ast-resolve-pattern.h +++ b/gcc/rust/resolve/rust-ast-resolve-pattern.h @@ -51,10 +51,10 @@ class BindingTypeInfo { Mutability mut; bool is_ref; - Location locus; + location_t locus; public: - BindingTypeInfo (Mutability mut, bool is_ref, Location locus) + BindingTypeInfo (Mutability mut, bool is_ref, location_t locus) : mut (mut), is_ref (is_ref), locus (locus) {} diff --git a/gcc/rust/resolve/rust-ast-resolve-stmt.h b/gcc/rust/resolve/rust-ast-resolve-stmt.h index ce350c3..6d5f532 100644 --- a/gcc/rust/resolve/rust-ast-resolve-stmt.h +++ b/gcc/rust/resolve/rust-ast-resolve-stmt.h @@ -59,7 +59,7 @@ public: resolver->get_name_scope ().insert ( path, constant.get_node_id (), constant.get_locus (), false, Rib::ItemType::Const, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, constant.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -94,7 +94,7 @@ public: resolver->get_type_scope ().insert ( path, struct_decl.get_node_id (), struct_decl.get_locus (), false, Rib::ItemType::Type, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, struct_decl.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -127,7 +127,7 @@ public: resolver->get_type_scope ().insert ( path, enum_decl.get_node_id (), enum_decl.get_locus (), false, Rib::ItemType::Type, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, enum_decl.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -159,7 +159,7 @@ public: resolver->get_type_scope ().insert ( path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, item.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -179,7 +179,7 @@ public: resolver->get_type_scope ().insert ( path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, item.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -205,7 +205,7 @@ public: resolver->get_type_scope ().insert ( path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, item.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -231,7 +231,7 @@ public: resolver->get_type_scope ().insert ( path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, item.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -252,7 +252,7 @@ public: resolver->get_type_scope ().insert ( path, struct_decl.get_node_id (), struct_decl.get_locus (), false, Rib::ItemType::Type, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, struct_decl.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -290,7 +290,7 @@ public: resolver->get_type_scope ().insert ( path, union_decl.get_node_id (), union_decl.get_locus (), false, Rib::ItemType::Type, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, union_decl.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -326,7 +326,7 @@ public: resolver->get_name_scope ().insert ( path, function.get_node_id (), function.get_locus (), false, Rib::ItemType::Function, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, function.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); diff --git a/gcc/rust/resolve/rust-ast-resolve-toplevel.h b/gcc/rust/resolve/rust-ast-resolve-toplevel.h index f45f6e8..2ef3e75 100644 --- a/gcc/rust/resolve/rust-ast-resolve-toplevel.h +++ b/gcc/rust/resolve/rust-ast-resolve-toplevel.h @@ -55,7 +55,7 @@ public: resolver->get_name_scope ().insert ( path, module.get_node_id (), module.get_locus (), false, Rib::ItemType::Module, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, module.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -85,7 +85,7 @@ public: resolver->get_type_scope ().insert ( path, alias.get_node_id (), alias.get_locus (), false, Rib::ItemType::Type, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, alias.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -107,7 +107,7 @@ public: resolver->get_type_scope ().insert ( path, struct_decl.get_node_id (), struct_decl.get_locus (), false, Rib::ItemType::Type, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, struct_decl.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -129,7 +129,7 @@ public: resolver->get_type_scope ().insert ( path, enum_decl.get_node_id (), enum_decl.get_locus (), false, Rib::ItemType::Type, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, enum_decl.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -155,7 +155,7 @@ public: resolver->get_type_scope ().insert ( path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, item.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -177,7 +177,7 @@ public: resolver->get_type_scope ().insert ( path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, item.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -199,7 +199,7 @@ public: resolver->get_type_scope ().insert ( path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, item.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -221,7 +221,7 @@ public: resolver->get_type_scope ().insert ( path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, item.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -245,7 +245,7 @@ public: resolver->get_type_scope ().insert ( path, struct_decl.get_node_id (), struct_decl.get_locus (), false, Rib::ItemType::Type, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, struct_decl.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -267,7 +267,7 @@ public: resolver->get_type_scope ().insert ( path, union_decl.get_node_id (), union_decl.get_locus (), false, Rib::ItemType::Type, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, union_decl.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -287,7 +287,7 @@ public: resolver->get_name_scope ().insert ( path, var.get_node_id (), var.get_locus (), false, Rib::ItemType::Static, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, var.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -308,7 +308,7 @@ public: resolver->get_name_scope ().insert ( path, constant.get_node_id (), constant.get_locus (), false, Rib::ItemType::Const, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, constant.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -330,7 +330,7 @@ public: resolver->get_name_scope ().insert ( path, function.get_node_id (), function.get_locus (), false, Rib::ItemType::Function, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, function.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -374,7 +374,7 @@ public: resolver->get_name_scope ().insert ( impl_prefix, impl_block.get_node_id (), impl_block.get_locus (), false, Rib::ItemType::TraitImpl, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, impl_block.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -394,7 +394,7 @@ public: resolver->get_type_scope ().insert ( path, trait.get_node_id (), trait.get_locus (), false, Rib::ItemType::Trait, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, trait.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); @@ -470,7 +470,7 @@ public: resolver->get_type_scope ().insert ( decl, resolved_crate, extern_crate.get_locus (), false, Rib::ItemType::ExternCrate, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rich_location r (line_table, extern_crate.get_locus ()); r.add_range (locus); rust_error_at (r, "redefined multiple times"); diff --git a/gcc/rust/resolve/rust-ast-resolve-type.h b/gcc/rust/resolve/rust-ast-resolve-type.h index ac2fd17..c69a828 100644 --- a/gcc/rust/resolve/rust-ast-resolve-type.h +++ b/gcc/rust/resolve/rust-ast-resolve-type.h @@ -178,7 +178,7 @@ public: param.get_type_representation ().as_string ()); resolver->get_type_scope ().insert ( seg, param.get_node_id (), param.get_locus (), false, Rib::ItemType::Type, - [&] (const CanonicalPath &, NodeId, Location locus) -> void { + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { rust_error_at (param.get_locus (), "generic param redefined multiple times"); rust_error_at (locus, "was defined here"); diff --git a/gcc/rust/resolve/rust-name-resolver.cc b/gcc/rust/resolve/rust-name-resolver.cc index b579225..da67101 100644 --- a/gcc/rust/resolve/rust-name-resolver.cc +++ b/gcc/rust/resolve/rust-name-resolver.cc @@ -28,7 +28,7 @@ Rib::Rib (CrateNum crateNum, NodeId node_id) void Rib::insert_name ( - const CanonicalPath &path, NodeId id, Location locus, bool shadow, + const CanonicalPath &path, NodeId id, location_t locus, bool shadow, ItemType type, std::function<void (const CanonicalPath &, NodeId, Location)> dup_cb) { @@ -139,7 +139,7 @@ Scope::Scope (CrateNum crate_num) : crate_num (crate_num) {} void Scope::insert ( - const CanonicalPath &ident, NodeId id, Location locus, bool shadow, + const CanonicalPath &ident, NodeId id, location_t locus, bool shadow, Rib::ItemType type, std::function<void (const CanonicalPath &, NodeId, Location)> dup_cb) { @@ -147,7 +147,7 @@ Scope::insert ( } void -Scope::insert (const CanonicalPath &ident, NodeId id, Location locus, +Scope::insert (const CanonicalPath &ident, NodeId id, location_t locus, Rib::ItemType type) { peek ()->insert_name (ident, id, locus, true, type, diff --git a/gcc/rust/resolve/rust-name-resolver.h b/gcc/rust/resolve/rust-name-resolver.h index bf4ec37..831207f 100644 --- a/gcc/rust/resolve/rust-name-resolver.h +++ b/gcc/rust/resolve/rust-name-resolver.h @@ -55,7 +55,7 @@ public: // this takes the relative paths of items within a compilation unit for lookup void insert_name ( - const CanonicalPath &path, NodeId id, Location locus, bool shadow, + const CanonicalPath &path, NodeId id, location_t locus, bool shadow, ItemType type, std::function<void (const CanonicalPath &, NodeId, Location)> dup_cb); @@ -89,11 +89,11 @@ public: Scope (CrateNum crate_num); void - insert (const CanonicalPath &ident, NodeId id, Location locus, bool shadow, + insert (const CanonicalPath &ident, NodeId id, location_t locus, bool shadow, Rib::ItemType type, std::function<void (const CanonicalPath &, NodeId, Location)> dup_cb); - void insert (const CanonicalPath &ident, NodeId id, Location locus, + void insert (const CanonicalPath &ident, NodeId id, location_t locus, Rib::ItemType type = Rib::ItemType::Unknown); bool lookup (const CanonicalPath &ident, NodeId *id); bool lookup_decl_type (NodeId id, Rib::ItemType *type); diff --git a/gcc/rust/rust-diagnostics.cc b/gcc/rust/rust-diagnostics.cc index f612273..26553ce 100644 --- a/gcc/rust/rust-diagnostics.cc +++ b/gcc/rust/rust-diagnostics.cc @@ -360,11 +360,12 @@ namespace Rust { * This function takes ownership of `args` and calls `va_end` on it */ static Error -va_constructor (Error::Kind kind, Location locus, const char *fmt, va_list args) - RUST_ATTRIBUTE_GCC_DIAG (3, 0); +va_constructor (Error::Kind kind, location_t locus, const char *fmt, + va_list args) RUST_ATTRIBUTE_GCC_DIAG (3, 0); static Error -va_constructor (Error::Kind kind, Location locus, const char *fmt, va_list args) +va_constructor (Error::Kind kind, location_t locus, const char *fmt, + va_list args) { std::string message = expand_message (fmt, args); message.shrink_to_fit (); diff --git a/gcc/rust/rust-diagnostics.h b/gcc/rust/rust-diagnostics.h index 316d3e0..dccdf6d 100644 --- a/gcc/rust/rust-diagnostics.h +++ b/gcc/rust/rust-diagnostics.h @@ -146,45 +146,45 @@ struct Error }; Kind kind; - Location locus; + location_t locus; std::string message; // TODO: store more stuff? e.g. node id? - Error (Kind kind, Location locus, std::string message) + Error (Kind kind, location_t locus, std::string message) : kind (kind), locus (locus), message (std::move (message)) { message.shrink_to_fit (); } - Error (Location locus, std::string message) + Error (location_t locus, std::string message) { Error (Kind::Err, locus, std::move (message)); } - static Error Hint (Location locus, std::string message) + static Error Hint (location_t locus, std::string message) { return Error (Kind::Hint, locus, std::move (message)); } - static Error Fatal (Location locus, std::string message) + static Error Fatal (location_t locus, std::string message) { return Error (Kind::FatalErr, locus, std::move (message)); } // TODO: the attribute part might be incorrect - Error (Location locus, const char *fmt, + Error (location_t locus, const char *fmt, ...) /*RUST_ATTRIBUTE_GCC_DIAG (2, 3)*/ RUST_ATTRIBUTE_GCC_DIAG (3, 4); /** * printf-like overload of Error::Hint */ - static Error Hint (Location locus, const char *fmt, ...) + static Error Hint (location_t locus, const char *fmt, ...) RUST_ATTRIBUTE_GCC_DIAG (2, 3); /** * printf-like overload of Error::Fatal */ - static Error Fatal (Location locus, const char *fmt, ...) + static Error Fatal (location_t locus, const char *fmt, ...) RUST_ATTRIBUTE_GCC_DIAG (2, 3); void emit () const diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc index 8a2071d..8b6410d 100644 --- a/gcc/rust/rust-gcc.cc +++ b/gcc/rust/rust-gcc.cc @@ -213,7 +213,7 @@ public: tree assignment_statement (tree lhs, tree rhs, Location); - tree return_statement (tree fndecl, tree val, Location locus); + tree return_statement (tree fndecl, tree val, location_t locus); tree if_statement (tree, tree condition, tree then_block, tree else_block, Location); @@ -1734,7 +1734,7 @@ Gcc_backend::array_constructor_expression ( tree Gcc_backend::array_initializer (tree fndecl, tree block, tree array_type, tree length, tree value, tree *tmp, - Location locus) + location_t locus) { std::vector<tree> stmts; @@ -2021,13 +2021,13 @@ Gcc_backend::if_statement (tree, tree cond_tree, tree then_tree, tree else_tree, // Loops tree -Gcc_backend::loop_expression (tree body, Location locus) +Gcc_backend::loop_expression (tree body, location_t locus) { return fold_build1_loc (locus, LOOP_EXPR, void_type_node, body); } tree -Gcc_backend::exit_expression (tree cond_tree, Location locus) +Gcc_backend::exit_expression (tree cond_tree, location_t locus) { return fold_build1_loc (locus, EXIT_EXPR, void_type_node, cond_tree); } diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc index 452f692..b1a735c 100644 --- a/gcc/rust/rust-session-manager.cc +++ b/gcc/rust/rust-session-manager.cc @@ -955,7 +955,7 @@ Session::dump_hir_pretty (HIR::Crate &crate) const // imports NodeId -Session::load_extern_crate (const std::string &crate_name, Location locus) +Session::load_extern_crate (const std::string &crate_name, location_t locus) { // has it already been loaded? CrateNum found_crate_num = UNKNOWN_CREATENUM; diff --git a/gcc/rust/rust-session-manager.h b/gcc/rust/rust-session-manager.h index b6d89a8..f4f95af 100644 --- a/gcc/rust/rust-session-manager.h +++ b/gcc/rust/rust-session-manager.h @@ -359,7 +359,7 @@ public: return extra_files.back ().c_str (); } - NodeId load_extern_crate (const std::string &crate_name, Location locus); + NodeId load_extern_crate (const std::string &crate_name, location_t locus); private: void compile_crate (const char *filename); diff --git a/gcc/rust/typecheck/rust-casts.cc b/gcc/rust/typecheck/rust-casts.cc index 39791ae..640d147 100644 --- a/gcc/rust/typecheck/rust-casts.cc +++ b/gcc/rust/typecheck/rust-casts.cc @@ -21,13 +21,13 @@ namespace Rust { namespace Resolver { -TypeCastRules::TypeCastRules (Location locus, TyTy::TyWithLocation from, +TypeCastRules::TypeCastRules (location_t locus, TyTy::TyWithLocation from, TyTy::TyWithLocation to) : locus (locus), from (from), to (to) {} TypeCoercionRules::CoercionResult -TypeCastRules::resolve (Location locus, TyTy::TyWithLocation from, +TypeCastRules::resolve (location_t locus, TyTy::TyWithLocation from, TyTy::TyWithLocation to) { TypeCastRules cast_rules (locus, from, to); diff --git a/gcc/rust/typecheck/rust-casts.h b/gcc/rust/typecheck/rust-casts.h index bd78236..c2506c2 100644 --- a/gcc/rust/typecheck/rust-casts.h +++ b/gcc/rust/typecheck/rust-casts.h @@ -28,8 +28,9 @@ namespace Resolver { class TypeCastRules { public: - static TypeCoercionRules::CoercionResult - resolve (Location locus, TyTy::TyWithLocation from, TyTy::TyWithLocation to); + static TypeCoercionRules::CoercionResult resolve (location_t locus, + TyTy::TyWithLocation from, + TyTy::TyWithLocation to); protected: TypeCoercionRules::CoercionResult check (); @@ -39,10 +40,10 @@ protected: void emit_cast_error () const; protected: - TypeCastRules (Location locus, TyTy::TyWithLocation from, + TypeCastRules (location_t locus, TyTy::TyWithLocation from, TyTy::TyWithLocation to); - Location locus; + location_t locus; TyTy::TyWithLocation from; TyTy::TyWithLocation to; }; diff --git a/gcc/rust/typecheck/rust-coercion.cc b/gcc/rust/typecheck/rust-coercion.cc index 216ac0e..cd2a666 100644 --- a/gcc/rust/typecheck/rust-coercion.cc +++ b/gcc/rust/typecheck/rust-coercion.cc @@ -24,7 +24,7 @@ namespace Resolver { TypeCoercionRules::CoercionResult TypeCoercionRules::Coerce (TyTy::BaseType *receiver, TyTy::BaseType *expected, - Location locus, bool allow_autoderef, + location_t locus, bool allow_autoderef, bool is_cast_site) { TypeCoercionRules resolver (expected, locus, true, allow_autoderef, false, @@ -35,7 +35,7 @@ TypeCoercionRules::Coerce (TyTy::BaseType *receiver, TyTy::BaseType *expected, TypeCoercionRules::CoercionResult TypeCoercionRules::TryCoerce (TyTy::BaseType *receiver, - TyTy::BaseType *expected, Location locus, + TyTy::BaseType *expected, location_t locus, bool allow_autoderef, bool is_cast_site) { TypeCoercionRules resolver (expected, locus, false, allow_autoderef, true, @@ -44,9 +44,10 @@ TypeCoercionRules::TryCoerce (TyTy::BaseType *receiver, return ok ? resolver.try_result : CoercionResult::get_error (); } -TypeCoercionRules::TypeCoercionRules (TyTy::BaseType *expected, Location locus, - bool emit_errors, bool allow_autoderef, - bool try_flag, bool is_cast_site) +TypeCoercionRules::TypeCoercionRules (TyTy::BaseType *expected, + location_t locus, bool emit_errors, + bool allow_autoderef, bool try_flag, + bool is_cast_site) : AutoderefCycle (!allow_autoderef), mappings (Analysis::Mappings::get ()), context (TypeCheckContext::get ()), expected (expected), locus (locus), try_result (CoercionResult::get_error ()), emit_errors (emit_errors), @@ -73,7 +74,7 @@ TypeCoercionRules::do_coercion (TyTy::BaseType *receiver) // here, we would coerce from `!` to `?T`. if (expected->has_subsititions_defined () && !expected->is_concrete ()) { - Location locus = mappings->lookup_location (receiver->get_ref ()); + location_t locus = mappings->lookup_location (receiver->get_ref ()); TyTy::TyVar implicit_var = TyTy::TyVar::get_implicit_infer_var (locus); try_result = CoercionResult{{}, implicit_var.get_tyty ()}; diff --git a/gcc/rust/typecheck/rust-coercion.h b/gcc/rust/typecheck/rust-coercion.h index be672e8..b8e5573 100644 --- a/gcc/rust/typecheck/rust-coercion.h +++ b/gcc/rust/typecheck/rust-coercion.h @@ -42,12 +42,12 @@ public: }; static CoercionResult Coerce (TyTy::BaseType *receiver, - TyTy::BaseType *expected, Location locus, + TyTy::BaseType *expected, location_t locus, bool allow_autoderef, bool is_cast_site = false); static CoercionResult TryCoerce (TyTy::BaseType *receiver, - TyTy::BaseType *expected, Location locus, + TyTy::BaseType *expected, location_t locus, bool allow_autoderef, bool is_cast_site = false); @@ -70,8 +70,9 @@ public: void object_unsafe_error (Location expr_locus, Location lhs, Location rhs); protected: - TypeCoercionRules (TyTy::BaseType *expected, Location locus, bool emit_errors, - bool allow_autoderef, bool try_flag, bool is_cast_site); + TypeCoercionRules (TyTy::BaseType *expected, location_t locus, + bool emit_errors, bool allow_autoderef, bool try_flag, + bool is_cast_site); bool select (TyTy::BaseType &autoderefed) override; @@ -84,7 +85,7 @@ private: // search TyTy::BaseType *expected; - Location locus; + location_t locus; // mutable fields CoercionResult try_result; diff --git a/gcc/rust/typecheck/rust-hir-path-probe.cc b/gcc/rust/typecheck/rust-hir-path-probe.cc index 2885d35..2b40f5d 100644 --- a/gcc/rust/typecheck/rust-hir-path-probe.cc +++ b/gcc/rust/typecheck/rust-hir-path-probe.cc @@ -39,18 +39,19 @@ PathProbeCandidate::Candidate::Candidate (TraitItemCandidate trait) {} PathProbeCandidate::PathProbeCandidate (CandidateType type, TyTy::BaseType *ty, - Location locus, + location_t locus, EnumItemCandidate enum_field) : type (type), ty (ty), locus (locus), item (enum_field) {} PathProbeCandidate::PathProbeCandidate (CandidateType type, TyTy::BaseType *ty, - Location locus, ImplItemCandidate impl) + location_t locus, + ImplItemCandidate impl) : type (type), ty (ty), locus (locus), item (impl) {} PathProbeCandidate::PathProbeCandidate (CandidateType type, TyTy::BaseType *ty, - Location locus, + location_t locus, TraitItemCandidate trait) : type (type), ty (ty), locus (locus), item (trait) {} diff --git a/gcc/rust/typecheck/rust-hir-path-probe.h b/gcc/rust/typecheck/rust-hir-path-probe.h index 0e814ec..ea041ac 100644 --- a/gcc/rust/typecheck/rust-hir-path-probe.h +++ b/gcc/rust/typecheck/rust-hir-path-probe.h @@ -64,7 +64,7 @@ struct PathProbeCandidate CandidateType type; TyTy::BaseType *ty; - Location locus; + location_t locus; union Candidate { EnumItemCandidate enum_field; @@ -76,13 +76,13 @@ struct PathProbeCandidate Candidate (TraitItemCandidate trait); } item; - PathProbeCandidate (CandidateType type, TyTy::BaseType *ty, Location locus, + PathProbeCandidate (CandidateType type, TyTy::BaseType *ty, location_t locus, EnumItemCandidate enum_field); - PathProbeCandidate (CandidateType type, TyTy::BaseType *ty, Location locus, + PathProbeCandidate (CandidateType type, TyTy::BaseType *ty, location_t locus, ImplItemCandidate impl); - PathProbeCandidate (CandidateType type, TyTy::BaseType *ty, Location locus, + PathProbeCandidate (CandidateType type, TyTy::BaseType *ty, location_t locus, TraitItemCandidate trait); std::string as_string () const; diff --git a/gcc/rust/typecheck/rust-hir-trait-reference.cc b/gcc/rust/typecheck/rust-hir-trait-reference.cc index 32a9f91..d089e23 100644 --- a/gcc/rust/typecheck/rust-hir-trait-reference.cc +++ b/gcc/rust/typecheck/rust-hir-trait-reference.cc @@ -381,7 +381,7 @@ TraitReference::get_super_traits () const } bool -TraitReference::is_object_safe (bool emit_error, Location locus) const +TraitReference::is_object_safe (bool emit_error, location_t locus) const { // https: // doc.rust-lang.org/reference/items/traits.html#object-safety std::vector<const TraitReference *> non_object_super_traits; diff --git a/gcc/rust/typecheck/rust-hir-trait-reference.h b/gcc/rust/typecheck/rust-hir-trait-reference.h index 38f2949..1722e0f 100644 --- a/gcc/rust/typecheck/rust-hir-trait-reference.h +++ b/gcc/rust/typecheck/rust-hir-trait-reference.h @@ -42,7 +42,7 @@ public: TraitItemReference (std::string identifier, bool optional, TraitItemType type, HIR::TraitItem *hir_trait_item, TyTy::BaseType *self, std::vector<TyTy::SubstitutionParamMapping> substitutions, - Location locus); + location_t locus); TraitItemReference (TraitItemReference const &other); @@ -130,7 +130,7 @@ private: TraitItemType type; HIR::TraitItem *hir_trait_item; std::vector<TyTy::SubstitutionParamMapping> inherited_substitutions; - Location locus; + location_t locus; TyTy::BaseType *self; // this is the implict Self TypeParam required for methods @@ -219,7 +219,7 @@ public: const std::vector<const TraitReference *> get_super_traits () const; - bool is_object_safe (bool emit_error, Location locus) const; + bool is_object_safe (bool emit_error, location_t locus) const; bool trait_has_generics () const; diff --git a/gcc/rust/typecheck/rust-hir-trait-resolve.cc b/gcc/rust/typecheck/rust-hir-trait-resolve.cc index f5370d0..37132a7 100644 --- a/gcc/rust/typecheck/rust-hir-trait-resolve.cc +++ b/gcc/rust/typecheck/rust-hir-trait-resolve.cc @@ -38,7 +38,7 @@ void ResolveTraitItemToRef::visit (HIR::TraitItemType &type) { // create trait-item-ref - Location locus = type.get_locus (); + location_t locus = type.get_locus (); bool is_optional = false; std::string identifier = type.get_name ().as_string (); @@ -51,7 +51,7 @@ void ResolveTraitItemToRef::visit (HIR::TraitItemConst &cst) { // create trait-item-ref - Location locus = cst.get_locus (); + location_t locus = cst.get_locus (); bool is_optional = cst.has_expr (); std::string identifier = cst.get_name ().as_string (); @@ -64,7 +64,7 @@ void ResolveTraitItemToRef::visit (HIR::TraitItemFunc &fn) { // create trait-item-ref - Location locus = fn.get_locus (); + location_t locus = fn.get_locus (); bool is_optional = fn.has_block_defined (); std::string identifier = fn.get_decl ().get_function_name ().as_string (); @@ -491,7 +491,7 @@ AssociatedImplTrait::setup_associated_types ( // generate inference variables for these bound arguments so we can compute // their values - Location locus = UNKNOWN_LOCATION; + location_t locus = UNKNOWN_LOCATION; std::vector<TyTy::SubstitutionArg> subst_args; for (auto &p : substitutions) { diff --git a/gcc/rust/typecheck/rust-hir-type-check-base.cc b/gcc/rust/typecheck/rust-hir-type-check-base.cc index 622a8bb..f0f820c 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-base.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-base.cc @@ -87,7 +87,7 @@ TypeCheckBase::check_for_unconstrained ( bool used = constrained_symbols.find (sym) != constrained_symbols.end (); if (!used) { - Location locus = symbol_to_location.at (sym); + location_t locus = symbol_to_location.at (sym); rust_error_at (locus, "unconstrained type parameter"); unconstrained = true; } @@ -101,7 +101,7 @@ TypeCheckBase::check_for_unconstrained ( TyTy::BaseType * TypeCheckBase::resolve_literal (const Analysis::NodeMapping &expr_mappings, - HIR::Literal &literal, Location locus) + HIR::Literal &literal, location_t locus) { TyTy::BaseType *infered = nullptr; switch (literal.get_lit_type ()) @@ -282,7 +282,7 @@ TypeCheckBase::resolve_literal (const Analysis::NodeMapping &expr_mappings, } TyTy::ADTType::ReprOptions -TypeCheckBase::parse_repr_options (const AST::AttrVec &attrs, Location locus) +TypeCheckBase::parse_repr_options (const AST::AttrVec &attrs, location_t locus) { TyTy::ADTType::ReprOptions repr; repr.pack = 0; diff --git a/gcc/rust/typecheck/rust-hir-type-check-base.h b/gcc/rust/typecheck/rust-hir-type-check-base.h index f73b61b8..0cbcefe 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-base.h +++ b/gcc/rust/typecheck/rust-hir-type-check-base.h @@ -47,10 +47,10 @@ protected: const TyTy::BaseType *reference); TyTy::BaseType *resolve_literal (const Analysis::NodeMapping &mappings, - HIR::Literal &literal, Location locus); + HIR::Literal &literal, location_t locus); TyTy::ADTType::ReprOptions parse_repr_options (const AST::AttrVec &attrs, - Location locus); + location_t locus); void resolve_generic_params ( const std::vector<std::unique_ptr<HIR::GenericParam> > &generic_params, diff --git a/gcc/rust/typecheck/rust-hir-type-check-item.cc b/gcc/rust/typecheck/rust-hir-type-check-item.cc index b6a21ad..4e50d68 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-item.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-item.cc @@ -75,7 +75,7 @@ TypeCheckItem::ResolveImplBlockSelf (HIR::ImplBlock &impl_block) TyTy::BaseType * TypeCheckItem::ResolveImplBlockSelfWithInference ( - HIR::ImplBlock &impl, Location locus, + HIR::ImplBlock &impl, location_t locus, TyTy::SubstitutionArgumentMappings *infer_arguments) { TypeCheckItem resolver; diff --git a/gcc/rust/typecheck/rust-hir-type-check-item.h b/gcc/rust/typecheck/rust-hir-type-check-item.h index bbe3a11..73cf9de 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-item.h +++ b/gcc/rust/typecheck/rust-hir-type-check-item.h @@ -36,7 +36,7 @@ public: static TyTy::BaseType *ResolveImplBlockSelf (HIR::ImplBlock &impl_block); static TyTy::BaseType *ResolveImplBlockSelfWithInference ( - HIR::ImplBlock &impl, Location locus, + HIR::ImplBlock &impl, location_t locus, TyTy::SubstitutionArgumentMappings *infer_arguments); void visit (HIR::Module &module) override; diff --git a/gcc/rust/typecheck/rust-hir-type-check-path.cc b/gcc/rust/typecheck/rust-hir-type-check-path.cc index 54ca28f..daa5ac7 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-path.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-path.cc @@ -478,7 +478,7 @@ TypeCheckExpr::resolve_segments (NodeId root_resolved_node_id, } else if (tyseg->needs_generic_substitutions () && !reciever_is_generic) { - Location locus = seg.get_locus (); + location_t locus = seg.get_locus (); tyseg = SubstMapper::InferSubst (tyseg, locus); if (tyseg->get_kind () == TyTy::TypeKind::ERROR) return; @@ -488,7 +488,7 @@ TypeCheckExpr::resolve_segments (NodeId root_resolved_node_id, rust_assert (resolved_node_id != UNKNOWN_NODEID); if (tyseg->needs_generic_substitutions () && !reciever_is_generic) { - Location locus = segments.back ().get_locus (); + location_t locus = segments.back ().get_locus (); tyseg = SubstMapper::InferSubst (tyseg, locus); if (tyseg->get_kind () == TyTy::TypeKind::ERROR) return; diff --git a/gcc/rust/typecheck/rust-hir-type-check-pattern.cc b/gcc/rust/typecheck/rust-hir-type-check-pattern.cc index 9c47876..028becf 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-pattern.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-pattern.cc @@ -426,7 +426,7 @@ TypeCheckPattern::emit_pattern_size_error (const HIR::Pattern &pattern, TyTy::BaseType * TypeCheckPattern::typecheck_range_pattern_bound ( std::unique_ptr<Rust::HIR::RangePatternBound> &bound, - Analysis::NodeMapping mappings, Location locus) + Analysis::NodeMapping mappings, location_t locus) { TyTy::BaseType *resolved_bound = nullptr; switch (bound->get_bound_type ()) diff --git a/gcc/rust/typecheck/rust-hir-type-check-pattern.h b/gcc/rust/typecheck/rust-hir-type-check-pattern.h index cdfc34b..4820b74 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-pattern.h +++ b/gcc/rust/typecheck/rust-hir-type-check-pattern.h @@ -49,7 +49,7 @@ private: TyTy::BaseType *typecheck_range_pattern_bound ( std::unique_ptr<Rust::HIR::RangePatternBound> &bound, - Analysis::NodeMapping mappings, Location locus); + Analysis::NodeMapping mappings, location_t locus); void emit_pattern_size_error (const HIR::Pattern &pattern, size_t expected_field_count, diff --git a/gcc/rust/typecheck/rust-hir-type-check-type.cc b/gcc/rust/typecheck/rust-hir-type-check-type.cc index 24ef25c..779e7fd 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-type.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-type.cc @@ -524,7 +524,7 @@ TypeCheckType::resolve_segments ( context->insert_receiver (expr_mappings.get_hirid (), prev_segment); if (tyseg->needs_generic_substitutions ()) { - // Location locus = segments.back ()->get_locus (); + // location_t locus = segments.back ()->get_locus (); if (!prev_segment->needs_generic_substitutions ()) { auto used_args_in_prev_segment diff --git a/gcc/rust/typecheck/rust-hir-type-check-type.h b/gcc/rust/typecheck/rust-hir-type-check-type.h index f8eb9c4..05b41ab 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-type.h +++ b/gcc/rust/typecheck/rust-hir-type-check-type.h @@ -36,7 +36,7 @@ public: void visit (HIR::TypePathSegmentGeneric &generic); private: - TypeCheckResolveGenericArguments (Location locus) + TypeCheckResolveGenericArguments (location_t locus) : TypeCheckBase (), args (HIR::GenericArgs::create_empty (locus)) {} diff --git a/gcc/rust/typecheck/rust-hir-type-check.cc b/gcc/rust/typecheck/rust-hir-type-check.cc index 8f9286f..4e6d457 100644 --- a/gcc/rust/typecheck/rust-hir-type-check.cc +++ b/gcc/rust/typecheck/rust-hir-type-check.cc @@ -84,7 +84,7 @@ TypeResolution::Resolve (HIR::Crate &crate) TraitItemReference::TraitItemReference ( std::string identifier, bool optional, TraitItemType type, HIR::TraitItem *hir_trait_item, TyTy::BaseType *self, - std::vector<TyTy::SubstitutionParamMapping> substitutions, Location locus) + std::vector<TyTy::SubstitutionParamMapping> substitutions, location_t locus) : identifier (identifier), optional_flag (optional), type (type), hir_trait_item (hir_trait_item), inherited_substitutions (std::move (substitutions)), locus (locus), diff --git a/gcc/rust/typecheck/rust-hir-type-check.h b/gcc/rust/typecheck/rust-hir-type-check.h index 3e478f2..7dd4dda 100644 --- a/gcc/rust/typecheck/rust-hir-type-check.h +++ b/gcc/rust/typecheck/rust-hir-type-check.h @@ -110,7 +110,7 @@ public: void iterate (std::function<bool (HirId, TyTy::BaseType *)> cb); bool have_loop_context () const; - void push_new_loop_context (HirId id, Location locus); + void push_new_loop_context (HirId id, location_t locus); void push_new_while_loop_context (HirId id); TyTy::BaseType *peek_loop_context (); TyTy::BaseType *pop_loop_context (); diff --git a/gcc/rust/typecheck/rust-substitution-mapper.cc b/gcc/rust/typecheck/rust-substitution-mapper.cc index 479f6e1..b2d58c4 100644 --- a/gcc/rust/typecheck/rust-substitution-mapper.cc +++ b/gcc/rust/typecheck/rust-substitution-mapper.cc @@ -22,12 +22,13 @@ namespace Rust { namespace Resolver { -SubstMapper::SubstMapper (HirId ref, HIR::GenericArgs *generics, Location locus) +SubstMapper::SubstMapper (HirId ref, HIR::GenericArgs *generics, + location_t locus) : resolved (new TyTy::ErrorType (ref)), generics (generics), locus (locus) {} TyTy::BaseType * -SubstMapper::Resolve (TyTy::BaseType *base, Location locus, +SubstMapper::Resolve (TyTy::BaseType *base, location_t locus, HIR::GenericArgs *generics) { SubstMapper mapper (base->get_ref (), generics, locus); @@ -37,7 +38,7 @@ SubstMapper::Resolve (TyTy::BaseType *base, Location locus, } TyTy::BaseType * -SubstMapper::InferSubst (TyTy::BaseType *base, Location locus) +SubstMapper::InferSubst (TyTy::BaseType *base, location_t locus) { return SubstMapper::Resolve (base, locus, nullptr); } diff --git a/gcc/rust/typecheck/rust-substitution-mapper.h b/gcc/rust/typecheck/rust-substitution-mapper.h index 63cc6bc..0a816c7 100644 --- a/gcc/rust/typecheck/rust-substitution-mapper.h +++ b/gcc/rust/typecheck/rust-substitution-mapper.h @@ -28,10 +28,10 @@ namespace Resolver { class SubstMapper : public TyTy::TyVisitor { public: - static TyTy::BaseType *Resolve (TyTy::BaseType *base, Location locus, + static TyTy::BaseType *Resolve (TyTy::BaseType *base, location_t locus, HIR::GenericArgs *generics = nullptr); - static TyTy::BaseType *InferSubst (TyTy::BaseType *base, Location locus); + static TyTy::BaseType *InferSubst (TyTy::BaseType *base, location_t locus); bool have_generic_args () const; @@ -63,11 +63,11 @@ public: void visit (TyTy::ClosureType &) override { rust_unreachable (); } private: - SubstMapper (HirId ref, HIR::GenericArgs *generics, Location locus); + SubstMapper (HirId ref, HIR::GenericArgs *generics, location_t locus); TyTy::BaseType *resolved; HIR::GenericArgs *generics; - Location locus; + location_t locus; }; class SubstMapperInternal : public TyTy::TyVisitor diff --git a/gcc/rust/typecheck/rust-type-util.cc b/gcc/rust/typecheck/rust-type-util.cc index 561509c..e5b42df 100644 --- a/gcc/rust/typecheck/rust-type-util.cc +++ b/gcc/rust/typecheck/rust-type-util.cc @@ -198,7 +198,7 @@ unify_site_and (HirId id, TyTy::TyWithLocation lhs, TyTy::TyWithLocation rhs, TyTy::BaseType * coercion_site (HirId id, TyTy::TyWithLocation lhs, TyTy::TyWithLocation rhs, - Location locus) + location_t locus) { TyTy::BaseType *expected = lhs.get_ty (); TyTy::BaseType *expr = rhs.get_ty (); @@ -233,7 +233,7 @@ coercion_site (HirId id, TyTy::TyWithLocation lhs, TyTy::TyWithLocation rhs, TyTy::BaseType * try_coercion (HirId id, TyTy::TyWithLocation lhs, TyTy::TyWithLocation rhs, - Location locus) + location_t locus) { TyTy::BaseType *expected = lhs.get_ty (); TyTy::BaseType *expr = rhs.get_ty (); diff --git a/gcc/rust/typecheck/rust-typecheck-context.cc b/gcc/rust/typecheck/rust-typecheck-context.cc index bbd83a9..7062259 100644 --- a/gcc/rust/typecheck/rust-typecheck-context.cc +++ b/gcc/rust/typecheck/rust-typecheck-context.cc @@ -187,7 +187,7 @@ TypeCheckContext::have_loop_context () const } void -TypeCheckContext::push_new_loop_context (HirId id, Location locus) +TypeCheckContext::push_new_loop_context (HirId id, location_t locus) { TyTy::BaseType *infer_var = new TyTy::InferType (id, TyTy::InferType::InferTypeKind::GENERAL, diff --git a/gcc/rust/typecheck/rust-tyty-bounds.cc b/gcc/rust/typecheck/rust-tyty-bounds.cc index 7b6f788..c17f27b 100644 --- a/gcc/rust/typecheck/rust-tyty-bounds.cc +++ b/gcc/rust/typecheck/rust-tyty-bounds.cc @@ -290,7 +290,7 @@ TypeCheckBase::get_predicate_from_bound (HIR::TypePath &type_path, namespace TyTy { TypeBoundPredicate::TypeBoundPredicate ( - const Resolver::TraitReference &trait_reference, Location locus) + const Resolver::TraitReference &trait_reference, location_t locus) : SubstitutionRef ({}, SubstitutionArgumentMappings::empty ()), reference (trait_reference.get_mappings ().get_defid ()), locus (locus), error_flag (false) @@ -305,7 +305,8 @@ TypeBoundPredicate::TypeBoundPredicate ( } TypeBoundPredicate::TypeBoundPredicate ( - DefId reference, std::vector<SubstitutionParamMapping> subst, Location locus) + DefId reference, std::vector<SubstitutionParamMapping> subst, + location_t locus) : SubstitutionRef ({}, SubstitutionArgumentMappings::empty ()), reference (reference), locus (locus), error_flag (false) { @@ -431,7 +432,7 @@ TypeBoundPredicate::get_name () const } bool -TypeBoundPredicate::is_object_safe (bool emit_error, Location locus) const +TypeBoundPredicate::is_object_safe (bool emit_error, location_t locus) const { const Resolver::TraitReference *trait = get (); rust_assert (trait != nullptr); diff --git a/gcc/rust/typecheck/rust-tyty-call.h b/gcc/rust/typecheck/rust-tyty-call.h index e9764a1..a06815e 100644 --- a/gcc/rust/typecheck/rust-tyty-call.h +++ b/gcc/rust/typecheck/rust-tyty-call.h @@ -88,7 +88,7 @@ class Argument { public: Argument (Analysis::NodeMapping mapping, BaseType *argument_type, - Location locus) + location_t locus) : mapping (mapping), argument_type (argument_type), locus (locus) {} @@ -101,7 +101,7 @@ public: private: Analysis::NodeMapping mapping; BaseType *argument_type; - Location locus; + location_t locus; }; class TypeCheckMethodCallExpr diff --git a/gcc/rust/typecheck/rust-tyty-subst.cc b/gcc/rust/typecheck/rust-tyty-subst.cc index 483883e..aea9685 100644 --- a/gcc/rust/typecheck/rust-tyty-subst.cc +++ b/gcc/rust/typecheck/rust-tyty-subst.cc @@ -107,7 +107,7 @@ SubstitutionParamMapping::need_substitution () const bool SubstitutionParamMapping::fill_param_ty ( - SubstitutionArgumentMappings &subst_mappings, Location locus) + SubstitutionArgumentMappings &subst_mappings, location_t locus) { SubstitutionArg arg = SubstitutionArg::error (); bool ok = subst_mappings.get_argument_for_symbol (get_param_ty (), &arg); @@ -247,7 +247,7 @@ SubstitutionArg::as_string () const SubstitutionArgumentMappings::SubstitutionArgumentMappings ( std::vector<SubstitutionArg> mappings, - std::map<std::string, BaseType *> binding_args, Location locus, + std::map<std::string, BaseType *> binding_args, location_t locus, ParamSubstCb param_subst_cb, bool trait_item_flag, bool error_flag) : mappings (mappings), binding_args (binding_args), locus (locus), param_subst_cb (param_subst_cb), trait_item_flag (trait_item_flag), @@ -692,7 +692,7 @@ SubstitutionRef::get_mappings_from_generic_args (HIR::GenericArgs &args) } BaseType * -SubstitutionRef::infer_substitions (Location locus) +SubstitutionRef::infer_substitions (location_t locus) { std::vector<SubstitutionArg> args; std::map<std::string, BaseType *> argument_mappings; diff --git a/gcc/rust/typecheck/rust-tyty-subst.h b/gcc/rust/typecheck/rust-tyty-subst.h index 73812ff..e40e8e7 100644 --- a/gcc/rust/typecheck/rust-tyty-subst.h +++ b/gcc/rust/typecheck/rust-tyty-subst.h @@ -40,7 +40,7 @@ public: std::string as_string () const; bool fill_param_ty (SubstitutionArgumentMappings &subst_mappings, - Location locus); + location_t locus); SubstitutionParamMapping clone () const; @@ -110,7 +110,7 @@ class SubstitutionArgumentMappings public: SubstitutionArgumentMappings (std::vector<SubstitutionArg> mappings, std::map<std::string, BaseType *> binding_args, - Location locus, + location_t locus, ParamSubstCb param_subst_cb = nullptr, bool trait_item_flag = false, bool error_flag = false); @@ -163,7 +163,7 @@ public: private: std::vector<SubstitutionArg> mappings; std::map<std::string, BaseType *> binding_args; - Location locus; + location_t locus; ParamSubstCb param_subst_cb; bool trait_item_flag; bool error_flag; @@ -303,7 +303,7 @@ public: // // This function will inject implicit inference variables for the type // parameters X and Y - BaseType *infer_substitions (Location locus); + BaseType *infer_substitions (location_t locus); // this clears any possible projections from higher ranked trait bounds which // could be hanging around from a previous resolution diff --git a/gcc/rust/typecheck/rust-tyty-util.cc b/gcc/rust/typecheck/rust-tyty-util.cc index 7002efd..37c2d8b 100644 --- a/gcc/rust/typecheck/rust-tyty-util.cc +++ b/gcc/rust/typecheck/rust-tyty-util.cc @@ -42,7 +42,7 @@ TyVar::get_tyty () const } TyVar -TyVar::get_implicit_infer_var (Location locus) +TyVar::get_implicit_infer_var (location_t locus) { auto mappings = Analysis::Mappings::get (); auto context = Resolver::TypeCheckContext::get (); @@ -103,7 +103,7 @@ TyVar::monomorphized_clone () const return TyVar (c->get_ref ()); } -TyWithLocation::TyWithLocation (BaseType *ty, Location locus) +TyWithLocation::TyWithLocation (BaseType *ty, location_t locus) : ty (ty), locus (locus) {} diff --git a/gcc/rust/typecheck/rust-tyty-util.h b/gcc/rust/typecheck/rust-tyty-util.h index ac6b73a..ed13c6e 100644 --- a/gcc/rust/typecheck/rust-tyty-util.h +++ b/gcc/rust/typecheck/rust-tyty-util.h @@ -40,7 +40,7 @@ public: TyVar monomorphized_clone () const; - static TyVar get_implicit_infer_var (Location locus); + static TyVar get_implicit_infer_var (location_t locus); static TyVar subst_covariant_var (TyTy::BaseType *orig, TyTy::BaseType *subst); @@ -52,7 +52,7 @@ private: class TyWithLocation { public: - explicit TyWithLocation (BaseType *ty, Location locus); + explicit TyWithLocation (BaseType *ty, location_t locus); explicit TyWithLocation (BaseType *ty); BaseType *get_ty () const { return ty; } @@ -60,7 +60,7 @@ public: private: BaseType *ty; - Location locus; + location_t locus; }; } // namespace TyTy diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc index 848d0c7..f07c6d2 100644 --- a/gcc/rust/typecheck/rust-tyty.cc +++ b/gcc/rust/typecheck/rust-tyty.cc @@ -368,7 +368,7 @@ BaseType::satisfies_bound (const TypeBoundPredicate &predicate, } bool -BaseType::bounds_compatible (const BaseType &other, Location locus, +BaseType::bounds_compatible (const BaseType &other, location_t locus, bool emit_error) const { std::vector<std::reference_wrapper<const TypeBoundPredicate>> @@ -954,14 +954,14 @@ BaseType::needs_generic_substitutions () const // InferType InferType::InferType (HirId ref, InferTypeKind infer_kind, TypeHint hint, - Location locus, std::set<HirId> refs) + location_t locus, std::set<HirId> refs) : BaseType (ref, ref, TypeKind::INFER, {Resolver::CanonicalPath::create_empty (), locus}, refs), infer_kind (infer_kind), default_hint (hint) {} InferType::InferType (HirId ref, HirId ty_ref, InferTypeKind infer_kind, - TypeHint hint, Location locus, std::set<HirId> refs) + TypeHint hint, location_t locus, std::set<HirId> refs) : BaseType (ref, ty_ref, TypeKind::INFER, {Resolver::CanonicalPath::create_empty (), locus}, refs), infer_kind (infer_kind), default_hint (hint) @@ -1315,7 +1315,7 @@ ErrorType::clone () const // Struct Field type StructFieldType::StructFieldType (HirId ref, std::string name, BaseType *ty, - Location locus) + location_t locus) : ref (ref), name (name), ty (ty), locus (locus) {} @@ -1805,14 +1805,14 @@ ADTType::handle_substitions (SubstitutionArgumentMappings &subst_mappings) // TupleType -TupleType::TupleType (HirId ref, Location locus, std::vector<TyVar> fields, +TupleType::TupleType (HirId ref, location_t locus, std::vector<TyVar> fields, std::set<HirId> refs) : BaseType (ref, ref, TypeKind::TUPLE, {Resolver::CanonicalPath::create_empty (), locus}, refs), fields (fields) {} -TupleType::TupleType (HirId ref, HirId ty_ref, Location locus, +TupleType::TupleType (HirId ref, HirId ty_ref, location_t locus, std::vector<TyVar> fields, std::set<HirId> refs) : BaseType (ref, ty_ref, TypeKind::TUPLE, {Resolver::CanonicalPath::create_empty (), locus}, refs), @@ -3249,7 +3249,7 @@ PointerType::handle_substitions (SubstitutionArgumentMappings &mappings) // PARAM Type -ParamType::ParamType (std::string symbol, Location locus, HirId ref, +ParamType::ParamType (std::string symbol, location_t locus, HirId ref, HIR::GenericParam ¶m, std::vector<TypeBoundPredicate> specified_bounds, std::set<HirId> refs) @@ -3260,7 +3260,7 @@ ParamType::ParamType (std::string symbol, Location locus, HirId ref, is_trait_self (false), symbol (symbol), param (param) {} -ParamType::ParamType (bool is_trait_self, std::string symbol, Location locus, +ParamType::ParamType (bool is_trait_self, std::string symbol, location_t locus, HirId ref, HirId ty_ref, HIR::GenericParam ¶m, std::vector<TypeBoundPredicate> specified_bounds, std::set<HirId> refs) diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h index 45c0545..fa95611 100644 --- a/gcc/rust/typecheck/rust-tyty.h +++ b/gcc/rust/typecheck/rust-tyty.h @@ -116,7 +116,7 @@ public: bool satisfies_bound (const TypeBoundPredicate &predicate, bool emit_error) const; - bool bounds_compatible (const BaseType &other, Location locus, + bool bounds_compatible (const BaseType &other, location_t locus, bool emit_error) const; void inherit_bounds (const BaseType &other); void inherit_bounds ( @@ -218,11 +218,11 @@ public: } }; - InferType (HirId ref, InferTypeKind infer_kind, TypeHint hint, Location locus, - std::set<HirId> refs = std::set<HirId> ()); + InferType (HirId ref, InferTypeKind infer_kind, TypeHint hint, + location_t locus, std::set<HirId> refs = std::set<HirId> ()); InferType (HirId ref, HirId ty_ref, InferTypeKind infer_kind, TypeHint hint, - Location locus, std::set<HirId> refs = std::set<HirId> ()); + location_t locus, std::set<HirId> refs = std::set<HirId> ()); void accept_vis (TyVisitor &vis) override; void accept_vis (TyConstVisitor &vis) const override; @@ -269,13 +269,13 @@ public: class ParamType : public BaseType { public: - ParamType (std::string symbol, Location locus, HirId ref, + ParamType (std::string symbol, location_t locus, HirId ref, HIR::GenericParam ¶m, std::vector<TypeBoundPredicate> specified_bounds, std::set<HirId> refs = std::set<HirId> ()); - ParamType (bool is_trait_self, std::string symbol, Location locus, HirId ref, - HirId ty_ref, HIR::GenericParam ¶m, + ParamType (bool is_trait_self, std::string symbol, location_t locus, + HirId ref, HirId ty_ref, HIR::GenericParam ¶m, std::vector<TypeBoundPredicate> specified_bounds, std::set<HirId> refs = std::set<HirId> ()); @@ -314,7 +314,7 @@ private: class StructFieldType { public: - StructFieldType (HirId ref, std::string name, BaseType *ty, Location locus); + StructFieldType (HirId ref, std::string name, BaseType *ty, location_t locus); HirId get_ref () const; @@ -336,17 +336,17 @@ private: HirId ref; std::string name; BaseType *ty; - Location locus; + location_t locus; }; class TupleType : public BaseType { public: - TupleType (HirId ref, Location locus, + TupleType (HirId ref, location_t locus, std::vector<TyVar> fields = std::vector<TyVar> (), std::set<HirId> refs = std::set<HirId> ()); - TupleType (HirId ref, HirId ty_ref, Location locus, + TupleType (HirId ref, HirId ty_ref, location_t locus, std::vector<TyVar> fields = std::vector<TyVar> (), std::set<HirId> refs = std::set<HirId> ()); @@ -381,11 +381,11 @@ class TypeBoundPredicate : public SubstitutionRef { public: TypeBoundPredicate (const Resolver::TraitReference &trait_reference, - Location locus); + location_t locus); TypeBoundPredicate (DefId reference, std::vector<SubstitutionParamMapping> substitutions, - Location locus); + location_t locus); TypeBoundPredicate (const TypeBoundPredicate &other); @@ -407,7 +407,7 @@ public: // check that this predicate is object-safe see: // https://doc.rust-lang.org/reference/items/traits.html#object-safety - bool is_object_safe (bool emit_error, Location locus) const; + bool is_object_safe (bool emit_error, location_t locus) const; void apply_generic_arguments (HIR::GenericArgs *generic_args, bool has_associated_self); @@ -443,7 +443,7 @@ public: private: DefId reference; - Location locus; + location_t locus; bool error_flag; }; @@ -761,14 +761,14 @@ private: class FnPtr : public BaseType { public: - FnPtr (HirId ref, Location locus, std::vector<TyVar> params, + FnPtr (HirId ref, location_t locus, std::vector<TyVar> params, TyVar result_type, std::set<HirId> refs = std::set<HirId> ()) : BaseType (ref, ref, TypeKind::FNPTR, {Resolver::CanonicalPath::create_empty (), locus}, refs), params (std::move (params)), result_type (result_type) {} - FnPtr (HirId ref, HirId ty_ref, Location locus, std::vector<TyVar> params, + FnPtr (HirId ref, HirId ty_ref, location_t locus, std::vector<TyVar> params, TyVar result_type, std::set<HirId> refs = std::set<HirId> ()) : BaseType (ref, ty_ref, TypeKind::FNPTR, {Resolver::CanonicalPath::create_empty (), locus}, refs), @@ -876,15 +876,16 @@ private: class ArrayType : public BaseType { public: - ArrayType (HirId ref, Location locus, HIR::Expr &capacity_expr, TyVar base, + ArrayType (HirId ref, location_t locus, HIR::Expr &capacity_expr, TyVar base, std::set<HirId> refs = std::set<HirId> ()) : BaseType (ref, ref, TypeKind::ARRAY, {Resolver::CanonicalPath::create_empty (), locus}, refs), element_type (base), capacity_expr (capacity_expr) {} - ArrayType (HirId ref, HirId ty_ref, Location locus, HIR::Expr &capacity_expr, - TyVar base, std::set<HirId> refs = std::set<HirId> ()) + ArrayType (HirId ref, HirId ty_ref, location_t locus, + HIR::Expr &capacity_expr, TyVar base, + std::set<HirId> refs = std::set<HirId> ()) : BaseType (ref, ty_ref, TypeKind::ARRAY, {Resolver::CanonicalPath::create_empty (), locus}, refs), element_type (base), capacity_expr (capacity_expr) @@ -918,14 +919,14 @@ private: class SliceType : public BaseType { public: - SliceType (HirId ref, Location locus, TyVar base, + SliceType (HirId ref, location_t locus, TyVar base, std::set<HirId> refs = std::set<HirId> ()) : BaseType (ref, ref, TypeKind::SLICE, {Resolver::CanonicalPath::create_empty (), locus}, refs), element_type (base) {} - SliceType (HirId ref, HirId ty_ref, Location locus, TyVar base, + SliceType (HirId ref, HirId ty_ref, location_t locus, TyVar base, std::set<HirId> refs = std::set<HirId> ()) : BaseType (ref, ty_ref, TypeKind::SLICE, {Resolver::CanonicalPath::create_empty (), locus}, refs), diff --git a/gcc/rust/typecheck/rust-unify.cc b/gcc/rust/typecheck/rust-unify.cc index 6a526e2..43cb57b 100644 --- a/gcc/rust/typecheck/rust-unify.cc +++ b/gcc/rust/typecheck/rust-unify.cc @@ -22,7 +22,7 @@ namespace Rust { namespace Resolver { UnifyRules::UnifyRules (TyTy::TyWithLocation lhs, TyTy::TyWithLocation rhs, - Location locus, bool commit_flag, bool emit_error, + location_t locus, bool commit_flag, bool emit_error, bool infer, std::vector<CommitSite> &commits, std::vector<InferenceSite> &infers) : lhs (lhs), rhs (rhs), locus (locus), commit_flag (commit_flag), @@ -33,7 +33,7 @@ UnifyRules::UnifyRules (TyTy::TyWithLocation lhs, TyTy::TyWithLocation rhs, TyTy::BaseType * UnifyRules::Resolve (TyTy::TyWithLocation lhs, TyTy::TyWithLocation rhs, - Location locus, bool commit_flag, bool emit_error, + location_t locus, bool commit_flag, bool emit_error, bool infer, std::vector<CommitSite> &commits, std::vector<InferenceSite> &infers) { diff --git a/gcc/rust/typecheck/rust-unify.h b/gcc/rust/typecheck/rust-unify.h index 4867746..83fbfb5 100644 --- a/gcc/rust/typecheck/rust-unify.h +++ b/gcc/rust/typecheck/rust-unify.h @@ -43,7 +43,7 @@ public: }; static TyTy::BaseType *Resolve (TyTy::TyWithLocation lhs, - TyTy::TyWithLocation rhs, Location locus, + TyTy::TyWithLocation rhs, location_t locus, bool commit_flag, bool emit_error, bool infer, std::vector<CommitSite> &commits, std::vector<InferenceSite> &infers); @@ -85,7 +85,7 @@ protected: private: UnifyRules (TyTy::TyWithLocation lhs, TyTy::TyWithLocation rhs, - Location locus, bool commit_flag, bool emit_error, bool infer, + location_t locus, bool commit_flag, bool emit_error, bool infer, std::vector<CommitSite> &commits, std::vector<InferenceSite> &infers); @@ -100,7 +100,7 @@ private: TyTy::TyWithLocation lhs; TyTy::TyWithLocation rhs; - Location locus; + location_t locus; bool commit_flag; bool emit_error; bool infer_flag; diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc index 9510a5b..c969636 100644 --- a/gcc/rust/util/rust-hir-map.cc +++ b/gcc/rust/util/rust-hir-map.cc @@ -792,7 +792,7 @@ Mappings::lookup_hir_to_node (HirId id, NodeId *ref) } void -Mappings::insert_location (HirId id, Location locus) +Mappings::insert_location (HirId id, location_t locus) { locations[id] = locus; } diff --git a/gcc/rust/util/rust-hir-map.h b/gcc/rust/util/rust-hir-map.h index 5b8e09c..7f3f4fb 100644 --- a/gcc/rust/util/rust-hir-map.h +++ b/gcc/rust/util/rust-hir-map.h @@ -171,7 +171,7 @@ public: bool lookup_node_to_hir (NodeId id, HirId *ref); bool lookup_hir_to_node (HirId id, NodeId *ref); - void insert_location (HirId id, Location locus); + void insert_location (HirId id, location_t locus); Location lookup_location (HirId id); bool resolve_nodeid_to_stmt (NodeId id, HIR::Stmt **stmt); diff --git a/gcc/rust/util/rust-identifier.h b/gcc/rust/util/rust-identifier.h index adf1c07..cbb743c 100644 --- a/gcc/rust/util/rust-identifier.h +++ b/gcc/rust/util/rust-identifier.h @@ -27,9 +27,9 @@ namespace Rust { struct RustIdent { Resolver::CanonicalPath path; - Location locus; + location_t locus; - RustIdent (const Resolver::CanonicalPath &path, Location locus) + RustIdent (const Resolver::CanonicalPath &path, location_t locus) : path (path), locus (locus) {} |