diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2024-04-24 10:51:13 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-17 16:35:22 +0100 |
commit | fd788dd543017cd801657b82bf80bb78e03479ed (patch) | |
tree | 7d8007823936b858a4beed0eee0a3030096a39cf /gcc/rust/backend | |
parent | 4d851ca89569b71ee87f22644d2e70938bb84992 (diff) | |
download | gcc-fd788dd543017cd801657b82bf80bb78e03479ed.zip gcc-fd788dd543017cd801657b82bf80bb78e03479ed.tar.gz gcc-fd788dd543017cd801657b82bf80bb78e03479ed.tar.bz2 |
gccrs: Change singleton returned type to a reference
We do not need a raw pointer for this singleton,
nor we need having it on the heap through a
smart pointer.
gcc/rust/ChangeLog:
* ast/rust-ast.h: Change dereference from a pointer to a reference
accessor.
* ast/rust-expr.h: Likewise.
* ast/rust-item.h: Likewise.
* ast/rust-macro.h: Likewise.
* ast/rust-path.h: Likewise.
* ast/rust-pattern.h: Likewise.
* ast/rust-type.h: Likewise.
* backend/rust-compile-base.cc (HIRCompileBase::resolve_method_address):
Likewise.
* backend/rust-compile-context.h: Likewise.
* backend/rust-compile-expr.cc (CompileExpr::visit): Likewise.
(CompileExpr::generate_closure_function): Likewise.
* backend/rust-compile-extern.h: Likewise.
* backend/rust-compile-implitem.cc (CompileTraitItem::visit): Likewise.
* backend/rust-compile-intrinsic.cc (Intrinsics::compile): Likewise.
* backend/rust-compile-item.cc (CompileItem::visit): Likewise.
* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve):
Likewise.
(HIRCompileBase::query_compile): Likewise.
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Likewise.
(TyTyResolveCompile::create_dyn_obj_record): Likewise.
* backend/rust-compile.cc (HIRCompileBase::coerce_to_dyn_object):
Likewise.
* backend/rust-mangle-v0.cc (v0_path): Likewise.
(v0_mangle_item): Likewise.
* checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go):
Likewise.
* checks/errors/privacy/rust-privacy-check.cc (Resolver::resolve):
Likewise.
* checks/errors/rust-const-checker.cc (ConstChecker::ConstChecker):
Likewise.
* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::UnsafeChecker):
Likewise.
* checks/lints/rust-lint-marklive-base.h: Likewise.
* checks/lints/rust-lint-marklive.cc (MarkLive::go): Likewise.
(MarkLive::visit): Likewise.
(MarkLive::visit_path_segment): Likewise.
* checks/lints/rust-lint-marklive.h: Likewise.
* checks/lints/rust-lint-scan-deadcode.h: Likewise.
* expand/rust-macro-expand.cc (MacroExpander::expand_invoc): Likewise.
* expand/rust-macro-expand.h (struct MacroExpander): Change mapping
from pointer to a reference.
* expand/rust-proc-macro.cc (BangProcMacro::BangProcMacro): Replace
pointer accessor with reference accessor.
(AttributeProcMacro::AttributeProcMacro): Likewise.
(CustomDeriveProcMacro::CustomDeriveProcMacro): Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_lifetime):
Likewise.
(ASTLoweringBase::lower_loop_label): Likewise.
(ASTLoweringBase::lower_path_expr_seg): Likewise.
(ASTLoweringBase::lower_self): Likewise.
(ASTLoweringBase::handle_lang_item_attribute): Likewise.
(ASTLoweringBase::lower_extern_block): Likewise.
(ASTLoweringBase::lower_macro_definition): Likewise.
* hir/rust-ast-lower-base.h: Likewise.
* hir/rust-ast-lower-block.h: Likewise.
* hir/rust-ast-lower-enumitem.h: Likewise.
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::translate): Likewise.
(ASTLoweringExpr::visit): Likewise.
* hir/rust-ast-lower-extern.h: Likewise.
* hir/rust-ast-lower-implitem.cc (ASTLowerImplItem::translate):
Likewise.
(ASTLowerImplItem::visit): Likewise.
(ASTLowerTraitItem::translate): Likewise.
(ASTLowerTraitItem::visit): Likewise.
* hir/rust-ast-lower-item.cc (ASTLoweringItem::translate): Likewise.
(ASTLoweringItem::visit): Likewise.
(ASTLoweringSimplePath::lower): Likewise.
* hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::translate):
Likewise.
(ASTLoweringPattern::visit): Likewise.
* hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::translate): Likewise.
(ASTLoweringStmt::visit): Likewise.
* hir/rust-ast-lower-struct-field-expr.h: Likewise.
* hir/rust-ast-lower-type.cc (ASTLowerTypePath::visit): Likewise.
(ASTLowerQualifiedPathInType::visit): Likewise.
(ASTLoweringType::translate): Likewise.
(ASTLoweringType::visit): Likewise.
(ASTLowerGenericParam::translate): Likewise.
(ASTLowerGenericParam::visit): Likewise.
(ASTLoweringTypeBounds::translate): Likewise.
(ASTLoweringTypeBounds::visit): Likewise.
(ASTLowerWhereClauseItem::translate): Likewise.
(ASTLowerWhereClauseItem::visit): Likewise.
* hir/rust-ast-lower.cc (ASTLowering::go): Likewise.
(ASTLoweringBlock::visit): Likewise.
(ASTLoweringIfBlock::visit): Likewise.
(ASTLoweringIfLetBlock::visit): Likewise.
(ASTLowerStructExprField::visit): Likewise.
(ASTLoweringExprWithBlock::visit): Likewise.
(ASTLowerPathInExpression::visit): Likewise.
(ASTLoweringBase::lower_qual_path_type): Likewise.
(ASTLowerQualPathInExpression::visit): Likewise.
* metadata/rust-export-metadata.cc (ExportContext::emit_trait):
Likewise.
(ExportContext::emit_function): Likewise.
(ExportContext::emit_macro): Likewise.
(PublicInterface::PublicInterface): Likewise.
(PublicInterface::expected_metadata_filename): Likewise.
* metadata/rust-export-metadata.h: Likewise.
* resolve/rust-ast-resolve-base.h: Likewise.
* resolve/rust-ast-resolve-implitem.h: Likewise.
* resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit):
Likewise.
(ResolveItem::visit): Likewise.
(ResolveExternItem::visit): Likewise.
* resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path):
Likewise.
* resolve/rust-ast-resolve-stmt.h: Likewise.
* resolve/rust-ast-resolve-toplevel.h: Likewise.
* resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go):
Likewise.
(ResolveTypeToCanonicalPath::visit): Likewise.
* resolve/rust-ast-resolve-type.h: Likewise.
* resolve/rust-ast-resolve.cc (NameResolution::NameResolution):
Likewise.
(NameResolution::go): Likewise.
* resolve/rust-ast-resolve.h: Likewise.
* resolve/rust-early-name-resolver-2.0.cc (Early::visit_attributes):
Likewise.
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::EarlyNameResolver):
Likewise.
* resolve/rust-late-name-resolver-2.0.cc (next_node_id): Likewise.
(next_hir_id): Likewise.
* resolve/rust-name-resolution-context.cc (NameResolutionContext::NameResolutionContext):
Likewise.
* resolve/rust-name-resolver.cc (Resolver::Resolver): Likewise.
(Resolver::generate_builtins): Likewise.
(Resolver::setup_builtin): Likewise.
* resolve/rust-name-resolver.h: Likewise.
* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit):
Likewise.
(TopLevel::handle_use_glob): Likewise.
* rust-session-manager.cc (Session::get_instance): Likewise.
(Session::handle_input_files): Likewise.
(Session::handle_crate_name): Likewise.
(Session::compile_crate): Likewise.
(Session::load_extern_crate): Likewise.
* rust-session-manager.h: Likewise.
* typecheck/rust-autoderef.cc (Adjuster::try_unsize_type): Likewise.
* typecheck/rust-coercion.cc (TypeCoercionRules::do_coercion):
Likewise.
(TypeCoercionRules::coerce_unsafe_ptr): Likewise.
(TypeCoercionRules::coerce_borrowed_pointer): Likewise.
(TypeCoercionRules::coerce_unsized): Likewise.
* typecheck/rust-coercion.h: Likewise.
* typecheck/rust-hir-dot-operator.cc (MethodResolver::select):
Likewise.
* typecheck/rust-hir-inherent-impl-overlap.h: Likewise.
* typecheck/rust-hir-path-probe.cc (PathProbeType::process_enum_item_for_candiates):
Likewise.
(PathProbeType::process_impl_items_for_candidates): Likewise.
(PathProbeImplTrait::process_trait_impl_items_for_candidates):
Likewise.
* typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_path_to_trait):
Likewise.
(TraitItemReference::get_parent_trait_mappings): Likewise.
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::resolve_literal):
Likewise.
(TypeCheckBase::get_marker_predicate): Likewise.
* typecheck/rust-hir-type-check-base.h: Likewise.
* typecheck/rust-hir-type-check-enumitem.cc (TypeCheckEnumItem::visit):
Likewise.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
Likewise.
(TypeCheckExpr::resolve_operator_overload): Likewise.
(TypeCheckExpr::resolve_fn_trait_call): Likewise.
* typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit):
Likewise.
(TypeCheckImplItem::visit): Likewise.
* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit):
Likewise.
* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_root_path):
Likewise.
(TypeCheckExpr::resolve_segments): Likewise.
* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::emit_pattern_size_error):
Likewise.
(ClosureParamInfer::Resolve): Likewise.
* typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::resolve):
Likewise.
* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): Likewise.
(TypeCheckType::resolve_root_path): Likewise.
(TypeResolveGenericParam::visit): Likewise.
(ResolveWhereClauseItem::visit): Likewise.
* typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn):
Likewise.
* typecheck/rust-type-util.cc (query_type): Likewise.
* typecheck/rust-typecheck-context.cc (TypeCheckContext::compute_inference_variables):
Likewise.
* typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::scan): Likewise.
(TypeBoundsProbe::assemble_builtin_candidate): Likewise.
(TypeCheckBase::get_predicate_from_bound): Likewise.
* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Likewise.
(TypeCheckMethodCallExpr::check): Likewise.
* typecheck/rust-tyty-call.h: Likewise.
* typecheck/rust-tyty-cmp.h: Likewise.
* typecheck/rust-tyty-subst.cc (SubstitutionParamMapping::override_context):
Likewise.
(SubstitutionRef::monomorphize): Likewise.
* typecheck/rust-tyty-util.cc (TyVar::get_implicit_infer_var):
Likewise.
(TyVar::monomorphized_clone): Likewise.
(TyWithLocation::TyWithLocation): Likewise.
* typecheck/rust-tyty.cc (BaseType::satisfies_bound): Likewise.
(InferType::clone): Likewise.
(ADTType::handle_substitions): Likewise.
(TupleType::handle_substitions): Likewise.
(FnType::handle_substitions): Likewise.
(ClosureType::setup_fn_once_output): Likewise.
(ArrayType::handle_substitions): Likewise.
(SliceType::handle_substitions): Likewise.
(ReferenceType::handle_substitions): Likewise.
(PointerType::handle_substitions): Likewise.
(ParamType::handle_substitions): Likewise.
* typecheck/rust-tyty.h: Likewise.
* typecheck/rust-unify.cc (UnifyRules::UnifyRules): Likewise.
(UnifyRules::commit): Likewise.
* util/rust-hir-map.cc: Change getter return type to a reference.
* util/rust-hir-map.h: Update function's prototype.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r-- | gcc/rust/backend/rust-compile-base.cc | 6 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-context.h | 4 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.cc | 22 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-extern.h | 2 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-implitem.cc | 4 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-intrinsic.cc | 2 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-item.cc | 10 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-resolve-path.cc | 12 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-type.cc | 22 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile.cc | 2 | ||||
-rw-r--r-- | gcc/rust/backend/rust-mangle-v0.cc | 14 |
11 files changed, 50 insertions, 50 deletions
diff --git a/gcc/rust/backend/rust-compile-base.cc b/gcc/rust/backend/rust-compile-base.cc index 67d8797..e313820 100644 --- a/gcc/rust/backend/rust-compile-base.cc +++ b/gcc/rust/backend/rust-compile-base.cc @@ -877,7 +877,7 @@ HIRCompileBase::resolve_method_address (TyTy::FnType *fntype, // Now we can try and resolve the address since this might be a forward // declared function, generic function which has not be compiled yet or // its an not yet trait bound function - HIR::Item *resolved_item = ctx->get_mappings ()->lookup_defid (id); + HIR::Item *resolved_item = ctx->get_mappings ().lookup_defid (id); if (resolved_item != nullptr) { if (!fntype->has_substitutions_defined ()) @@ -888,8 +888,8 @@ HIRCompileBase::resolve_method_address (TyTy::FnType *fntype, // it might be resolved to a trait item HIR::TraitItem *trait_item - = ctx->get_mappings ()->lookup_trait_item_defid (id); - HIR::Trait *trait = ctx->get_mappings ()->lookup_trait_item_mapping ( + = ctx->get_mappings ().lookup_trait_item_defid (id); + HIR::Trait *trait = ctx->get_mappings ().lookup_trait_item_mapping ( trait_item->get_mappings ().get_hirid ()); Resolver::TraitReference *trait_ref diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index 156c7b1..a446388 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -89,7 +89,7 @@ public: Resolver::Resolver *get_resolver () { return resolver; } Resolver::TypeCheckContext *get_tyctx () { return tyctx; } - Analysis::Mappings *get_mappings () { return mappings; } + Analysis::Mappings &get_mappings () { return mappings; } void push_block (tree scope) { @@ -390,7 +390,7 @@ public: private: Resolver::Resolver *resolver; Resolver::TypeCheckContext *tyctx; - Analysis::Mappings *mappings; + Analysis::Mappings &mappings; Mangler mangler; // state diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 9ffd863..0980e6c 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -120,7 +120,7 @@ CompileExpr::visit (HIR::ReturnExpr &expr) TyTy::BaseType *expected = fncontext.retty; location_t lvalue_locus - = ctx->get_mappings ()->lookup_location (expected->get_ref ()); + = ctx->get_mappings ().lookup_location (expected->get_ref ()); TyTy::BaseType *actual = nullptr; bool ok = ctx->get_tyctx ()->lookup_type ( @@ -456,7 +456,7 @@ CompileExpr::visit (HIR::StructExprStructFields &struct_expr) // process arguments auto &argument = struct_expr.get_fields ().at (0); auto lvalue_locus - = ctx->get_mappings ()->lookup_location (expected->get_ty_ref ()); + = ctx->get_mappings ().lookup_location (expected->get_ty_ref ()); auto rvalue_locus = argument->get_locus (); auto rvalue = CompileStructExprField::Compile (argument.get (), ctx); @@ -488,7 +488,7 @@ CompileExpr::visit (HIR::StructExprStructFields &struct_expr) // process arguments auto &argument = struct_expr.get_fields ().at (i); auto lvalue_locus - = ctx->get_mappings ()->lookup_location (expected->get_ty_ref ()); + = ctx->get_mappings ().lookup_location (expected->get_ty_ref ()); auto rvalue_locus = argument->get_locus (); auto rvalue = CompileStructExprField::Compile (argument.get (), ctx); @@ -735,7 +735,7 @@ CompileExpr::visit (HIR::BreakExpr &expr) } HirId ref = UNKNOWN_HIRID; - if (!ctx->get_mappings ()->lookup_node_to_hir (resolved_node_id, &ref)) + if (!ctx->get_mappings ().lookup_node_to_hir (resolved_node_id, &ref)) { rust_fatal_error (expr.get_locus (), "reverse lookup label failure"); return; @@ -779,7 +779,7 @@ CompileExpr::visit (HIR::ContinueExpr &expr) } HirId ref = UNKNOWN_HIRID; - if (!ctx->get_mappings ()->lookup_node_to_hir (resolved_node_id, &ref)) + if (!ctx->get_mappings ().lookup_node_to_hir (resolved_node_id, &ref)) { rust_fatal_error (expr.get_locus (), "reverse lookup label failure"); return; @@ -1153,7 +1153,7 @@ CompileExpr::visit (HIR::CallExpr &expr) // coerce it if required location_t lvalue_locus - = ctx->get_mappings ()->lookup_location (expected->get_ty_ref ()); + = ctx->get_mappings ().lookup_location (expected->get_ty_ref ()); location_t rvalue_locus = argument->get_locus (); rvalue = coercion_site (argument->get_mappings ().get_hirid (), rvalue, @@ -1257,7 +1257,7 @@ CompileExpr::visit (HIR::CallExpr &expr) // coerce it if required location_t lvalue_locus - = ctx->get_mappings ()->lookup_location (expected->get_ty_ref ()); + = ctx->get_mappings ().lookup_location (expected->get_ty_ref ()); location_t rvalue_locus = argument->get_locus (); rvalue = coercion_site (argument->get_mappings ().get_hirid (), rvalue, actual, expected, lvalue_locus, rvalue_locus); @@ -1346,7 +1346,7 @@ CompileExpr::visit (HIR::MethodCallExpr &expr) // coerce it if required location_t lvalue_locus - = ctx->get_mappings ()->lookup_location (expected->get_ty_ref ()); + = ctx->get_mappings ().lookup_location (expected->get_ty_ref ()); location_t rvalue_locus = argument->get_locus (); rvalue = coercion_site (argument->get_mappings ().get_hirid (), rvalue, actual, expected, lvalue_locus, rvalue_locus); @@ -2175,7 +2175,7 @@ CompileExpr::visit (HIR::ClosureExpr &expr) { // lookup the HirId HirId ref = UNKNOWN_HIRID; - bool ok = ctx->get_mappings ()->lookup_node_to_hir (capture, &ref); + bool ok = ctx->get_mappings ().lookup_node_to_hir (capture, &ref); rust_assert (ok); // lookup the var decl @@ -2209,7 +2209,7 @@ CompileExpr::generate_closure_function (HIR::ClosureExpr &expr, const Resolver::CanonicalPath &parent_canonical_path = closure_tyty.get_ident ().path; NodeId node_id; - bool ok = ctx->get_mappings ()->lookup_hir_to_node ( + bool ok = ctx->get_mappings ().lookup_hir_to_node ( expr.get_mappings ().get_hirid (), &node_id); rust_assert (ok); Resolver::CanonicalPath path = parent_canonical_path.append ( @@ -2245,7 +2245,7 @@ CompileExpr::generate_closure_function (HIR::ClosureExpr &expr, { // lookup the HirId HirId ref = UNKNOWN_HIRID; - bool ok = ctx->get_mappings ()->lookup_node_to_hir (capture, &ref); + bool ok = ctx->get_mappings ().lookup_node_to_hir (capture, &ref); rust_assert (ok); // get the assessor diff --git a/gcc/rust/backend/rust-compile-extern.h b/gcc/rust/backend/rust-compile-extern.h index 7dbf7d7..f596ed2 100644 --- a/gcc/rust/backend/rust-compile-extern.h +++ b/gcc/rust/backend/rust-compile-extern.h @@ -135,7 +135,7 @@ public: { // then we need to get the canonical path of it and mangle it const Resolver::CanonicalPath *canonical_path = nullptr; - bool ok = ctx->get_mappings ()->lookup_canonical_path ( + bool ok = ctx->get_mappings ().lookup_canonical_path ( function.get_mappings ().get_nodeid (), &canonical_path); rust_assert (ok); diff --git a/gcc/rust/backend/rust-compile-implitem.cc b/gcc/rust/backend/rust-compile-implitem.cc index 7435833..0f24417 100644 --- a/gcc/rust/backend/rust-compile-implitem.cc +++ b/gcc/rust/backend/rust-compile-implitem.cc @@ -28,7 +28,7 @@ CompileTraitItem::visit (HIR::TraitItemConst &constant) TyTy::BaseType *resolved_type = concrete; const Resolver::CanonicalPath *canonical_path = nullptr; - bool ok = ctx->get_mappings ()->lookup_canonical_path ( + bool ok = ctx->get_mappings ().lookup_canonical_path ( constant.get_mappings ().get_nodeid (), &canonical_path); rust_assert (ok); @@ -78,7 +78,7 @@ CompileTraitItem::visit (HIR::TraitItemFunc &func) } const Resolver::CanonicalPath *canonical_path = nullptr; - bool ok = ctx->get_mappings ()->lookup_canonical_path ( + bool ok = ctx->get_mappings ().lookup_canonical_path ( func.get_mappings ().get_nodeid (), &canonical_path); rust_assert (ok); diff --git a/gcc/rust/backend/rust-compile-intrinsic.cc b/gcc/rust/backend/rust-compile-intrinsic.cc index f94659c..de3bb6e 100644 --- a/gcc/rust/backend/rust-compile-intrinsic.cc +++ b/gcc/rust/backend/rust-compile-intrinsic.cc @@ -269,7 +269,7 @@ Intrinsics::compile (TyTy::FnType *fntype) if (it != generic_intrinsics.end ()) return it->second (ctx, fntype); - location_t locus = ctx->get_mappings ()->lookup_location (fntype->get_ref ()); + location_t locus = ctx->get_mappings ().lookup_location (fntype->get_ref ()); rust_error_at (locus, ErrorCode::E0093, "unrecognized intrinsic function: %qs", fntype->get_identifier ().c_str ()); diff --git a/gcc/rust/backend/rust-compile-item.cc b/gcc/rust/backend/rust-compile-item.cc index 7c62adc..9d65b61 100644 --- a/gcc/rust/backend/rust-compile-item.cc +++ b/gcc/rust/backend/rust-compile-item.cc @@ -43,7 +43,7 @@ CompileItem::visit (HIR::StaticItem &var) tree type = TyTyResolveCompile::compile (ctx, resolved_type); const Resolver::CanonicalPath *canonical_path = nullptr; - ok = ctx->get_mappings ()->lookup_canonical_path ( + ok = ctx->get_mappings ().lookup_canonical_path ( var.get_mappings ().get_nodeid (), &canonical_path); rust_assert (ok); @@ -103,8 +103,8 @@ CompileItem::visit (HIR::ConstantItem &constant) else { const Resolver::CanonicalPath *canonical_path_ptr = nullptr; - ok = ctx->get_mappings ()->lookup_canonical_path (mappings.get_nodeid (), - &canonical_path_ptr); + ok = ctx->get_mappings ().lookup_canonical_path (mappings.get_nodeid (), + &canonical_path_ptr); rust_assert (ok); canonical_path = *canonical_path_ptr; } @@ -155,7 +155,7 @@ CompileItem::visit (HIR::Function &function) HirId parent_impl_block = UNKNOWN_HIRID; HirId id = function.get_mappings ().get_hirid (); HIR::ImplItem *impl_item - = ctx->get_mappings ()->lookup_hir_implitem (id, &parent_impl_block); + = ctx->get_mappings ().lookup_hir_implitem (id, &parent_impl_block); if (impl_item != nullptr) { Resolver::AssociatedImplTrait *impl = nullptr; @@ -182,7 +182,7 @@ CompileItem::visit (HIR::Function &function) else { const Resolver::CanonicalPath *path = nullptr; - bool ok = ctx->get_mappings ()->lookup_canonical_path ( + bool ok = ctx->get_mappings ().lookup_canonical_path ( function.get_mappings ().get_nodeid (), &path); rust_assert (ok); diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc index 91f2deb..ea8bb5b 100644 --- a/gcc/rust/backend/rust-compile-resolve-path.cc +++ b/gcc/rust/backend/rust-compile-resolve-path.cc @@ -126,7 +126,7 @@ ResolvePathRef::resolve (const HIR::PathIdentSegment &final_segment, } HirId ref; - if (!ctx->get_mappings ()->lookup_node_to_hir (ref_node_id, &ref)) + if (!ctx->get_mappings ().lookup_node_to_hir (ref_node_id, &ref)) { rust_error_at (expr_locus, "reverse call path lookup failure"); return error_mark_node; @@ -199,10 +199,10 @@ HIRCompileBase::query_compile (HirId ref, TyTy::BaseType *lookup, const Analysis::NodeMapping &mappings, location_t expr_locus, bool is_qualified_path) { - HIR::Item *resolved_item = ctx->get_mappings ()->lookup_hir_item (ref); + HIR::Item *resolved_item = ctx->get_mappings ().lookup_hir_item (ref); HirId parent_block; HIR::ExternalItem *resolved_extern_item - = ctx->get_mappings ()->lookup_hir_extern_item (ref, &parent_block); + = ctx->get_mappings ().lookup_hir_extern_item (ref, &parent_block); bool is_hir_item = resolved_item != nullptr; bool is_hir_extern_item = resolved_extern_item != nullptr; bool is_fn = lookup->get_kind () == TyTy::TypeKind::FNDEF; @@ -242,7 +242,7 @@ HIRCompileBase::query_compile (HirId ref, TyTy::BaseType *lookup, HirId parent_impl_id = UNKNOWN_HIRID; HIR::ImplItem *resolved_item - = ctx->get_mappings ()->lookup_hir_implitem (ref, &parent_impl_id); + = ctx->get_mappings ().lookup_hir_implitem (ref, &parent_impl_id); bool is_impl_item = resolved_item != nullptr; if (is_impl_item) { @@ -257,8 +257,8 @@ HIRCompileBase::query_compile (HirId ref, TyTy::BaseType *lookup, { // it might be resolved to a trait item HIR::TraitItem *trait_item - = ctx->get_mappings ()->lookup_hir_trait_item (ref); - HIR::Trait *trait = ctx->get_mappings ()->lookup_trait_item_mapping ( + = ctx->get_mappings ().lookup_hir_trait_item (ref); + HIR::Trait *trait = ctx->get_mappings ().lookup_trait_item_mapping ( trait_item->get_mappings ().get_hirid ()); Resolver::TraitReference *trait_ref diff --git a/gcc/rust/backend/rust-compile-type.cc b/gcc/rust/backend/rust-compile-type.cc index bfc2464..4b42cef 100644 --- a/gcc/rust/backend/rust-compile-type.cc +++ b/gcc/rust/backend/rust-compile-type.cc @@ -147,7 +147,7 @@ TyTyResolveCompile::visit (const TyTy::PlaceholderType &type) void TyTyResolveCompile::visit (const TyTy::ClosureType &type) { - auto mappings = ctx->get_mappings (); + auto &mappings = ctx->get_mappings (); std::vector<Backend::typed_identifier> fields; @@ -156,7 +156,7 @@ TyTyResolveCompile::visit (const TyTy::ClosureType &type) { // lookup the HirId HirId ref = UNKNOWN_HIRID; - bool ok = mappings->lookup_node_to_hir (capture, &ref); + bool ok = mappings.lookup_node_to_hir (capture, &ref); rust_assert (ok); // lookup the var decl type @@ -201,7 +201,7 @@ TyTyResolveCompile::visit (const TyTy::FnType &type) { auto ret = TyTyResolveCompile::compile (ctx, hir_type, trait_object_mode); location_t return_type_locus - = ctx->get_mappings ()->lookup_location (hir_type->get_ref ()); + = ctx->get_mappings ().lookup_location (hir_type->get_ref ()); results.push_back ( Backend::typed_identifier ("_", ret, return_type_locus)); } @@ -214,7 +214,7 @@ TyTyResolveCompile::visit (const TyTy::FnType &type) auto compiled_param = Backend::typed_identifier ( param_pair.first->as_string (), compiled_param_type, - ctx->get_mappings ()->lookup_location (param_tyty->get_ref ())); + ctx->get_mappings ().lookup_location (param_tyty->get_ref ())); parameters.push_back (compiled_param); } @@ -263,7 +263,7 @@ TyTyResolveCompile::visit (const TyTy::ADTType &type) = TyTyResolveCompile::compile (ctx, field->get_field_type ()); Backend::typed_identifier f (field->get_name (), compiled_field_ty, - ctx->get_mappings ()->lookup_location ( + ctx->get_mappings ().lookup_location ( type.get_ty_ref ())); fields.push_back (std::move (f)); } @@ -307,7 +307,7 @@ TyTyResolveCompile::visit (const TyTy::ADTType &type) tree enumeral_type = TyTyResolveCompile::get_implicit_enumeral_node_type (ctx); Backend::typed_identifier f (RUST_ENUM_DISR_FIELD_NAME, enumeral_type, - ctx->get_mappings ()->lookup_location ( + ctx->get_mappings ().lookup_location ( variant->get_id ())); fields.push_back (std::move (f)); @@ -326,7 +326,7 @@ TyTyResolveCompile::visit (const TyTy::ADTType &type) Backend::typed_identifier f ( field_name, compiled_field_ty, - ctx->get_mappings ()->lookup_location (type.get_ty_ref ())); + ctx->get_mappings ().lookup_location (type.get_ty_ref ())); fields.push_back (std::move (f)); } @@ -353,7 +353,7 @@ TyTyResolveCompile::visit (const TyTy::ADTType &type) std::string implicit_variant_name = variant->get_identifier (); Backend::typed_identifier f (implicit_variant_name, variant_record, - ctx->get_mappings ()->lookup_location ( + ctx->get_mappings ().lookup_location ( type.get_ty_ref ())); enum_fields.push_back (std::move (f)); } @@ -411,7 +411,7 @@ TyTyResolveCompile::visit (const TyTy::TupleType &type) // approach makes it simpler to use a C-only debugger, or // GDB's C mode, when debugging Rust. Backend::typed_identifier f ("__" + std::to_string (i), compiled_field_ty, - ctx->get_mappings ()->lookup_location ( + ctx->get_mappings ().lookup_location ( type.get_ty_ref ())); fields.push_back (std::move (f)); } @@ -714,14 +714,14 @@ TyTyResolveCompile::create_dyn_obj_record (const TyTy::DynamicObjectType &type) tree uintptr_ty = build_pointer_type (uint); Backend::typed_identifier f ("pointer", uintptr_ty, - ctx->get_mappings ()->lookup_location ( + ctx->get_mappings ().lookup_location ( type.get_ty_ref ())); fields.push_back (std::move (f)); tree vtable_size = build_int_cst (size_type_node, items.size ()); tree vtable_type = Backend::array_type (uintptr_ty, vtable_size); Backend::typed_identifier vtf ("vtable", vtable_type, - ctx->get_mappings ()->lookup_location ( + ctx->get_mappings ().lookup_location ( type.get_ty_ref ())); fields.push_back (std::move (vtf)); diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc index 47a6dad..20190c3 100644 --- a/gcc/rust/backend/rust-compile.cc +++ b/gcc/rust/backend/rust-compile.cc @@ -189,7 +189,7 @@ HIRCompileBase::coerce_to_dyn_object (tree compiled_ref, location_t locus) { // DST's get wrapped in a pseudo reference that doesnt exist... - const TyTy::ReferenceType r (ctx->get_mappings ()->get_next_hir_id (), + const TyTy::ReferenceType r (ctx->get_mappings ().get_next_hir_id (), TyTy::TyVar (ty->get_ref ()), Mutability::Imm); tree dynamic_object = TyTyResolveCompile::compile (ctx, &r); diff --git a/gcc/rust/backend/rust-mangle-v0.cc b/gcc/rust/backend/rust-mangle-v0.cc index c8582b5..0c85d42 100644 --- a/gcc/rust/backend/rust-mangle-v0.cc +++ b/gcc/rust/backend/rust-mangle-v0.cc @@ -369,13 +369,13 @@ static std::string v0_path (Rust::Compile::Context *ctx, const TyTy::BaseType *ty, const Resolver::CanonicalPath &cpath) { - auto mappings = Analysis::Mappings::get (); + auto &mappings = Analysis::Mappings::get (); V0Path v0path = {}; cpath.iterate_segs ([&] (const Resolver::CanonicalPath &seg) { HirId hir_id; - bool ok = mappings->lookup_node_to_hir (seg.get_node_id (), &hir_id); + bool ok = mappings.lookup_node_to_hir (seg.get_node_id (), &hir_id); if (!ok) { // FIXME: generic arg in canonical path? (e.g. <i32> in crate::S<i32>) @@ -384,10 +384,10 @@ v0_path (Rust::Compile::Context *ctx, const TyTy::BaseType *ty, HirId parent_impl_id = UNKNOWN_HIRID; HIR::ImplItem *impl_item - = mappings->lookup_hir_implitem (hir_id, &parent_impl_id); - HIR::TraitItem *trait_item = mappings->lookup_hir_trait_item (hir_id); - HIR::Item *item = mappings->lookup_hir_item (hir_id); - HIR::Expr *expr = mappings->lookup_hir_expr (hir_id); + = mappings.lookup_hir_implitem (hir_id, &parent_impl_id); + HIR::TraitItem *trait_item = mappings.lookup_hir_trait_item (hir_id); + HIR::Item *item = mappings.lookup_hir_item (hir_id); + HIR::Expr *expr = mappings.lookup_hir_expr (hir_id); if (impl_item != nullptr) { @@ -490,7 +490,7 @@ v0_mangle_item (Rust::Compile::Context *ctx, const TyTy::BaseType *ty, rust_debug ("Start mangling: %s", path.get ().c_str ()); // TODO: get Instanciating CrateNum - // auto mappings = Analysis::Mappings::get (); + // auto &mappings = Analysis::Mappings::get (); // std::string crate_name; // bool ok = mappings->get_crate_name (path.get_crate_num (), crate_name); // rust_assert (ok); |