aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/rust/ast/rust-ast-builder.h4
-rw-r--r--gcc/rust/ast/rust-ast.h11
-rw-r--r--gcc/rust/ast/rust-expr.h18
-rw-r--r--gcc/rust/ast/rust-item.h16
-rw-r--r--gcc/rust/ast/rust-macro.h42
-rw-r--r--gcc/rust/ast/rust-path.h2
-rw-r--r--gcc/rust/hir/tree/rust-hir-expr.h12
-rw-r--r--gcc/rust/hir/tree/rust-hir-item.h6
-rw-r--r--gcc/rust/hir/tree/rust-hir-path.h2
-rw-r--r--gcc/rust/hir/tree/rust-hir.h2
-rw-r--r--gcc/rust/lex/rust-lex.cc32
-rw-r--r--gcc/rust/lex/rust-lex.h26
12 files changed, 88 insertions, 85 deletions
diff --git a/gcc/rust/ast/rust-ast-builder.h b/gcc/rust/ast/rust-ast-builder.h
index 524b390..0ee36ff 100644
--- a/gcc/rust/ast/rust-ast-builder.h
+++ b/gcc/rust/ast/rust-ast-builder.h
@@ -31,7 +31,7 @@ namespace AST {
class AstBuilder
{
public:
- AstBuilder (Location loc) : loc (loc) {}
+ AstBuilder (location_t loc) : loc (loc) {}
/* Create an identifier expression (`variable`) */
std::unique_ptr<Expr> identifier (std::string name);
@@ -107,7 +107,7 @@ private:
/**
* Location of the generated AST nodes
*/
- Location loc;
+ location_t loc;
};
} // namespace AST
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index f46925a..3f154ef 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -41,7 +41,7 @@ public:
loc (UNDEF_LOCATION)
{}
// Create identifier with dummy location
- Identifier (std::string ident, Location loc = UNDEF_LOCATION)
+ Identifier (std::string ident, location_t loc = UNDEF_LOCATION)
: ident (ident), node_id (Analysis::Mappings::get ()->get_next_node_id ()),
loc (loc)
{}
@@ -66,7 +66,7 @@ public:
private:
std::string ident;
NodeId node_id;
- Location loc;
+ location_t loc;
};
std::ostream &
@@ -157,7 +157,7 @@ public:
virtual ~MacroMatch () {}
virtual std::string as_string () const = 0;
- virtual Location get_match_locus () const = 0;
+ virtual location_t get_match_locus () const = 0;
// Unique pointer custom clone function
std::unique_ptr<MacroMatch> clone_macro_match () const
@@ -264,7 +264,10 @@ public:
}
std::string as_string () const override;
- Location get_match_locus () const override { return tok_ref->get_locus (); };
+ location_t get_match_locus () const override
+ {
+ return tok_ref->get_locus ();
+ };
void accept_vis (ASTVisitor &vis) override;
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h
index b3aa417..69937bf 100644
--- a/gcc/rust/ast/rust-expr.h
+++ b/gcc/rust/ast/rust-expr.h
@@ -2396,8 +2396,8 @@ class BlockExpr : public ExprWithBlock
std::vector<Attribute> inner_attrs;
std::vector<std::unique_ptr<Stmt> > statements;
std::unique_ptr<Expr> expr;
- Location start_locus;
- Location end_locus;
+ location_t start_locus;
+ location_t end_locus;
bool marked_for_strip = false;
public:
@@ -2412,8 +2412,8 @@ public:
BlockExpr (std::vector<std::unique_ptr<Stmt> > block_statements,
std::unique_ptr<Expr> block_expr,
std::vector<Attribute> inner_attribs,
- std::vector<Attribute> outer_attribs, Location start_locus,
- Location end_locus)
+ std::vector<Attribute> outer_attribs, location_t start_locus,
+ location_t end_locus)
: outer_attrs (std::move (outer_attribs)),
inner_attrs (std::move (inner_attribs)),
statements (std::move (block_statements)), expr (std::move (block_expr)),
@@ -2470,8 +2470,8 @@ public:
location_t get_locus () const override final { return start_locus; }
- Location get_start_locus () const { return start_locus; }
- Location get_end_locus () const { return end_locus; }
+ location_t get_start_locus () const { return start_locus; }
+ location_t get_end_locus () const { return end_locus; }
void accept_vis (ASTVisitor &vis) override;
@@ -4596,7 +4596,7 @@ struct TupleClobber
{
// as gccrs still doesen't contain a symbol class I have put them as strings
std::string symbol;
- Location loc;
+ location_t loc;
};
struct TupleTemplateStr
@@ -4604,7 +4604,7 @@ struct TupleTemplateStr
// as gccrs still doesen't contain a symbol class I have put them as strings
std::string symbol;
std::string optional_symbol;
- Location loc;
+ location_t loc;
};
// Inline Assembly Node
@@ -4616,7 +4616,7 @@ public:
std::vector<InlineAsmOperand> operands;
TupleClobber clobber_abi;
InlineAsmOptions options;
- std::vector<Location> line_spans;
+ std::vector<location_t> line_spans;
};
} // namespace AST
diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h
index 365b20b..dad20c7 100644
--- a/gcc/rust/ast/rust-item.h
+++ b/gcc/rust/ast/rust-item.h
@@ -667,14 +667,14 @@ public:
// Creates a public visibility with no further features/arguments.
// empty?
- static Visibility create_public (Location pub_vis_location)
+ static Visibility create_public (location_t pub_vis_location)
{
return Visibility (PUB, SimplePath::create_empty (), pub_vis_location);
}
// Creates a public visibility with crate-relative paths
- static Visibility create_crate (Location crate_tok_location,
- Location crate_vis_location)
+ static Visibility create_crate (location_t crate_tok_location,
+ location_t crate_vis_location)
{
return Visibility (PUB_CRATE,
SimplePath::from_str ("crate", crate_tok_location),
@@ -682,8 +682,8 @@ public:
}
// Creates a public visibility with self-relative paths
- static Visibility create_self (Location self_tok_location,
- Location self_vis_location)
+ static Visibility create_self (location_t self_tok_location,
+ location_t self_vis_location)
{
return Visibility (PUB_SELF,
SimplePath::from_str ("self", self_tok_location),
@@ -691,8 +691,8 @@ public:
}
// Creates a public visibility with parent module-relative paths
- static Visibility create_super (Location super_tok_location,
- Location super_vis_location)
+ static Visibility create_super (location_t super_tok_location,
+ location_t super_vis_location)
{
return Visibility (PUB_SUPER,
SimplePath::from_str ("super", super_tok_location),
@@ -707,7 +707,7 @@ public:
// Creates a public visibility with a given path or whatever.
static Visibility create_in_path (SimplePath in_path,
- Location in_path_vis_location)
+ location_t in_path_vis_location)
{
return Visibility (PUB_IN_PATH, std::move (in_path), in_path_vis_location);
}
diff --git a/gcc/rust/ast/rust-macro.h b/gcc/rust/ast/rust-macro.h
index 78941f8..a9d5b95 100644
--- a/gcc/rust/ast/rust-macro.h
+++ b/gcc/rust/ast/rust-macro.h
@@ -190,7 +190,7 @@ public:
}
std::string as_string () const override;
- Location get_match_locus () const override { return locus; };
+ location_t get_match_locus () const override { return locus; };
void accept_vis (ASTVisitor &vis) override;
@@ -281,7 +281,7 @@ public:
MacroMatchRepetition &operator= (MacroMatchRepetition &&other) = default;
std::string as_string () const override;
- Location get_match_locus () const override { return locus; };
+ location_t get_match_locus () const override { return locus; };
void accept_vis (ASTVisitor &vis) override;
@@ -359,7 +359,7 @@ public:
// Returns whether MacroMatcher is in an error state.
bool is_error () const { return is_invalid; }
- Location get_match_locus () const override { return locus; }
+ location_t get_match_locus () const override { return locus; }
std::string as_string () const override;
@@ -468,7 +468,7 @@ private:
std::vector<MacroRule> rules; // inlined form
location_t locus;
- std::function<Fragment (Location, MacroInvocData &)> associated_transcriber;
+ std::function<Fragment (location_t, MacroInvocData &)> associated_transcriber;
// Since we can't compare std::functions, we need to use an extra boolean
bool is_builtin_rule;
MacroKind kind;
@@ -480,7 +480,7 @@ private:
* should make use of the actual rules. If the macro is builtin, then another
* associated transcriber should be used
*/
- static Fragment dummy_builtin (Location, MacroInvocData &)
+ static Fragment dummy_builtin (location_t, MacroInvocData &)
{
rust_unreachable ();
return Fragment::create_error ();
@@ -502,10 +502,10 @@ private:
kind (kind)
{}
- MacroRulesDefinition (
- Identifier builtin_name, DelimType delim_type,
- std::function<Fragment (Location, MacroInvocData &)> associated_transcriber,
- MacroKind kind, Visibility vis)
+ MacroRulesDefinition (Identifier builtin_name, DelimType delim_type,
+ std::function<Fragment (location_t, MacroInvocData &)>
+ associated_transcriber,
+ MacroKind kind, Visibility vis)
: VisItem (std::move (vis), std::vector<Attribute> ()),
outer_attrs (std::vector<Attribute> ()), rule_name (builtin_name),
delim_type (delim_type), rules (std::vector<MacroRule> ()),
@@ -560,14 +560,14 @@ public:
const std::vector<MacroRule> &get_rules () const { return rules; }
bool is_builtin () const { return is_builtin_rule; }
- const std::function<Fragment (Location, MacroInvocData &)> &
+ const std::function<Fragment (location_t, MacroInvocData &)> &
get_builtin_transcriber () const
{
rust_assert (is_builtin ());
return associated_transcriber;
}
void set_builtin_transcriber (
- std::function<Fragment (Location, MacroInvocData &)> transcriber)
+ std::function<Fragment (location_t, MacroInvocData &)> transcriber)
{
associated_transcriber = transcriber;
is_builtin_rule = true;
@@ -926,10 +926,10 @@ protected:
class MetaWord : public MetaItem
{
Identifier ident;
- Location ident_locus;
+ location_t ident_locus;
public:
- MetaWord (Identifier ident, Location ident_locus)
+ MetaWord (Identifier ident, location_t ident_locus)
: ident (std::move (ident)), ident_locus (ident_locus)
{}
@@ -962,15 +962,15 @@ protected:
class MetaNameValueStr : public MetaItem
{
Identifier ident;
- Location ident_locus;
+ location_t ident_locus;
// NOTE: str stored without quotes
std::string str;
- Location str_locus;
+ location_t str_locus;
public:
- MetaNameValueStr (Identifier ident, Location ident_locus, std::string str,
- Location str_locus)
+ MetaNameValueStr (Identifier ident, location_t ident_locus, std::string str,
+ location_t str_locus)
: ident (std::move (ident)), ident_locus (ident_locus),
str (std::move (str)), str_locus (str_locus)
{}
@@ -1019,11 +1019,11 @@ protected:
class MetaListPaths : public MetaItem
{
Identifier ident;
- Location ident_locus;
+ location_t ident_locus;
std::vector<SimplePath> paths;
public:
- MetaListPaths (Identifier ident, Location ident_locus,
+ MetaListPaths (Identifier ident, location_t ident_locus,
std::vector<SimplePath> paths)
: ident (std::move (ident)), ident_locus (ident_locus),
paths (std::move (paths))
@@ -1064,11 +1064,11 @@ protected:
class MetaListNameValueStr : public MetaItem
{
Identifier ident;
- Location ident_locus;
+ location_t ident_locus;
std::vector<MetaNameValueStr> strs;
public:
- MetaListNameValueStr (Identifier ident, Location ident_locus,
+ MetaListNameValueStr (Identifier ident, location_t ident_locus,
std::vector<MetaNameValueStr> strs)
: ident (std::move (ident)), ident_locus (ident_locus),
strs (std::move (strs))
diff --git a/gcc/rust/ast/rust-path.h b/gcc/rust/ast/rust-path.h
index 12326a3..14524c7 100644
--- a/gcc/rust/ast/rust-path.h
+++ b/gcc/rust/ast/rust-path.h
@@ -209,7 +209,7 @@ public:
bool is_error () const { return kind == Kind::Error; }
Kind get_kind () const { return kind; }
- const Location &get_locus () const { return locus; }
+ location_t get_locus () const { return locus; }
void accept_vis (AST::ASTVisitor &visitor)
{
diff --git a/gcc/rust/hir/tree/rust-hir-expr.h b/gcc/rust/hir/tree/rust-hir-expr.h
index e180d6c..f0e9a36 100644
--- a/gcc/rust/hir/tree/rust-hir-expr.h
+++ b/gcc/rust/hir/tree/rust-hir-expr.h
@@ -2121,8 +2121,8 @@ public:
std::vector<std::unique_ptr<Stmt> > statements;
std::unique_ptr<Expr> expr;
bool tail_reachable;
- Location start_locus;
- Location end_locus;
+ location_t start_locus;
+ location_t end_locus;
std::string as_string () const override;
@@ -2140,7 +2140,7 @@ public:
std::vector<std::unique_ptr<Stmt> > block_statements,
std::unique_ptr<Expr> block_expr, bool tail_reachable,
AST::AttrVec inner_attribs, AST::AttrVec outer_attribs,
- Location start_locus, Location end_locus)
+ location_t start_locus, location_t end_locus)
: ExprWithBlock (std::move (mappings), std::move (outer_attribs)),
WithInnerAttrs (std::move (inner_attribs)),
statements (std::move (block_statements)), expr (std::move (block_expr)),
@@ -2193,9 +2193,9 @@ public:
location_t get_locus () const override final { return start_locus; }
- Location get_start_locus () const { return start_locus; }
+ location_t get_start_locus () const { return start_locus; }
- Location get_end_locus () const { return end_locus; }
+ location_t get_end_locus () const { return end_locus; }
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRExpressionVisitor &vis) override;
@@ -3935,7 +3935,7 @@ public:
std::vector<AST::TupleTemplateStr> template_strs;
std::vector<AST::InlineAsmOperand> operands;
AST::InlineAsmOptions options;
- std::vector<Location> line_spans;
+ std::vector<location_t> line_spans;
};
} // namespace HIR
} // namespace Rust
diff --git a/gcc/rust/hir/tree/rust-hir-item.h b/gcc/rust/hir/tree/rust-hir-item.h
index cb0dc13..75e02e9 100644
--- a/gcc/rust/hir/tree/rust-hir-item.h
+++ b/gcc/rust/hir/tree/rust-hir-item.h
@@ -2406,7 +2406,7 @@ public:
return outer_attrs;
}
- Location get_trait_locus () const override { return get_locus (); }
+ location_t get_trait_locus () const override { return get_locus (); }
protected:
// Clone function implementation as (not pure) virtual method
@@ -2493,7 +2493,7 @@ public:
return outer_attrs;
}
- Location get_trait_locus () const override { return get_locus (); }
+ location_t get_trait_locus () const override { return get_locus (); }
protected:
// Clone function implementation as (not pure) virtual method
@@ -2585,7 +2585,7 @@ public:
return outer_attrs;
}
- Location get_trait_locus () const override { return get_locus (); }
+ location_t get_trait_locus () const override { return get_locus (); }
protected:
// Clone function implementation as (not pure) virtual method
diff --git a/gcc/rust/hir/tree/rust-hir-path.h b/gcc/rust/hir/tree/rust-hir-path.h
index 80456e8..b7644b8 100644
--- a/gcc/rust/hir/tree/rust-hir-path.h
+++ b/gcc/rust/hir/tree/rust-hir-path.h
@@ -1001,7 +1001,7 @@ public:
bool is_error () const { return segments.empty (); }
const Analysis::NodeMapping &get_mappings () const { return mappings; }
- const Location &get_locus () const { return locus; }
+ location_t get_locus () const { return locus; }
};
} // namespace HIR
diff --git a/gcc/rust/hir/tree/rust-hir.h b/gcc/rust/hir/tree/rust-hir.h
index aac4b2d..76b6c73 100644
--- a/gcc/rust/hir/tree/rust-hir.h
+++ b/gcc/rust/hir/tree/rust-hir.h
@@ -814,7 +814,7 @@ public:
const Analysis::NodeMapping &get_mappings () const { return mappings; }
- virtual Location get_trait_locus () const = 0;
+ virtual location_t get_trait_locus () const = 0;
virtual TraitItemKind get_item_kind () const = 0;
diff --git a/gcc/rust/lex/rust-lex.cc b/gcc/rust/lex/rust-lex.cc
index ee91d02..8c575a7 100644
--- a/gcc/rust/lex/rust-lex.cc
+++ b/gcc/rust/lex/rust-lex.cc
@@ -173,7 +173,7 @@ Lexer::input_source_is_valid_utf8 ()
return raw_input_source->is_valid ();
}
-Location
+location_t
Lexer::get_current_location ()
{
if (line_map)
@@ -230,7 +230,7 @@ Lexer::dump_and_skip (int n)
tok = peek_token ();
found_eof |= tok->get_id () == Rust::END_OF_FILE;
- Location loc = tok->get_locus ();
+ location_t loc = tok->get_locus ();
out << "<id=";
out << tok->token_id_to_str ();
@@ -302,7 +302,7 @@ Lexer::build_token ()
// loop to go through multiple characters to build a single token
while (true)
{
- Location loc = get_current_location ();
+ location_t loc = get_current_location ();
current_char = peek_input ();
skip_input ();
@@ -1699,7 +1699,7 @@ Lexer::parse_partial_unicode_escape ()
// Parses a byte character.
TokenPtr
-Lexer::parse_byte_char (Location loc)
+Lexer::parse_byte_char (location_t loc)
{
skip_input ();
current_column++;
@@ -1767,7 +1767,7 @@ Lexer::parse_byte_char (Location loc)
// Parses a byte string.
TokenPtr
-Lexer::parse_byte_string (Location loc)
+Lexer::parse_byte_string (location_t loc)
{
// byte string
@@ -1833,7 +1833,7 @@ Lexer::parse_byte_string (Location loc)
// Parses a raw byte string.
TokenPtr
-Lexer::parse_raw_byte_string (Location loc)
+Lexer::parse_raw_byte_string (location_t loc)
{
// raw byte string literals
std::string str;
@@ -1916,7 +1916,7 @@ Lexer::parse_raw_byte_string (Location loc)
// Parses a raw identifier.
TokenPtr
-Lexer::parse_raw_identifier (Location loc)
+Lexer::parse_raw_identifier (location_t loc)
{
// raw identifier
std::string str;
@@ -1998,7 +1998,7 @@ Lexer::skip_broken_string_input (Codepoint current_char)
// Parses a string.
TokenPtr
-Lexer::parse_string (Location loc)
+Lexer::parse_string (location_t loc)
{
std::string str;
str.reserve (16); // some sensible default
@@ -2063,7 +2063,7 @@ Lexer::parse_string (Location loc)
// Parses an identifier or keyword.
TokenPtr
-Lexer::parse_identifier_or_keyword (Location loc)
+Lexer::parse_identifier_or_keyword (location_t loc)
{
std::string str;
str.reserve (16); // default
@@ -2104,7 +2104,7 @@ Lexer::parse_identifier_or_keyword (Location loc)
// Possibly returns a raw string token if it exists - otherwise returns null.
TokenPtr
-Lexer::maybe_parse_raw_string (Location loc)
+Lexer::maybe_parse_raw_string (location_t loc)
{
int peek_index = 0;
while (peek_input (peek_index) == '#')
@@ -2118,7 +2118,7 @@ Lexer::maybe_parse_raw_string (Location loc)
// Returns a raw string token.
TokenPtr
-Lexer::parse_raw_string (Location loc, int initial_hash_count)
+Lexer::parse_raw_string (location_t loc, int initial_hash_count)
{
// raw string literals
std::string str;
@@ -2181,7 +2181,7 @@ Lexer::parse_raw_string (Location loc, int initial_hash_count)
template <typename IsDigitFunc>
TokenPtr
-Lexer::parse_non_decimal_int_literal (Location loc, IsDigitFunc is_digit_func,
+Lexer::parse_non_decimal_int_literal (location_t loc, IsDigitFunc is_digit_func,
std::string existent_str, int base)
{
int length = 1;
@@ -2245,7 +2245,7 @@ Lexer::parse_non_decimal_int_literal (Location loc, IsDigitFunc is_digit_func,
// Parses a hex, binary or octal int literal.
TokenPtr
-Lexer::parse_non_decimal_int_literals (Location loc)
+Lexer::parse_non_decimal_int_literals (location_t loc)
{
std::string str;
str.reserve (16); // some sensible default
@@ -2278,7 +2278,7 @@ Lexer::parse_non_decimal_int_literals (Location loc)
// Parses a decimal-based int literal or float literal.
TokenPtr
-Lexer::parse_decimal_int_or_float (Location loc)
+Lexer::parse_decimal_int_or_float (location_t loc)
{
std::string str;
str.reserve (16); // some sensible default
@@ -2417,7 +2417,7 @@ Lexer::parse_decimal_int_or_float (Location loc)
}
TokenPtr
-Lexer::parse_char_or_lifetime (Location loc)
+Lexer::parse_char_or_lifetime (location_t loc)
{
int length = 1;
@@ -2511,7 +2511,7 @@ Lexer::split_current_token (TokenId new_left, TokenId new_right)
{
/* TODO: assert that this TokenId is a "simple token" like punctuation and not
* like "IDENTIFIER"? */
- Location current_loc = peek_token ()->get_locus ();
+ location_t current_loc = peek_token ()->get_locus ();
TokenPtr new_left_tok = Token::make (new_left, current_loc);
TokenPtr new_right_tok = Token::make (new_right, current_loc + 1);
diff --git a/gcc/rust/lex/rust-lex.h b/gcc/rust/lex/rust-lex.h
index 1bb35ae..e85b562 100644
--- a/gcc/rust/lex/rust-lex.h
+++ b/gcc/rust/lex/rust-lex.h
@@ -112,7 +112,7 @@ class Lexer
{
private:
// Request new Location for current column in line_table
- Location get_current_location ();
+ location_t get_current_location ();
// Skips the current input char.
void skip_input ();
@@ -138,20 +138,20 @@ private:
void skip_broken_string_input (Codepoint current_char);
- TokenPtr parse_byte_char (Location loc);
- TokenPtr parse_byte_string (Location loc);
- TokenPtr parse_raw_byte_string (Location loc);
- TokenPtr parse_raw_identifier (Location loc);
- TokenPtr parse_string (Location loc);
- TokenPtr maybe_parse_raw_string (Location loc);
- TokenPtr parse_raw_string (Location loc, int initial_hash_count);
- TokenPtr parse_non_decimal_int_literals (Location loc);
- TokenPtr parse_decimal_int_or_float (Location loc);
- TokenPtr parse_char_or_lifetime (Location loc);
- TokenPtr parse_identifier_or_keyword (Location loc);
+ TokenPtr parse_byte_char (location_t loc);
+ TokenPtr parse_byte_string (location_t loc);
+ TokenPtr parse_raw_byte_string (location_t loc);
+ TokenPtr parse_raw_identifier (location_t loc);
+ TokenPtr parse_string (location_t loc);
+ TokenPtr maybe_parse_raw_string (location_t loc);
+ TokenPtr parse_raw_string (location_t loc, int initial_hash_count);
+ TokenPtr parse_non_decimal_int_literals (location_t loc);
+ TokenPtr parse_decimal_int_or_float (location_t loc);
+ TokenPtr parse_char_or_lifetime (location_t loc);
+ TokenPtr parse_identifier_or_keyword (location_t loc);
template <typename IsDigitFunc>
- TokenPtr parse_non_decimal_int_literal (Location loc,
+ TokenPtr parse_non_decimal_int_literal (location_t loc,
IsDigitFunc is_digit_func,
std::string existent_str, int base);