Skip to content

Commit

Permalink
Continue to replace usages of Location with location_t
Browse files Browse the repository at this point in the history
gcc/rust/ChangeLog:

	* backend/rust-compile-base.cc: Replace Location with location_t.
	* backend/rust-compile-base.h: Likewise.
	* backend/rust-compile-expr.cc: Likewise.
	* lex/rust-token.h: Likewise.
	* metadata/rust-import-archive.cc: Likewise.
	* metadata/rust-imports.cc: Likewise.
	* metadata/rust-imports.h: Likewise.
	* rust-backend.h: Likewise.
	* rust-diagnostics.cc: Likewise.
	* rust-diagnostics.h: Likewise.
	* rust-gcc.cc: Likewise.
	* rust-linemap.cc: Likewise.
	* util/rust-token-converter.cc: Likewise.

Signed-off-by: Owen Avery <[email protected]>
  • Loading branch information
powerboat9 authored and P-E-P committed Jul 21, 2023
1 parent 19983e8 commit ccac7ed
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 89 deletions.
4 changes: 2 additions & 2 deletions gcc/rust/backend/rust-compile-base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ HIRCompileBase::mark_addressable (tree exp, location_t locus)
}

tree
HIRCompileBase::address_expression (tree expr, Location location)
HIRCompileBase::address_expression (tree expr, location_t location)
{
if (expr == error_mark_node)
return error_mark_node;
Expand Down Expand Up @@ -748,7 +748,7 @@ HIRCompileBase::compile_constant_item (
tree
HIRCompileBase::named_constant_expression (tree type_tree,
const std::string &name,
tree const_val, Location location)
tree const_val, location_t location)
{
if (type_tree == error_mark_node || const_val == error_mark_node)
return error_mark_node;
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/backend/rust-compile-base.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class HIRCompileBase

static tree named_constant_expression (tree type_tree,
const std::string &name,
tree const_val, Location location);
tree const_val, location_t location);
};

} // namespace Compile
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/backend/rust-compile-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2070,7 +2070,7 @@ CompileExpr::compile_byte_string_literal (const HIR::LiteralExpr &expr,

tree
CompileExpr::type_cast_expression (tree type_to_cast_to, tree expr_tree,
Location location)
location_t location)
{
if (type_to_cast_to == error_mark_node || expr_tree == error_mark_node
|| TREE_TYPE (expr_tree) == error_mark_node)
Expand Down
10 changes: 5 additions & 5 deletions gcc/rust/lex/rust-token.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,32 +252,32 @@ class Token
PrimitiveCoreType type_hint;

// Token constructor from token id and location. Has a null string.
Token (TokenId token_id, Location location)
Token (TokenId token_id, location_t location)
: token_id (token_id), locus (location), str (nullptr),
type_hint (CORETYPE_UNKNOWN)
{}

// Token constructor from token id, location, and a string.
Token (TokenId token_id, Location location, std::string &&paramStr)
Token (TokenId token_id, location_t location, std::string &&paramStr)
: token_id (token_id), locus (location),
str (new std::string (std::move (paramStr))), type_hint (CORETYPE_UNKNOWN)
{}

// Token constructor from token id, location, and a char.
Token (TokenId token_id, Location location, char paramChar)
Token (TokenId token_id, location_t location, char paramChar)
: token_id (token_id), locus (location),
str (new std::string (1, paramChar)), type_hint (CORETYPE_UNKNOWN)
{}

// Token constructor from token id, location, and a "codepoint".
Token (TokenId token_id, Location location, Codepoint paramCodepoint)
Token (TokenId token_id, location_t location, Codepoint paramCodepoint)
: token_id (token_id), locus (location),
str (new std::string (paramCodepoint.as_string ())),
type_hint (CORETYPE_UNKNOWN)
{}

// Token constructor from token id, location, a string, and type hint.
Token (TokenId token_id, Location location, std::string &&paramStr,
Token (TokenId token_id, location_t location, std::string &&paramStr,
PrimitiveCoreType parType)
: token_id (token_id), locus (location),
str (new std::string (std::move (paramStr))), type_hint (parType)
Expand Down
8 changes: 4 additions & 4 deletions gcc/rust/metadata/rust-import-archive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Import::is_archive_magic (const char *bytes)
class Archive_file
{
public:
Archive_file (const std::string &filename, int fd, Location location)
Archive_file (const std::string &filename, int fd, location_t location)
: filename_ (filename), fd_ (fd), filesize_ (-1), first_member_offset_ (0),
extended_names_ (), is_thin_archive_ (false), is_big_archive_ (false),
location_ (location), nested_archives_ ()
Expand All @@ -128,7 +128,7 @@ class Archive_file
bool is_big_archive () const { return this->is_big_archive_; }

// Return the location of the import statement.
Location location () const { return this->location_; }
location_t location () const { return this->location_; }

// Read bytes.
bool read (off_t offset, off_t size, char *);
Expand Down Expand Up @@ -188,7 +188,7 @@ class Archive_file
// Whether this is a big archive.
bool is_big_archive_;
// The location of the import statements.
Location location_;
location_t location_;
// Table of nested archives.
Nested_archive_table nested_archives_;
};
Expand Down Expand Up @@ -838,7 +838,7 @@ Stream_concatenate::do_advance (size_t skip)

std::unique_ptr<Import::Stream>
Import::find_archive_export_data (const std::string &filename, int fd,
Location location)
location_t location)
{
Archive_file afile (filename, fd, location);
if (!afile.initialize ())
Expand Down
12 changes: 6 additions & 6 deletions gcc/rust/metadata/rust-imports.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ add_search_path (const std::string &path)
// later in the search path.

std::pair<std::unique_ptr<Import::Stream>, std::vector<ProcMacro::Procmacro>>
Import::open_package (const std::string &filename, Location location,
Import::open_package (const std::string &filename, location_t location,
const std::string &relative_import_path)
{
bool is_local;
Expand Down Expand Up @@ -138,7 +138,7 @@ Import::open_package (const std::string &filename, Location location,

std::pair<std::unique_ptr<Import::Stream>, std::vector<ProcMacro::Procmacro>>
Import::try_package_in_directory (const std::string &filename,
Location location)
location_t location)
{
std::string found_filename = filename;
int fd = open (found_filename.c_str (), O_RDONLY | O_BINARY);
Expand Down Expand Up @@ -229,7 +229,7 @@ Import::try_suffixes (std::string *pfilename)

std::unique_ptr<Import::Stream>
Import::find_export_data (const std::string &filename, int fd,
Location location)
location_t location)
{
// See if we can read this as an object file.
std::unique_ptr<Import::Stream> stream
Expand Down Expand Up @@ -271,7 +271,7 @@ Import::find_export_data (const std::string &filename, int fd,

std::unique_ptr<Import::Stream>
Import::find_object_export_data (const std::string &filename, int fd,
off_t offset, Location location)
off_t offset, location_t location)
{
char *buf;
size_t len;
Expand All @@ -298,7 +298,7 @@ Import::find_object_export_data (const std::string &filename, int fd,
// Construct an Import object. We make the builtin_types_ vector
// large enough to hold all the builtin types.

Import::Import (std::unique_ptr<Stream> stream, Location location)
Import::Import (std::unique_ptr<Stream> stream, location_t location)
: stream_ (std::move (stream)), location_ (location)
{}

Expand Down Expand Up @@ -358,7 +358,7 @@ Import::Stream::match_bytes (const char *bytes, size_t length)
// Require that the next LENGTH bytes from the stream match BYTES.

void
Import::Stream::require_bytes (Location location, const char *bytes,
Import::Stream::require_bytes (location_t location, const char *bytes,
size_t length)
{
const char *read;
Expand Down
8 changes: 4 additions & 4 deletions gcc/rust/metadata/rust-imports.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Import

// Give an error if the next bytes do not match STR. Advance the
// read position by the length of STR.
void require_c_string (Location location, const char *str)
void require_c_string (location_t location, const char *str)
{
this->require_bytes (location, str, strlen (str));
}
Expand Down Expand Up @@ -111,7 +111,7 @@ class Import
// exports. LOCATION is the location of the import statement.
// RELATIVE_IMPORT_PATH is used as a prefix for a relative import.
static std::pair<std::unique_ptr<Stream>, std::vector<ProcMacro::Procmacro>>
open_package (const std::string &filename, Location location,
open_package (const std::string &filename, location_t location,
const std::string &relative_import_path);

static std::pair<std::unique_ptr<Stream>, std::vector<ProcMacro::Procmacro>>
Expand All @@ -121,7 +121,7 @@ class Import
Import (std::unique_ptr<Stream>, Location);

// The location of the import statement.
Location location () const { return this->location_; }
location_t location () const { return this->location_; }

// Return the next character.
int peek_char () { return this->stream_->peek_char (); }
Expand Down Expand Up @@ -175,7 +175,7 @@ class Import
// The stream from which to read import data.
std::unique_ptr<Stream> stream_;
// The location of the import statement we are processing.
Location location_;
location_t location_;
};

// Read import data from a string.
Expand Down
24 changes: 12 additions & 12 deletions gcc/rust/rust-backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Backend
{
std::string name;
tree type;
Location location;
location_t location;

typed_identifier () : name (), type (NULL_TREE), location (UNKNOWN_LOCATION)
{}
Expand Down Expand Up @@ -116,19 +116,19 @@ class Backend
virtual tree function_type (const typed_identifier &receiver,
const std::vector<typed_identifier> &parameters,
const std::vector<typed_identifier> &results,
tree result_struct, Location location)
tree result_struct, location_t location)
= 0;

virtual tree
function_type_varadic (const typed_identifier &receiver,
const std::vector<typed_identifier> &parameters,
const std::vector<typed_identifier> &results,
tree result_struct, Location location)
tree result_struct, location_t location)
= 0;

virtual tree function_ptr_type (tree result,
const std::vector<tree> &praameters,
Location location)
location_t location)
= 0;

// Get a struct type.
Expand Down Expand Up @@ -366,10 +366,10 @@ class Backend
// be put into a unique section if possible; this is intended to
// permit the linker to garbage collect the variable if it is not
// referenced. LOCATION is where the variable was defined.
virtual Bvariable *global_variable (const std::string &name,
const std::string &asm_name, tree btype,
bool is_external, bool is_hidden,
bool in_unique_section, Location location)
virtual Bvariable *
global_variable (const std::string &name, const std::string &asm_name,
tree btype, bool is_external, bool is_hidden,
bool in_unique_section, location_t location)
= 0;

// A global variable will 1) be initialized to zero, or 2) be
Expand All @@ -394,20 +394,20 @@ class Backend
// the frontend will call init_statement to set the initial value.
virtual Bvariable *local_variable (tree function, const std::string &name,
tree type, Bvariable *decl_var,
Location location)
location_t location)
= 0;

// Create a function parameter. This is an incoming parameter, not
// a result parameter (result parameters are treated as local
// variables). The arguments are as for local_variable.
virtual Bvariable *parameter_variable (tree function, const std::string &name,
tree type, Location location)
tree type, location_t location)
= 0;

// Create a static chain parameter. This is the closure parameter.
virtual Bvariable *static_chain_variable (tree function,
const std::string &name, tree type,
Location location)
location_t location)
= 0;

// Create a temporary variable. A temporary variable has no name,
Expand All @@ -423,7 +423,7 @@ class Backend
// *PSTATEMENT to a statement which initializes the variable.
virtual Bvariable *temporary_variable (tree fndecl, tree bind_tree, tree type,
tree init, bool address_is_taken,
Location location, tree *pstatement)
location_t location, tree *pstatement)
= 0;

// Labels.
Expand Down
Loading

0 comments on commit ccac7ed

Please sign in to comment.