Skip to content

Commit 0f898a4

Browse files
powerboat9philberty
authored andcommitted
Change class Location into typedef
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]>
1 parent f261732 commit 0f898a4

12 files changed

+124
-219
lines changed

gcc/rust/backend/rust-compile-base.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ HIRCompileBase::address_expression (tree expr, Location location)
425425
if (!mark_addressable (expr, location))
426426
return error_mark_node;
427427

428-
return build_fold_addr_expr_loc (location.gcc_location (), expr);
428+
return build_fold_addr_expr_loc (location, expr);
429429
}
430430

431431
tree
@@ -434,7 +434,7 @@ HIRCompileBase::indirect_expression (tree expr, Location locus)
434434
if (expr == error_mark_node)
435435
return error_mark_node;
436436

437-
return build_fold_indirect_ref_loc (locus.gcc_location (), expr);
437+
return build_fold_indirect_ref_loc (locus, expr);
438438
}
439439

440440
std::vector<Bvariable *>
@@ -739,8 +739,7 @@ HIRCompileBase::compile_constant_item (
739739
ctx->pop_fn ();
740740

741741
// lets fold it into a call expr
742-
tree call
743-
= build_call_array_loc (locus.gcc_location (), const_type, fndecl, 0, NULL);
742+
tree call = build_call_array_loc (locus, const_type, fndecl, 0, NULL);
744743
tree folded_expr = fold_expr (call);
745744

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

757756
tree name_tree = get_identifier_with_length (name.data (), name.length ());
758-
tree decl
759-
= build_decl (location.gcc_location (), CONST_DECL, name_tree, type_tree);
757+
tree decl = build_decl (location, CONST_DECL, name_tree, type_tree);
760758
DECL_INITIAL (decl) = const_val;
761759
TREE_CONSTANT (decl) = 1;
762760
TREE_READONLY (decl) = 1;

gcc/rust/backend/rust-compile-expr.cc

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -693,9 +693,8 @@ CompileExpr::visit (HIR::WhileLoopExpr &expr)
693693

694694
tree condition
695695
= CompileExpr::Compile (expr.get_predicate_expr ().get (), ctx);
696-
tree exit_condition
697-
= fold_build1_loc (expr.get_locus ().gcc_location (), TRUTH_NOT_EXPR,
698-
boolean_type_node, condition);
696+
tree exit_condition = fold_build1_loc (expr.get_locus (), TRUTH_NOT_EXPR,
697+
boolean_type_node, condition);
699698
tree exit_expr
700699
= ctx->get_backend ()->exit_expression (exit_condition, expr.get_locus ());
701700
ctx->add_statement (exit_expr);
@@ -1463,8 +1462,8 @@ CompileExpr::visit (HIR::MatchExpr &expr)
14631462
= ctx->get_backend ()->label_definition_statement (end_label);
14641463

14651464
// setup the switch-body-block
1466-
Location start_location; // FIXME
1467-
Location end_location; // FIXME
1465+
Location start_location = UNKNOWN_LOCATION; // FIXME
1466+
Location end_location = UNKNOWN_LOCATION; // FIXME
14681467
tree switch_body_block
14691468
= ctx->get_backend ()->block (fndecl, enclosing_scope, {}, start_location,
14701469
end_location);
@@ -1503,15 +1502,15 @@ CompileExpr::visit (HIR::MatchExpr &expr)
15031502
ctx->add_statement (assignment);
15041503

15051504
// go to end label
1506-
tree goto_end_label = build1_loc (arm_locus.gcc_location (), GOTO_EXPR,
1507-
void_type_node, end_label);
1505+
tree goto_end_label
1506+
= build1_loc (arm_locus, GOTO_EXPR, void_type_node, end_label);
15081507
ctx->add_statement (goto_end_label);
15091508
}
15101509

15111510
// setup the switch expression
15121511
tree match_body = ctx->pop_block ();
15131512
tree match_expr_stmt
1514-
= build2_loc (expr.get_locus ().gcc_location (), SWITCH_EXPR,
1513+
= build2_loc (expr.get_locus (), SWITCH_EXPR,
15151514
TREE_TYPE (match_scrutinee_expr_qualifier_expr),
15161515
match_scrutinee_expr_qualifier_expr, match_body);
15171516
ctx->add_statement (match_expr_stmt);
@@ -1830,13 +1829,12 @@ CompileExpr::get_fn_addr_from_dyn (const TyTy::DynamicObjectType *dyn,
18301829
tree vtable_ptr
18311830
= ctx->get_backend ()->struct_field_expression (receiver_ref, 1,
18321831
expr_locus);
1833-
tree vtable_array_access = build4_loc (expr_locus.gcc_location (), ARRAY_REF,
1834-
TREE_TYPE (TREE_TYPE (vtable_ptr)),
1835-
vtable_ptr, idx, NULL_TREE, NULL_TREE);
1832+
tree vtable_array_access
1833+
= build4_loc (expr_locus, ARRAY_REF, TREE_TYPE (TREE_TYPE (vtable_ptr)),
1834+
vtable_ptr, idx, NULL_TREE, NULL_TREE);
18361835

1837-
tree vcall
1838-
= build3_loc (expr_locus.gcc_location (), OBJ_TYPE_REF, expected_fntype,
1839-
vtable_array_access, receiver_ref, idx);
1836+
tree vcall = build3_loc (expr_locus, OBJ_TYPE_REF, expected_fntype,
1837+
vtable_array_access, receiver_ref, idx);
18401838

18411839
return vcall;
18421840
}
@@ -2113,8 +2111,8 @@ CompileExpr::type_cast_expression (tree type_to_cast_to, tree expr_tree,
21132111
else if (TREE_CODE (type_to_cast_to) == RECORD_TYPE
21142112
|| TREE_CODE (type_to_cast_to) == ARRAY_TYPE)
21152113
{
2116-
return fold_build1_loc (location.gcc_location (), VIEW_CONVERT_EXPR,
2117-
type_to_cast_to, expr_tree);
2114+
return fold_build1_loc (location, VIEW_CONVERT_EXPR, type_to_cast_to,
2115+
expr_tree);
21182116
}
21192117
else if (TREE_CODE (type_to_cast_to) == POINTER_TYPE
21202118
&& RS_DST_FLAG (TREE_TYPE (expr_tree)))
@@ -2143,8 +2141,7 @@ CompileExpr::type_cast_expression (tree type_to_cast_to, tree expr_tree,
21432141
location);
21442142
}
21452143

2146-
return fold_convert_loc (location.gcc_location (), type_to_cast_to,
2147-
expr_tree);
2144+
return fold_convert_loc (location, type_to_cast_to, expr_tree);
21482145
}
21492146

21502147
void

gcc/rust/backend/rust-compile-intrinsic.cc

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -473,12 +473,10 @@ transmute_handler (Context *ctx, TyTy::FnType *fntype)
473473

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

476-
tree t
477-
= build_fold_addr_expr_loc (Location ().gcc_location (), convert_me_expr);
478-
t = fold_build1_loc (Location ().gcc_location (), NOP_EXPR,
476+
tree t = build_fold_addr_expr_loc (UNKNOWN_LOCATION, convert_me_expr);
477+
t = fold_build1_loc (UNKNOWN_LOCATION, NOP_EXPR,
479478
build_pointer_type (target_type_expr), t);
480-
tree result_expr
481-
= build_fold_indirect_ref_loc (Location ().gcc_location (), t);
479+
tree result_expr = build_fold_indirect_ref_loc (UNKNOWN_LOCATION, t);
482480

483481
auto return_statement
484482
= ctx->get_backend ()->return_statement (fndecl, {result_expr},
@@ -716,8 +714,7 @@ copy_nonoverlapping_handler (Context *ctx, TyTy::FnType *fntype)
716714
tree memcpy_raw = nullptr;
717715
BuiltinsContext::get ().lookup_simple_builtin ("memcpy", &memcpy_raw);
718716
rust_assert (memcpy_raw);
719-
auto memcpy
720-
= build_fold_addr_expr_loc (Location ().gcc_location (), memcpy_raw);
717+
auto memcpy = build_fold_addr_expr_loc (UNKNOWN_LOCATION, memcpy_raw);
721718

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

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

872868
auto atomic_store
873-
= build_fold_addr_expr_loc (Location ().gcc_location (), atomic_store_raw);
869+
= build_fold_addr_expr_loc (UNKNOWN_LOCATION, atomic_store_raw);
874870

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

932928
auto atomic_load
933-
= build_fold_addr_expr_loc (Location ().gcc_location (), atomic_load_raw);
929+
= build_fold_addr_expr_loc (UNKNOWN_LOCATION, atomic_load_raw);
934930

935931
auto load_call
936932
= ctx->get_backend ()->call_expression (atomic_load, {src, memorder},

gcc/rust/resolve/rust-ast-resolve-expr.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ ResolveExpr::visit (AST::IdentifierExpr &expr)
167167
and use the lower-level emit_diagnostic () instead of the more common
168168
internal_error_no_backtrace () in order to pass our locus. */
169169
diagnostic_finalizer (global_dc) = funny_ice_finalizer;
170-
emit_diagnostic (DK_ICE_NOBT, expr.get_locus ().gcc_location (), -1,
170+
emit_diagnostic (DK_ICE_NOBT, expr.get_locus (), -1,
171171
"are you trying to break %s? how dare you?",
172172
expr.as_string ().c_str ());
173173
}

gcc/rust/rust-diagnostics.cc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,7 @@ rust_internal_error_at (const Location location, const char *fmt, ...)
179179
void
180180
rust_be_error_at (const Location location, const std::string &errmsg)
181181
{
182-
location_t gcc_loc = location.gcc_location ();
183-
error_at (gcc_loc, "%s", errmsg.c_str ());
182+
error_at (location, "%s", errmsg.c_str ());
184183
}
185184

186185
void
@@ -240,8 +239,7 @@ void
240239
rust_be_warning_at (const Location location, int opt,
241240
const std::string &warningmsg)
242241
{
243-
location_t gcc_loc = location.gcc_location ();
244-
warning_at (gcc_loc, opt, "%s", warningmsg.c_str ());
242+
warning_at (location, opt, "%s", warningmsg.c_str ());
245243
}
246244

247245
void
@@ -257,8 +255,7 @@ rust_warning_at (const Location location, int opt, const char *fmt, ...)
257255
void
258256
rust_be_fatal_error (const Location location, const std::string &fatalmsg)
259257
{
260-
location_t gcc_loc = location.gcc_location ();
261-
fatal_error (gcc_loc, "%s", fatalmsg.c_str ());
258+
fatal_error (location, "%s", fatalmsg.c_str ());
262259
}
263260

264261
void
@@ -274,8 +271,7 @@ rust_fatal_error (const Location location, const char *fmt, ...)
274271
void
275272
rust_be_inform (const Location location, const std::string &infomsg)
276273
{
277-
location_t gcc_loc = location.gcc_location ();
278-
inform (gcc_loc, "%s", infomsg.c_str ());
274+
inform (location, "%s", infomsg.c_str ());
279275
}
280276

281277
void

gcc/rust/rust-diagnostics.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,7 @@ struct Error
204204

205205
// rust_sorry_at wraps GCC diagnostic "sorry_at" to accept "Location" instead of
206206
// "location_t"
207-
#define rust_sorry_at(location, ...) \
208-
sorry_at (location.gcc_location (), __VA_ARGS__)
207+
#define rust_sorry_at(location, ...) sorry_at (location, __VA_ARGS__)
209208

210209
void
211210
rust_debug_loc (const Location location, const char *fmt,

0 commit comments

Comments
 (0)