Skip to content

Commit

Permalink
Change class Location into typedef
Browse files Browse the repository at this point in the history
gcc/rust/ChangeLog:

	* backend/rust-compile-base.cc
	(HIRCompileBase::address_expression): Remove gcc_location method call.
	(HIRCompileBase::indirect_expression): Likewise.
	(HIRCompileBase::compile_constant_item): Likewise.
	(HIRCompileBase::named_constant_expression): Likewise.
	* backend/rust-compile-expr.cc
	(CompileExpr::visit): Remove gcc_location method call, use UNKNOWN_LOCATION to initialize.
	(CompileExpr::get_fn_addr_from_dyn): Remove gcc_location method call.
	(CompileExpr::type_cast_expression): Likewise.
	* backend/rust-compile-intrinsic.cc
	(transmute_handler): Replace "Location ().gcc_location ()" with UNKNOWN_LOCATION.
	(copy_nonoverlapping_handler): Likewise.
	(prefetch_data_handler): Likewise.
	(atomic_store_handler_inner): Likewise.
	(atomic_load_handler_inner): Likewise.
	* resolve/rust-ast-resolve-expr.cc
	(ResolveExpr::visit): Remove gcc_location method call.
	* rust-diagnostics.cc
	(rust_be_error_at): Likewise.
	(rust_be_warning_at): Likewise.
	(rust_be_fatal_error): Likewise.
	(rust_be_inform): Likewise.
	* rust-diagnostics.h
	(rust_sorry_at): Likewise.
	* rust-gcc.cc
	(Bvariable::get_tree): Likewise.
	(Gcc_backend::fill_in_fields): Likewise.
	(Gcc_backend::named_type): Likewise.
	(Gcc_backend::real_part_expression): Likewise.
	(Gcc_backend::imag_part_expression): Likewise.
	(Gcc_backend::complex_expression): Likewise.
	(Gcc_backend::convert_expression): Likewise.
	(Gcc_backend::struct_field_expression): Likewise.
	(Gcc_backend::compound_expression): Likewise.
	(Gcc_backend::conditional_expression): Likewise.
	(Gcc_backend::negation_expression): Likewise.
	(Gcc_backend::arithmetic_or_logical_expression): Likewise.
	(Gcc_backend::arithmetic_or_logical_expression_checked): Likewise.
	(Gcc_backend::comparison_expression): Likewise.
	(Gcc_backend::lazy_boolean_expression): Likewise.
	(Gcc_backend::constructor_expression): Likewise.
	(Gcc_backend::array_constructor_expression): Likewise.
	(Gcc_backend::array_initializer): Likewise.
	(Gcc_backend::array_index_expression): Likewise.
	(Gcc_backend::call_expression): Likewise.
	(Gcc_backend::assignment_statement): Likewise.
	(Gcc_backend::return_statement): Likewise.
	(Gcc_backend::exception_handler_statement): Likewise.
	(Gcc_backend::if_statement): Likewise.
	(Gcc_backend::loop_expression): Likewise.
	(Gcc_backend::exit_expression): Likewise.
	(Gcc_backend::block): Likewise.
	(Gcc_backend::convert_tree): Likewise.
	(Gcc_backend::global_variable): Likewise.
	(Gcc_backend::local_variable): Likewise.
	(Gcc_backend::parameter_variable): Likewise.
	(Gcc_backend::static_chain_variable): Likewise.
	(Gcc_backend::temporary_variable): Likewise.
	(Gcc_backend::label): Likewise.
	(Gcc_backend::goto_statement): Likewise.
	(Gcc_backend::label_address): Likewise.
	(Gcc_backend::function): Likewise.
	* rust-linemap.cc
	(Gcc_linemap::to_string): Likewise.
	(Gcc_linemap::location_file): Likewise.
	(Gcc_linemap::location_line): Likewise.
	(Gcc_linemap::location_column): Likewise.
	(Gcc_linemap::is_predeclared): Likewise.
	(Gcc_linemap::is_unknown): Likewise.
	(RichLocation::RichLocation): Likewise.
	(RichLocation::add_range): Likewise.
	(RichLocation::add_fixit_insert_before): Likewise.
	(RichLocation::add_fixit_insert_after): Likewise.
	* rust-location.h
	(class Location): Replace with typedef.
	(operator<): Remove.
	(operator==): Remove.
	(operator+): Remove.
	(operator-): Remove.
	* typecheck/rust-hir-trait-resolve.cc
	(AssociatedImplTrait::setup_associated_types): Initialize Location with UNKNOWN_LOCATION.
	* typecheck/rust-hir-type-check-stmt.cc
	(TypeCheckStmt::visit): Likewise.
	* util/rust-token-converter.cc
	(convert): Remove gcc_location method call.

Signed-off-by: Owen Avery <[email protected]>
  • Loading branch information
powerboat9 authored and philberty committed Jul 6, 2023
1 parent f261732 commit 0f898a4
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 219 deletions.
10 changes: 4 additions & 6 deletions gcc/rust/backend/rust-compile-base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ HIRCompileBase::address_expression (tree expr, Location location)
if (!mark_addressable (expr, location))
return error_mark_node;

return build_fold_addr_expr_loc (location.gcc_location (), expr);
return build_fold_addr_expr_loc (location, expr);
}

tree
Expand All @@ -434,7 +434,7 @@ HIRCompileBase::indirect_expression (tree expr, Location locus)
if (expr == error_mark_node)
return error_mark_node;

return build_fold_indirect_ref_loc (locus.gcc_location (), expr);
return build_fold_indirect_ref_loc (locus, expr);
}

std::vector<Bvariable *>
Expand Down Expand Up @@ -739,8 +739,7 @@ HIRCompileBase::compile_constant_item (
ctx->pop_fn ();

// lets fold it into a call expr
tree call
= build_call_array_loc (locus.gcc_location (), const_type, fndecl, 0, NULL);
tree call = build_call_array_loc (locus, const_type, fndecl, 0, NULL);
tree folded_expr = fold_expr (call);

return named_constant_expression (const_type, ident, folded_expr, locus);
Expand All @@ -755,8 +754,7 @@ HIRCompileBase::named_constant_expression (tree type_tree,
return error_mark_node;

tree name_tree = get_identifier_with_length (name.data (), name.length ());
tree decl
= build_decl (location.gcc_location (), CONST_DECL, name_tree, type_tree);
tree decl = build_decl (location, CONST_DECL, name_tree, type_tree);
DECL_INITIAL (decl) = const_val;
TREE_CONSTANT (decl) = 1;
TREE_READONLY (decl) = 1;
Expand Down
33 changes: 15 additions & 18 deletions gcc/rust/backend/rust-compile-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -693,9 +693,8 @@ CompileExpr::visit (HIR::WhileLoopExpr &expr)

tree condition
= CompileExpr::Compile (expr.get_predicate_expr ().get (), ctx);
tree exit_condition
= fold_build1_loc (expr.get_locus ().gcc_location (), TRUTH_NOT_EXPR,
boolean_type_node, condition);
tree exit_condition = fold_build1_loc (expr.get_locus (), TRUTH_NOT_EXPR,
boolean_type_node, condition);
tree exit_expr
= ctx->get_backend ()->exit_expression (exit_condition, expr.get_locus ());
ctx->add_statement (exit_expr);
Expand Down Expand Up @@ -1463,8 +1462,8 @@ CompileExpr::visit (HIR::MatchExpr &expr)
= ctx->get_backend ()->label_definition_statement (end_label);

// setup the switch-body-block
Location start_location; // FIXME
Location end_location; // FIXME
Location start_location = UNKNOWN_LOCATION; // FIXME
Location end_location = UNKNOWN_LOCATION; // FIXME
tree switch_body_block
= ctx->get_backend ()->block (fndecl, enclosing_scope, {}, start_location,
end_location);
Expand Down Expand Up @@ -1503,15 +1502,15 @@ CompileExpr::visit (HIR::MatchExpr &expr)
ctx->add_statement (assignment);

// go to end label
tree goto_end_label = build1_loc (arm_locus.gcc_location (), GOTO_EXPR,
void_type_node, end_label);
tree goto_end_label
= build1_loc (arm_locus, GOTO_EXPR, void_type_node, end_label);
ctx->add_statement (goto_end_label);
}

// setup the switch expression
tree match_body = ctx->pop_block ();
tree match_expr_stmt
= build2_loc (expr.get_locus ().gcc_location (), SWITCH_EXPR,
= build2_loc (expr.get_locus (), SWITCH_EXPR,
TREE_TYPE (match_scrutinee_expr_qualifier_expr),
match_scrutinee_expr_qualifier_expr, match_body);
ctx->add_statement (match_expr_stmt);
Expand Down Expand Up @@ -1830,13 +1829,12 @@ CompileExpr::get_fn_addr_from_dyn (const TyTy::DynamicObjectType *dyn,
tree vtable_ptr
= ctx->get_backend ()->struct_field_expression (receiver_ref, 1,
expr_locus);
tree vtable_array_access = build4_loc (expr_locus.gcc_location (), ARRAY_REF,
TREE_TYPE (TREE_TYPE (vtable_ptr)),
vtable_ptr, idx, NULL_TREE, NULL_TREE);
tree vtable_array_access
= build4_loc (expr_locus, ARRAY_REF, TREE_TYPE (TREE_TYPE (vtable_ptr)),
vtable_ptr, idx, NULL_TREE, NULL_TREE);

tree vcall
= build3_loc (expr_locus.gcc_location (), OBJ_TYPE_REF, expected_fntype,
vtable_array_access, receiver_ref, idx);
tree vcall = build3_loc (expr_locus, OBJ_TYPE_REF, expected_fntype,
vtable_array_access, receiver_ref, idx);

return vcall;
}
Expand Down Expand Up @@ -2113,8 +2111,8 @@ CompileExpr::type_cast_expression (tree type_to_cast_to, tree expr_tree,
else if (TREE_CODE (type_to_cast_to) == RECORD_TYPE
|| TREE_CODE (type_to_cast_to) == ARRAY_TYPE)
{
return fold_build1_loc (location.gcc_location (), VIEW_CONVERT_EXPR,
type_to_cast_to, expr_tree);
return fold_build1_loc (location, VIEW_CONVERT_EXPR, type_to_cast_to,
expr_tree);
}
else if (TREE_CODE (type_to_cast_to) == POINTER_TYPE
&& RS_DST_FLAG (TREE_TYPE (expr_tree)))
Expand Down Expand Up @@ -2143,8 +2141,7 @@ CompileExpr::type_cast_expression (tree type_to_cast_to, tree expr_tree,
location);
}

return fold_convert_loc (location.gcc_location (), type_to_cast_to,
expr_tree);
return fold_convert_loc (location, type_to_cast_to, expr_tree);
}

void
Expand Down
18 changes: 7 additions & 11 deletions gcc/rust/backend/rust-compile-intrinsic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -473,12 +473,10 @@ transmute_handler (Context *ctx, TyTy::FnType *fntype)

// Return *((orig_type*)&decl) */

tree t
= build_fold_addr_expr_loc (Location ().gcc_location (), convert_me_expr);
t = fold_build1_loc (Location ().gcc_location (), NOP_EXPR,
tree t = build_fold_addr_expr_loc (UNKNOWN_LOCATION, convert_me_expr);
t = fold_build1_loc (UNKNOWN_LOCATION, NOP_EXPR,
build_pointer_type (target_type_expr), t);
tree result_expr
= build_fold_indirect_ref_loc (Location ().gcc_location (), t);
tree result_expr = build_fold_indirect_ref_loc (UNKNOWN_LOCATION, t);

auto return_statement
= ctx->get_backend ()->return_statement (fndecl, {result_expr},
Expand Down Expand Up @@ -716,8 +714,7 @@ copy_nonoverlapping_handler (Context *ctx, TyTy::FnType *fntype)
tree memcpy_raw = nullptr;
BuiltinsContext::get ().lookup_simple_builtin ("memcpy", &memcpy_raw);
rust_assert (memcpy_raw);
auto memcpy
= build_fold_addr_expr_loc (Location ().gcc_location (), memcpy_raw);
auto memcpy = build_fold_addr_expr_loc (UNKNOWN_LOCATION, memcpy_raw);

auto copy_call
= ctx->get_backend ()->call_expression (memcpy, {dst, src, size_expr},
Expand Down Expand Up @@ -773,8 +770,7 @@ prefetch_data_handler (Context *ctx, TyTy::FnType *fntype, Prefetch kind)
auto ok
= BuiltinsContext::get ().lookup_simple_builtin ("prefetch", &prefetch_raw);
rust_assert (ok);
auto prefetch
= build_fold_addr_expr_loc (Location ().gcc_location (), prefetch_raw);
auto prefetch = build_fold_addr_expr_loc (UNKNOWN_LOCATION, prefetch_raw);

auto prefetch_call
= ctx->get_backend ()->call_expression (prefetch, {addr, rw_flag, locality},
Expand Down Expand Up @@ -870,7 +866,7 @@ atomic_store_handler_inner (Context *ctx, TyTy::FnType *fntype, int ordering)
rust_assert (atomic_store_raw);

auto atomic_store
= build_fold_addr_expr_loc (Location ().gcc_location (), atomic_store_raw);
= build_fold_addr_expr_loc (UNKNOWN_LOCATION, atomic_store_raw);

auto store_call
= ctx->get_backend ()->call_expression (atomic_store,
Expand Down Expand Up @@ -930,7 +926,7 @@ atomic_load_handler_inner (Context *ctx, TyTy::FnType *fntype, int ordering)
rust_assert (atomic_load_raw);

auto atomic_load
= build_fold_addr_expr_loc (Location ().gcc_location (), atomic_load_raw);
= build_fold_addr_expr_loc (UNKNOWN_LOCATION, atomic_load_raw);

auto load_call
= ctx->get_backend ()->call_expression (atomic_load, {src, memorder},
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/resolve/rust-ast-resolve-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ ResolveExpr::visit (AST::IdentifierExpr &expr)
and use the lower-level emit_diagnostic () instead of the more common
internal_error_no_backtrace () in order to pass our locus. */
diagnostic_finalizer (global_dc) = funny_ice_finalizer;
emit_diagnostic (DK_ICE_NOBT, expr.get_locus ().gcc_location (), -1,
emit_diagnostic (DK_ICE_NOBT, expr.get_locus (), -1,
"are you trying to break %s? how dare you?",
expr.as_string ().c_str ());
}
Expand Down
12 changes: 4 additions & 8 deletions gcc/rust/rust-diagnostics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ rust_internal_error_at (const Location location, const char *fmt, ...)
void
rust_be_error_at (const Location location, const std::string &errmsg)
{
location_t gcc_loc = location.gcc_location ();
error_at (gcc_loc, "%s", errmsg.c_str ());
error_at (location, "%s", errmsg.c_str ());
}

void
Expand Down Expand Up @@ -240,8 +239,7 @@ void
rust_be_warning_at (const Location location, int opt,
const std::string &warningmsg)
{
location_t gcc_loc = location.gcc_location ();
warning_at (gcc_loc, opt, "%s", warningmsg.c_str ());
warning_at (location, opt, "%s", warningmsg.c_str ());
}

void
Expand All @@ -257,8 +255,7 @@ rust_warning_at (const Location location, int opt, const char *fmt, ...)
void
rust_be_fatal_error (const Location location, const std::string &fatalmsg)
{
location_t gcc_loc = location.gcc_location ();
fatal_error (gcc_loc, "%s", fatalmsg.c_str ());
fatal_error (location, "%s", fatalmsg.c_str ());
}

void
Expand All @@ -274,8 +271,7 @@ rust_fatal_error (const Location location, const char *fmt, ...)
void
rust_be_inform (const Location location, const std::string &infomsg)
{
location_t gcc_loc = location.gcc_location ();
inform (gcc_loc, "%s", infomsg.c_str ());
inform (location, "%s", infomsg.c_str ());
}

void
Expand Down
3 changes: 1 addition & 2 deletions gcc/rust/rust-diagnostics.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,7 @@ struct Error

// rust_sorry_at wraps GCC diagnostic "sorry_at" to accept "Location" instead of
// "location_t"
#define rust_sorry_at(location, ...) \
sorry_at (location.gcc_location (), __VA_ARGS__)
#define rust_sorry_at(location, ...) sorry_at (location, __VA_ARGS__)

void
rust_debug_loc (const Location location, const char *fmt,
Expand Down
Loading

0 comments on commit 0f898a4

Please sign in to comment.