]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Change class Location into typedef
authorOwen Avery <powerboat9.gamer@gmail.com>
Sun, 2 Jul 2023 23:59:29 +0000 (19:59 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:49:31 +0000 (18:49 +0100)
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 <powerboat9.gamer@gmail.com>
12 files changed:
gcc/rust/backend/rust-compile-base.cc
gcc/rust/backend/rust-compile-expr.cc
gcc/rust/backend/rust-compile-intrinsic.cc
gcc/rust/resolve/rust-ast-resolve-expr.cc
gcc/rust/rust-diagnostics.cc
gcc/rust/rust-diagnostics.h
gcc/rust/rust-gcc.cc
gcc/rust/rust-linemap.cc
gcc/rust/rust-location.h
gcc/rust/typecheck/rust-hir-trait-resolve.cc
gcc/rust/typecheck/rust-hir-type-check-stmt.cc
gcc/rust/util/rust-token-converter.cc

index 836ac82b6fc97d2e60912d4014765e8a211abab6..d2e1d62c1bb32d1a23b6012e54556e7ee8cba86c 100644 (file)
@@ -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
@@ -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 *>
@@ -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);
@@ -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;
index 5595bf4e9017baf3c2ffc2a6573dbfd54835b8cb..100b766f84134445356b27e3fca69055eaf45fcd 100644 (file)
@@ -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);
@@ -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);
@@ -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);
@@ -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;
 }
@@ -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)))
@@ -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
index b9951a07974ef29705baccb4c1c37dad757db003..697f40f2196c1d5379c110faa19ac5c8eaa632ee 100644 (file)
@@ -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},
@@ -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},
@@ -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},
@@ -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,
@@ -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},
index 6f45f459c4ef5faeb6672fd4dfeb7382ebafa1f7..a67fa307ed7e07b6b1b0af8de6d4b74dbad22c63 100644 (file)
@@ -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 ());
     }
index c9f203e2433cea6d97fffac754bc29c1f0cead20..c6e709936ae04105843ac9c733080ff2e038ef94 100644 (file)
@@ -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
@@ -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
@@ -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
@@ -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
index 16e36dd71b8447252ff4dbc714b308f8e927ae47..4ec1c53db4895b853921bb90122dd5aaade7149c 100644 (file)
@@ -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,
index c86804ee8dce45b61ba807fb5bd73419f7d67651..608c770c22356492ab5c5030253dd53a7fc55890 100644 (file)
@@ -71,10 +71,10 @@ Bvariable::get_tree (Location location) const
     }
 
   // Return *(orig_type*)&decl.  */
-  tree t = build_fold_addr_expr_loc (location.gcc_location (), this->t_);
-  t = fold_build1_loc (location.gcc_location (), NOP_EXPR,
+  tree t = build_fold_addr_expr_loc (location, this->t_);
+  t = fold_build1_loc (location, NOP_EXPR,
                       build_pointer_type (this->orig_type_), t);
-  return build_fold_indirect_ref_loc (location.gcc_location (), t);
+  return build_fold_indirect_ref_loc (location, t);
 }
 
 // This file implements the interface between the Rust frontend proper
@@ -821,8 +821,7 @@ Gcc_backend::fill_in_fields (tree fill,
       tree type_tree = p->type;
       if (type_tree == error_mark_node)
        return error_mark_node;
-      tree field = build_decl (p->location.gcc_location (), FIELD_DECL,
-                              name_tree, type_tree);
+      tree field = build_decl (p->location, FIELD_DECL, name_tree, type_tree);
       DECL_CONTEXT (field) = fill;
       *pp = field;
       pp = &DECL_CHAIN (field);
@@ -890,8 +889,7 @@ Gcc_backend::named_type (const std::string &name, tree type, Location location)
   // The middle-end expects a basic type to have a name.  In Rust every
   // basic type will have a name.  The first time we see a basic type,
   // give it whatever Rust name we have at this point.
-  if (TYPE_NAME (type) == NULL_TREE
-      && location.gcc_location () == BUILTINS_LOCATION
+  if (TYPE_NAME (type) == NULL_TREE && location == BUILTINS_LOCATION
       && (TREE_CODE (type) == INTEGER_TYPE || TREE_CODE (type) == REAL_TYPE
          || TREE_CODE (type) == COMPLEX_TYPE
          || TREE_CODE (type) == BOOLEAN_TYPE))
@@ -903,8 +901,8 @@ Gcc_backend::named_type (const std::string &name, tree type, Location location)
     }
 
   tree copy = build_variant_type_copy (type);
-  tree decl = build_decl (location.gcc_location (), TYPE_DECL,
-                         get_identifier_from_string (name), copy);
+  tree decl
+    = build_decl (location, TYPE_DECL, get_identifier_from_string (name), copy);
   DECL_ORIGINAL_TYPE (decl) = type;
   TYPE_NAME (copy) = decl;
   return copy;
@@ -1087,7 +1085,7 @@ Gcc_backend::real_part_expression (tree complex_tree, Location location)
     return error_mark_node;
   gcc_assert (COMPLEX_FLOAT_TYPE_P (TREE_TYPE (complex_tree)));
   tree ret
-    = fold_build1_loc (location.gcc_location (), REALPART_EXPR,
+    = fold_build1_loc (location, REALPART_EXPR,
                       TREE_TYPE (TREE_TYPE (complex_tree)), complex_tree);
   return ret;
 }
@@ -1101,7 +1099,7 @@ Gcc_backend::imag_part_expression (tree complex_tree, Location location)
     return error_mark_node;
   gcc_assert (COMPLEX_FLOAT_TYPE_P (TREE_TYPE (complex_tree)));
   tree ret
-    = fold_build1_loc (location.gcc_location (), IMAGPART_EXPR,
+    = fold_build1_loc (location, IMAGPART_EXPR,
                       TREE_TYPE (TREE_TYPE (complex_tree)), complex_tree);
   return ret;
 }
@@ -1117,7 +1115,7 @@ Gcc_backend::complex_expression (tree real_tree, tree imag_tree,
   gcc_assert (TYPE_MAIN_VARIANT (TREE_TYPE (real_tree))
              == TYPE_MAIN_VARIANT (TREE_TYPE (imag_tree)));
   gcc_assert (SCALAR_FLOAT_TYPE_P (TREE_TYPE (real_tree)));
-  tree ret = fold_build2_loc (location.gcc_location (), COMPLEX_EXPR,
+  tree ret = fold_build2_loc (location, COMPLEX_EXPR,
                              build_complex_type (TREE_TYPE (real_tree)),
                              real_tree, imag_tree);
   return ret;
@@ -1151,10 +1149,9 @@ Gcc_backend::convert_expression (tree type_tree, tree expr_tree,
     ret = convert_to_pointer (type_tree, expr_tree);
   else if (TREE_CODE (type_tree) == RECORD_TYPE
           || TREE_CODE (type_tree) == ARRAY_TYPE)
-    ret = fold_build1_loc (location.gcc_location (), VIEW_CONVERT_EXPR,
-                          type_tree, expr_tree);
+    ret = fold_build1_loc (location, VIEW_CONVERT_EXPR, type_tree, expr_tree);
   else
-    ret = fold_convert_loc (location.gcc_location (), type_tree, expr_tree);
+    ret = fold_convert_loc (location, type_tree, expr_tree);
 
   return ret;
 }
@@ -1184,8 +1181,8 @@ Gcc_backend::struct_field_expression (tree struct_tree, size_t index,
     }
   if (TREE_TYPE (field) == error_mark_node)
     return error_mark_node;
-  tree ret = fold_build3_loc (location.gcc_location (), COMPONENT_REF,
-                             TREE_TYPE (field), struct_tree, field, NULL_TREE);
+  tree ret = fold_build3_loc (location, COMPONENT_REF, TREE_TYPE (field),
+                             struct_tree, field, NULL_TREE);
   if (TREE_CONSTANT (struct_tree))
     TREE_CONSTANT (ret) = 1;
   return ret;
@@ -1198,8 +1195,8 @@ Gcc_backend::compound_expression (tree stat, tree expr, Location location)
 {
   if (stat == error_mark_node || expr == error_mark_node)
     return error_mark_node;
-  tree ret = fold_build2_loc (location.gcc_location (), COMPOUND_EXPR,
-                             TREE_TYPE (expr), stat, expr);
+  tree ret
+    = fold_build2_loc (location, COMPOUND_EXPR, TREE_TYPE (expr), stat, expr);
   return ret;
 }
 
@@ -1214,8 +1211,8 @@ Gcc_backend::conditional_expression (tree, tree type_tree, tree cond_expr,
   if (type_tree == error_mark_node || cond_expr == error_mark_node
       || then_expr == error_mark_node || else_expr == error_mark_node)
     return error_mark_node;
-  tree ret = build3_loc (location.gcc_location (), COND_EXPR, type_tree,
-                        cond_expr, then_expr, else_expr);
+  tree ret = build3_loc (location, COND_EXPR, type_tree, cond_expr, then_expr,
+                        else_expr);
   return ret;
 }
 
@@ -1348,8 +1345,7 @@ Gcc_backend::negation_expression (NegationOperator op, tree expr_tree,
     }
 
   /* Construct a new tree and build an expression from it. */
-  auto new_tree = fold_build1_loc (location.gcc_location (), tree_code,
-                                  tree_type, expr_tree);
+  auto new_tree = fold_build1_loc (location, tree_code, tree_type, expr_tree);
   if (floating_point && extended_type != NULL_TREE)
     new_tree = convert (original_type, expr_tree);
   return new_tree;
@@ -1374,7 +1370,6 @@ Gcc_backend::arithmetic_or_logical_expression (ArithmeticOrLogicalOperator op,
      as the lhs operand. */
   auto tree_type = TREE_TYPE (left);
   auto original_type = tree_type;
-  auto loc = location.gcc_location ();
   auto tree_code = operator_to_tree_code (op, floating_point);
 
   /* For floating point operations we may need to extend the precision of type.
@@ -1391,7 +1386,7 @@ Gcc_backend::arithmetic_or_logical_expression (ArithmeticOrLogicalOperator op,
        }
     }
 
-  ret = fold_build2_loc (loc, tree_code, tree_type, left, right);
+  ret = fold_build2_loc (location, tree_code, tree_type, left, right);
   TREE_CONSTANT (ret) = TREE_CONSTANT (left) & TREE_CONSTANT (right);
 
   // TODO: How do we handle floating point?
@@ -1468,8 +1463,6 @@ Gcc_backend::arithmetic_or_logical_expression_checked (
   if (left == error_mark_node || right == error_mark_node)
     return error_mark_node;
 
-  auto loc = location.gcc_location ();
-
   // FIXME: Add `if (!debug_mode)`
   // No overflow checks for floating point operations or divisions. In that
   // case, simply assign the result of the operation to the receiver variable
@@ -1480,26 +1473,26 @@ Gcc_backend::arithmetic_or_logical_expression_checked (
 
   auto receiver = receiver_var->get_tree (location);
   TREE_ADDRESSABLE (receiver) = 1;
-  auto result_ref = build_fold_addr_expr_loc (loc, receiver);
+  auto result_ref = build_fold_addr_expr_loc (location, receiver);
 
   auto builtins = fetch_overflow_builtins (op);
   auto abort = builtins.first;
   auto builtin = builtins.second;
 
-  auto abort_call = build_call_expr_loc (loc, abort, 0);
+  auto abort_call = build_call_expr_loc (location, abort, 0);
 
   // FIXME: ARTHUR: Is that needed?
   TREE_SIDE_EFFECTS (abort_call) = 1;
   TREE_READONLY (abort_call) = 0;
 
   auto builtin_call
-    = build_call_expr_loc (loc, builtin, 3, left, right, result_ref);
+    = build_call_expr_loc (location, builtin, 3, left, right, result_ref);
   auto overflow_check
-    = build2_loc (loc, EQ_EXPR, boolean_type_node, builtin_call,
+    = build2_loc (location, EQ_EXPR, boolean_type_node, builtin_call,
                  boolean_constant_expression (true));
 
-  auto if_block = build3_loc (loc, COND_EXPR, void_type_node, overflow_check,
-                             abort_call, NULL_TREE);
+  auto if_block = build3_loc (location, COND_EXPR, void_type_node,
+                             overflow_check, abort_call, NULL_TREE);
 
   // FIXME: ARTHUR: Needed?
   TREE_SIDE_EFFECTS (if_block) = 1;
@@ -1523,8 +1516,8 @@ Gcc_backend::comparison_expression (ComparisonOperator op, tree left_tree,
   auto tree_code = operator_to_tree_code (op);
 
   /* Construct a new tree and build an expression from it. */
-  auto new_tree = fold_build2_loc (location.gcc_location (), tree_code,
-                                  tree_type, left_tree, right_tree);
+  auto new_tree
+    = fold_build2_loc (location, tree_code, tree_type, left_tree, right_tree);
   return new_tree;
 }
 
@@ -1544,8 +1537,8 @@ Gcc_backend::lazy_boolean_expression (LazyBooleanOperator op, tree left_tree,
   auto tree_code = operator_to_tree_code (op);
 
   /* Construct a new tree and build an expression from it. */
-  auto new_tree = fold_build2_loc (location.gcc_location (), tree_code,
-                                  tree_type, left_tree, right_tree);
+  auto new_tree
+    = fold_build2_loc (location, tree_code, tree_type, left_tree, right_tree);
   return new_tree;
 }
 
@@ -1662,8 +1655,7 @@ Gcc_backend::constructor_expression (tree type_tree, bool is_variant,
   if (is_constant)
     TREE_CONSTANT (ret) = 1;
   if (sink != NULL_TREE)
-    ret = fold_build2_loc (location.gcc_location (), COMPOUND_EXPR, type_tree,
-                          sink, ret);
+    ret = fold_build2_loc (location, COMPOUND_EXPR, type_tree, sink, ret);
   return ret;
 }
 
@@ -1715,8 +1707,7 @@ Gcc_backend::array_constructor_expression (
   if (is_constant)
     TREE_CONSTANT (ret) = 1;
   if (sink != NULL_TREE)
-    ret = fold_build2_loc (location.gcc_location (), COMPOUND_EXPR, type_tree,
-                          sink, ret);
+    ret = fold_build2_loc (location, COMPOUND_EXPR, type_tree, sink, ret);
   return ret;
 }
 
@@ -1745,7 +1736,7 @@ Gcc_backend::array_initializer (tree fndecl, tree block, tree array_type,
   // Temporary variable for pointer used to initialize elements.
   tree ptr_type = this->pointer_type (TREE_TYPE (array_type));
   tree ptr_init
-    = build1_loc (locus.gcc_location (), ADDR_EXPR, ptr_type,
+    = build1_loc (locus, ADDR_EXPR, ptr_type,
                  this->array_index_expression (arr, integer_zero_node, locus));
   Bvariable *tmp_ptr = this->temporary_variable (fndecl, block, ptr_type,
                                                 ptr_init, false, locus, &t);
@@ -1806,12 +1797,11 @@ Gcc_backend::array_index_expression (tree array_tree, tree index_tree,
   // dealing with a zero sized type and just evaluate the operands.
   tree ret;
   if (TREE_TYPE (array_tree) != void_type_node)
-    ret = build4_loc (location.gcc_location (), ARRAY_REF,
-                     TREE_TYPE (TREE_TYPE (array_tree)), array_tree,
-                     index_tree, NULL_TREE, NULL_TREE);
+    ret = build4_loc (location, ARRAY_REF, TREE_TYPE (TREE_TYPE (array_tree)),
+                     array_tree, index_tree, NULL_TREE, NULL_TREE);
   else
-    ret = fold_build2_loc (location.gcc_location (), COMPOUND_EXPR,
-                          void_type_node, array_tree, index_tree);
+    ret = fold_build2_loc (location, COMPOUND_EXPR, void_type_node, array_tree,
+                          index_tree);
 
   return ret;
 }
@@ -1857,8 +1847,7 @@ Gcc_backend::call_expression (tree fn, const std::vector<tree> &fn_args,
            excess_type = NULL_TREE;
          else
            {
-             fn = build_fold_addr_expr_loc (location.gcc_location (),
-                                            excess_fndecl);
+             fn = build_fold_addr_expr_loc (location, excess_fndecl);
              for (size_t i = 0; i < nargs; ++i)
                {
                  if (SCALAR_FLOAT_TYPE_P (TREE_TYPE (args[i]))
@@ -1870,7 +1859,7 @@ Gcc_backend::call_expression (tree fn, const std::vector<tree> &fn_args,
     }
 
   tree ret
-    = build_call_array_loc (location.gcc_location (),
+    = build_call_array_loc (location,
                            excess_type != NULL_TREE ? excess_type : rettype,
                            fn, nargs, args);
 
@@ -1878,7 +1867,7 @@ Gcc_backend::call_expression (tree fn, const std::vector<tree> &fn_args,
   if (fndecl && TREE_DEPRECATED (fndecl))
     {
       // set up the call-site information for `warn_deprecated_use`
-      input_location = location.gcc_location ();
+      input_location = location;
       warn_deprecated_use (fndecl, NULL_TREE);
     }
 
@@ -1889,7 +1878,7 @@ Gcc_backend::call_expression (tree fn, const std::vector<tree> &fn_args,
     {
       // Calling convert here can undo our excess precision change.
       // That may or may not be a bug in convert_to_real.
-      ret = build1_loc (location.gcc_location (), NOP_EXPR, rettype, ret);
+      ret = build1_loc (location, NOP_EXPR, rettype, ret);
     }
 
   delete[] args;
@@ -1950,8 +1939,7 @@ Gcc_backend::assignment_statement (tree lhs, tree rhs, Location location)
 
   rhs = this->convert_tree (TREE_TYPE (lhs), rhs, location);
 
-  return fold_build2_loc (location.gcc_location (), MODIFY_EXPR, void_type_node,
-                         lhs, rhs);
+  return fold_build2_loc (location, MODIFY_EXPR, void_type_node, lhs, rhs);
 }
 
 // Return.
@@ -1969,9 +1957,9 @@ Gcc_backend::return_statement (tree fntree, tree val, Location location)
   if (val == error_mark_node)
     return error_mark_node;
 
-  auto locus = location.gcc_location ();
-  tree set = fold_build2_loc (locus, MODIFY_EXPR, void_type_node, result, val);
-  return fold_build1_loc (locus, RETURN_EXPR, void_type_node, set);
+  tree set
+    = fold_build2_loc (location, MODIFY_EXPR, void_type_node, result, val);
+  return fold_build1_loc (location, RETURN_EXPR, void_type_node, set);
 }
 
 // Create a statement that attempts to execute BSTAT and calls EXCEPT_STMT if an
@@ -1989,13 +1977,12 @@ Gcc_backend::exception_handler_statement (tree try_stmt, tree except_stmt,
     return error_mark_node;
 
   if (except_stmt != NULL_TREE)
-    try_stmt = build2_loc (location.gcc_location (), TRY_CATCH_EXPR,
-                          void_type_node, try_stmt,
-                          build2_loc (location.gcc_location (), CATCH_EXPR,
-                                      void_type_node, NULL, except_stmt));
+    try_stmt = build2_loc (location, TRY_CATCH_EXPR, void_type_node, try_stmt,
+                          build2_loc (location, CATCH_EXPR, void_type_node,
+                                      NULL, except_stmt));
   if (finally_stmt != NULL_TREE)
-    try_stmt = build2_loc (location.gcc_location (), TRY_FINALLY_EXPR,
-                          void_type_node, try_stmt, finally_stmt);
+    try_stmt = build2_loc (location, TRY_FINALLY_EXPR, void_type_node, try_stmt,
+                          finally_stmt);
   return try_stmt;
 }
 
@@ -2008,8 +1995,8 @@ Gcc_backend::if_statement (tree, tree cond_tree, tree then_tree, tree else_tree,
   if (cond_tree == error_mark_node || then_tree == error_mark_node
       || else_tree == error_mark_node)
     return error_mark_node;
-  tree ret = build3_loc (location.gcc_location (), COND_EXPR, void_type_node,
-                        cond_tree, then_tree, else_tree);
+  tree ret = build3_loc (location, COND_EXPR, void_type_node, cond_tree,
+                        then_tree, else_tree);
   return ret;
 }
 
@@ -2018,15 +2005,13 @@ Gcc_backend::if_statement (tree, tree cond_tree, tree then_tree, tree else_tree,
 tree
 Gcc_backend::loop_expression (tree body, Location locus)
 {
-  return fold_build1_loc (locus.gcc_location (), LOOP_EXPR, void_type_node,
-                         body);
+  return fold_build1_loc (locus, LOOP_EXPR, void_type_node, body);
 }
 
 tree
 Gcc_backend::exit_expression (tree cond_tree, Location locus)
 {
-  return fold_build1_loc (locus.gcc_location (), EXIT_EXPR, void_type_node,
-                         cond_tree);
+  return fold_build1_loc (locus, EXIT_EXPR, void_type_node, cond_tree);
 }
 
 // Pair of statements.
@@ -2127,9 +2112,8 @@ Gcc_backend::block (tree fndecl, tree enclosing,
 
   TREE_USED (block_tree) = 1;
 
-  tree bind_tree
-    = build3_loc (start_location.gcc_location (), BIND_EXPR, void_type_node,
-                 BLOCK_VARS (block_tree), NULL_TREE, block_tree);
+  tree bind_tree = build3_loc (start_location, BIND_EXPR, void_type_node,
+                              BLOCK_VARS (block_tree), NULL_TREE, block_tree);
   TREE_SIDE_EFFECTS (bind_tree) = 1;
   return bind_tree;
 }
@@ -2229,7 +2213,7 @@ Gcc_backend::convert_tree (tree type_tree, tree expr_tree, Location location)
 
   if (POINTER_TYPE_P (type_tree) || INTEGRAL_TYPE_P (type_tree)
       || SCALAR_FLOAT_TYPE_P (type_tree) || COMPLEX_FLOAT_TYPE_P (type_tree))
-    return fold_convert_loc (location.gcc_location (), type_tree, expr_tree);
+    return fold_convert_loc (location, type_tree, expr_tree);
   else if (TREE_CODE (type_tree) == RECORD_TYPE
           || TREE_CODE (type_tree) == UNION_TYPE
           || TREE_CODE (type_tree) == ARRAY_TYPE)
@@ -2238,10 +2222,9 @@ Gcc_backend::convert_tree (tree type_tree, tree expr_tree, Location location)
                  == int_size_in_bytes (TREE_TYPE (expr_tree)));
       if (TYPE_MAIN_VARIANT (type_tree)
          == TYPE_MAIN_VARIANT (TREE_TYPE (expr_tree)))
-       return fold_build1_loc (location.gcc_location (), NOP_EXPR, type_tree,
-                               expr_tree);
-      return fold_build1_loc (location.gcc_location (), VIEW_CONVERT_EXPR,
-                             type_tree, expr_tree);
+       return fold_build1_loc (location, NOP_EXPR, type_tree, expr_tree);
+      return fold_build1_loc (location, VIEW_CONVERT_EXPR, type_tree,
+                             expr_tree);
     }
 
   gcc_unreachable ();
@@ -2263,7 +2246,7 @@ Gcc_backend::global_variable (const std::string &var_name,
   if ((is_external || !is_hidden) && int_size_in_bytes (type_tree) == 0)
     type_tree = this->non_zero_size_type (type_tree);
 
-  tree decl = build_decl (location.gcc_location (), VAR_DECL,
+  tree decl = build_decl (location, VAR_DECL,
                          get_identifier_from_string (var_name), type_tree);
   if (is_external)
     DECL_EXTERNAL (decl) = 1;
@@ -2322,8 +2305,8 @@ Gcc_backend::local_variable (tree function, const std::string &name,
 {
   if (type_tree == error_mark_node)
     return this->error_variable ();
-  tree decl = build_decl (location.gcc_location (), VAR_DECL,
-                         get_identifier_from_string (name), type_tree);
+  tree decl = build_decl (location, VAR_DECL, get_identifier_from_string (name),
+                         type_tree);
   DECL_CONTEXT (decl) = function;
 
   if (decl_var != NULL)
@@ -2343,7 +2326,7 @@ Gcc_backend::parameter_variable (tree function, const std::string &name,
 {
   if (type_tree == error_mark_node)
     return this->error_variable ();
-  tree decl = build_decl (location.gcc_location (), PARM_DECL,
+  tree decl = build_decl (location, PARM_DECL,
                          get_identifier_from_string (name), type_tree);
   DECL_CONTEXT (decl) = function;
   DECL_ARG_TYPE (decl) = type_tree;
@@ -2360,7 +2343,7 @@ Gcc_backend::static_chain_variable (tree fndecl, const std::string &name,
 {
   if (type_tree == error_mark_node)
     return this->error_variable ();
-  tree decl = build_decl (location.gcc_location (), PARM_DECL,
+  tree decl = build_decl (location, PARM_DECL,
                          get_identifier_from_string (name), type_tree);
   DECL_CONTEXT (decl) = fndecl;
   DECL_ARG_TYPE (decl) = type_tree;
@@ -2414,8 +2397,8 @@ Gcc_backend::temporary_variable (tree fndecl, tree bind_tree, tree type_tree,
   else
     {
       gcc_assert (bind_tree != NULL_TREE);
-      var = build_decl (location.gcc_location (), VAR_DECL,
-                       create_tmp_var_name ("RUSTTMP"), type_tree);
+      var = build_decl (location, VAR_DECL, create_tmp_var_name ("RUSTTMP"),
+                       type_tree);
       DECL_ARTIFICIAL (var) = 1;
       DECL_IGNORED_P (var) = 1;
       TREE_USED (var) = 1;
@@ -2437,8 +2420,7 @@ Gcc_backend::temporary_variable (tree fndecl, tree bind_tree, tree type_tree,
   if (is_address_taken)
     TREE_ADDRESSABLE (var) = 1;
 
-  *pstatement
-    = build1_loc (location.gcc_location (), DECL_EXPR, void_type_node, var);
+  *pstatement = build1_loc (location, DECL_EXPR, void_type_node, var);
 
   // For a zero sized type, don't initialize VAR with BINIT, but still
   // evaluate BINIT for its side effects.
@@ -2463,15 +2445,14 @@ Gcc_backend::label (tree func_tree, const std::string &name, Location location)
       else
        push_cfun (DECL_STRUCT_FUNCTION (func_tree));
 
-      decl = create_artificial_label (location.gcc_location ());
+      decl = create_artificial_label (location);
 
       pop_cfun ();
     }
   else
     {
       tree id = get_identifier_from_string (name);
-      decl
-       = build_decl (location.gcc_location (), LABEL_DECL, id, void_type_node);
+      decl = build_decl (location, LABEL_DECL, id, void_type_node);
       DECL_CONTEXT (decl) = func_tree;
     }
   return decl;
@@ -2491,8 +2472,7 @@ Gcc_backend::label_definition_statement (tree label)
 tree
 Gcc_backend::goto_statement (tree label, Location location)
 {
-  return fold_build1_loc (location.gcc_location (), GOTO_EXPR, void_type_node,
-                         label);
+  return fold_build1_loc (location, GOTO_EXPR, void_type_node, label);
 }
 
 // Get the address of a label.
@@ -2502,10 +2482,8 @@ Gcc_backend::label_address (tree label, Location location)
 {
   TREE_USED (label) = 1;
   TREE_ADDRESSABLE (label) = 1;
-  tree ret
-    = fold_convert_loc (location.gcc_location (), ptr_type_node,
-                       build_fold_addr_expr_loc (location.gcc_location (),
-                                                 label));
+  tree ret = fold_convert_loc (location, ptr_type_node,
+                              build_fold_addr_expr_loc (location, label));
   return ret;
 }
 
@@ -2525,8 +2503,7 @@ Gcc_backend::function (tree functype, const std::string &name,
   if (functype == error_mark_node || id == error_mark_node)
     return error_mark_node;
 
-  tree decl
-    = build_decl (location.gcc_location (), FUNCTION_DECL, id, functype);
+  tree decl = build_decl (location, FUNCTION_DECL, id, functype);
   if (!asm_name.empty ())
     SET_DECL_ASSEMBLER_NAME (decl, get_identifier_from_string (asm_name));
 
@@ -2535,8 +2512,7 @@ Gcc_backend::function (tree functype, const std::string &name,
   else
     {
       tree restype = TREE_TYPE (functype);
-      tree resdecl = build_decl (location.gcc_location (), RESULT_DECL,
-                                NULL_TREE, restype);
+      tree resdecl = build_decl (location, RESULT_DECL, NULL_TREE, restype);
       DECL_ARTIFICIAL (resdecl) = 1;
       DECL_IGNORED_P (resdecl) = 1;
       DECL_CONTEXT (resdecl) = decl;
index 24aee9f6e84b9a4c50a1dc8dd2cdfc412a4d851e..17589bfb0ab393a82169c2fb810548d84d74b061 100644 (file)
@@ -81,9 +81,8 @@ Gcc_linemap::to_string (Location location)
 
   // Screen out unknown and predeclared locations; produce output
   // only for simple file:line locations.
-  resolved_location
-    = linemap_resolve_location (line_table, location.gcc_location (),
-                               LRK_SPELLING_LOCATION, &lmo);
+  resolved_location = linemap_resolve_location (line_table, location,
+                                               LRK_SPELLING_LOCATION, &lmo);
   if (lmo == NULL || resolved_location < RESERVED_LOCATION_COUNT)
     return "";
   const char *path = LINEMAP_FILE (lmo);
@@ -92,8 +91,8 @@ Gcc_linemap::to_string (Location location)
 
   // Strip the source file down to the base file, to reduce clutter.
   std::stringstream ss;
-  ss << lbasename (path) << ":" << SOURCE_LINE (lmo, location.gcc_location ())
-     << ":" << SOURCE_COLUMN (lmo, location.gcc_location ());
+  ss << lbasename (path) << ":" << SOURCE_LINE (lmo, location) << ":"
+     << SOURCE_COLUMN (lmo, location);
   return ss.str ();
 }
 
@@ -102,7 +101,7 @@ Gcc_linemap::to_string (Location location)
 std::string
 Gcc_linemap::location_file (Location loc)
 {
-  return LOCATION_FILE (loc.gcc_location ());
+  return LOCATION_FILE (loc);
 }
 
 // Return the line number for a given location.
@@ -110,14 +109,14 @@ Gcc_linemap::location_file (Location loc)
 int
 Gcc_linemap::location_line (Location loc)
 {
-  return LOCATION_LINE (loc.gcc_location ());
+  return LOCATION_LINE (loc);
 }
 
 // Return the column number for a given location.
 int
 Gcc_linemap::location_column (Location loc)
 {
-  return LOCATION_COLUMN (loc.gcc_location ());
+  return LOCATION_COLUMN (loc);
 }
 
 // Stop getting locations.
@@ -166,7 +165,7 @@ Gcc_linemap::get_predeclared_location ()
 bool
 Gcc_linemap::is_predeclared (Location loc)
 {
-  return loc.gcc_location () == BUILTINS_LOCATION;
+  return loc == BUILTINS_LOCATION;
 }
 
 // Return whether a location is the unknown location.
@@ -174,7 +173,7 @@ Gcc_linemap::is_predeclared (Location loc)
 bool
 Gcc_linemap::is_unknown (Location loc)
 {
-  return loc.gcc_location () == UNKNOWN_LOCATION;
+  return loc == UNKNOWN_LOCATION;
 }
 
 // Return the Linemap to use for the gcc backend.
@@ -185,8 +184,7 @@ rust_get_linemap ()
   return new Gcc_linemap;
 }
 
-RichLocation::RichLocation (Location root)
-  : gcc_rich_loc (line_table, root.gcc_location ())
+RichLocation::RichLocation (Location root) : gcc_rich_loc (line_table, root)
 {
   /*rich_location (line_maps *set, location_t loc,
                 const range_label *label = NULL);*/
@@ -197,7 +195,7 @@ RichLocation::~RichLocation () {}
 void
 RichLocation::add_range (Location loc)
 {
-  gcc_rich_loc.add_range (loc.gcc_location ());
+  gcc_rich_loc.add_range (loc);
 }
 
 void
@@ -210,8 +208,7 @@ void
 RichLocation::add_fixit_insert_before (Location where,
                                       const std::string &new_parent)
 {
-  gcc_rich_loc.add_fixit_insert_before (where.gcc_location (),
-                                       new_parent.c_str ());
+  gcc_rich_loc.add_fixit_insert_before (where, new_parent.c_str ());
 }
 
 void
@@ -224,6 +221,5 @@ void
 RichLocation::add_fixit_insert_after (Location where,
                                      const std::string &new_parent)
 {
-  gcc_rich_loc.add_fixit_insert_after (where.gcc_location (),
-                                      new_parent.c_str ());
+  gcc_rich_loc.add_fixit_insert_after (where, new_parent.c_str ());
 }
index b2f53d85386799bf88f98eeed16e081012db5c0a..b0b14c6ebb49e902990b00eba4ca04da6ccb2fc6 100644 (file)
 
 // A location in an input source file.
 
-class Location
-{
-public:
-  Location () : gcc_loc_ (UNKNOWN_LOCATION) {}
-
-  explicit Location (location_t loc) : gcc_loc_ (loc) {}
-
-  location_t gcc_location () const { return gcc_loc_; }
-
-  Location operator+= (location_t rhs)
-  {
-    gcc_loc_ += rhs;
-    return *this;
-  }
-
-  Location operator-= (location_t rhs)
-  {
-    gcc_loc_ -= rhs;
-    return *this;
-  }
-
-  bool operator== (location_t rhs) { return rhs == gcc_loc_; }
-
-private:
-  location_t gcc_loc_;
-};
-
-// The Rust frontend requires the ability to compare Locations.
-
-inline bool
-operator< (Location loca, Location locb)
-{
-  return loca.gcc_location () < locb.gcc_location ();
-}
-
-inline bool
-operator== (Location loca, Location locb)
-{
-  return loca.gcc_location () == locb.gcc_location ();
-}
-
-inline Location
-operator+ (Location lhs, location_t rhs)
-{
-  lhs += rhs;
-  return lhs;
-}
-
-inline Location
-operator- (Location lhs, location_t rhs)
-{
-  lhs -= rhs;
-  return lhs;
-}
+typedef location_t Location;
 
 class RichLocation
 {
index f72c6fc225a2c1046624d649ddfc65c29519a3db..f5370d07a194c557de68f990c0f3b984328f60a9 100644 (file)
@@ -491,7 +491,7 @@ AssociatedImplTrait::setup_associated_types (
 
   // generate inference variables for these bound arguments so we can compute
   // their values
-  Location locus;
+  Location locus = UNKNOWN_LOCATION;
   std::vector<TyTy::SubstitutionArg> subst_args;
   for (auto &p : substitutions)
     {
index 089cd03b9a2562680af05c63ec19b385c28a6e25..4efbd40e1a40898c88d2ea7d8710870129e796d1 100644 (file)
@@ -78,7 +78,7 @@ TypeCheckStmt::visit (HIR::LetStmt &stmt)
 
   HIR::Pattern &stmt_pattern = *stmt.get_pattern ();
   TyTy::BaseType *init_expr_ty = nullptr;
-  Location init_expr_locus;
+  Location init_expr_locus = UNKNOWN_LOCATION;
   if (stmt.has_init_expr ())
     {
       init_expr_locus = stmt.get_init_expr ()->get_locus ();
index e7d9a65991da0039114ca1831d70b1be2248d73d..1ba80a1647a79d7d99eb9a4a0ab3eb6d12a7d88a 100644 (file)
@@ -54,7 +54,7 @@ pop_group (std::vector<ProcMacro::TokenStream> &streams,
 static ProcMacro::Span
 convert (Location location)
 {
-  return ProcMacro::Span::make_span (location.gcc_location (), 0);
+  return ProcMacro::Span::make_span (location, 0);
 }
 
 static Location