diff options
author | David Faust <david.faust@oracle.com> | 2021-11-15 10:27:34 -0800 |
---|---|---|
committer | David Faust <david.faust@oracle.com> | 2021-11-16 13:15:56 -0800 |
commit | 5c87e61f96e0b394ce406bf9967c92708a16becc (patch) | |
tree | 7bd431f6cd496e67e3ac8947f975a636093a1485 /gcc | |
parent | 01a52df9440a78ec5221c7f2430f06e770133e06 (diff) | |
download | gcc-5c87e61f96e0b394ce406bf9967c92708a16becc.zip gcc-5c87e61f96e0b394ce406bf9967c92708a16becc.tar.gz gcc-5c87e61f96e0b394ce406bf9967c92708a16becc.tar.bz2 |
clang-format and minor cleanup
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/backend/rust-compile-context.h | 64 | ||||
-rw-r--r-- | gcc/rust/rust-backend.h | 11 | ||||
-rw-r--r-- | gcc/rust/rust-gcc.cc | 28 |
3 files changed, 50 insertions, 53 deletions
diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index 72ab4f2..668e8ba 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -35,7 +35,7 @@ namespace Compile { struct fncontext { - ::tree fndecl; + tree fndecl; ::Bvariable *ret_addr; }; @@ -61,19 +61,19 @@ public: rust_assert (ok); tree compiled = TyTyCompile::compile (backend, lookup); - compiled_type_map.insert (std::pair<HirId, tree > (ref, compiled)); + compiled_type_map.insert (std::pair<HirId, tree> (ref, compiled)); builtin_range.insert (ref); } } - bool lookup_compiled_types (HirId id, ::tree *type, + bool lookup_compiled_types (HirId id, tree *type, const TyTy::BaseType *ref = nullptr) { if (ref != nullptr) { for (auto it = mono.begin (); it != mono.end (); it++) { - std::pair<HirId, ::tree > &val = it->second; + std::pair<HirId, tree> &val = it->second; const TyTy::BaseType *r = it->first; if (ref->is_equal (*r)) @@ -94,14 +94,14 @@ public: return true; } - void insert_compiled_type (HirId id, ::tree type, + void insert_compiled_type (HirId id, tree type, const TyTy::BaseType *ref = nullptr) { rust_assert (builtin_range.find (id) == builtin_range.end ()); - compiled_type_map.insert (std::pair<HirId, tree > (id, type)); + compiled_type_map.insert (std::pair<HirId, tree> (id, type)); if (ref != nullptr) { - std::pair<HirId, ::tree > elem (id, type); + std::pair<HirId, tree> elem (id, type); mono[ref] = std::move (elem); } } @@ -209,9 +209,9 @@ public: return true; } - void insert_const_decl (HirId id, ::tree expr) { compiled_consts[id] = expr; } + void insert_const_decl (HirId id, tree expr) { compiled_consts[id] = expr; } - bool lookup_const_decl (HirId id, ::tree *expr) + bool lookup_const_decl (HirId id, tree *expr) { auto it = compiled_consts.find (id); if (it == compiled_consts.end ()) @@ -240,9 +240,9 @@ public: void pop_fn () { fn_stack.pop_back (); } fncontext peek_fn () { return fn_stack.back (); } - void push_type (::tree t) { type_decls.push_back (t); } + void push_type (tree t) { type_decls.push_back (t); } void push_var (::Bvariable *v) { var_decls.push_back (v); } - void push_const (::tree c) { const_decls.push_back (c); } + void push_const (tree c) { const_decls.push_back (c); } void push_function (tree f) { func_decls.push_back (f); } void write_to_backend () @@ -323,7 +323,7 @@ private: std::vector<tree> scope_stack; std::vector<::Bvariable *> loop_value_stack; std::vector<tree> loop_begin_labels; - std::map<const TyTy::BaseType *, std::pair<HirId, ::tree >> mono; + std::map<const TyTy::BaseType *, std::pair<HirId, tree>> mono; std::map<DefId, std::vector<std::pair<const TyTy::BaseType *, tree>>> mono_fns; @@ -338,7 +338,7 @@ class TyTyResolveCompile : public TyTy::TyConstVisitor { public: static tree compile (Context *ctx, const TyTy::BaseType *ty, - bool trait_object_mode = false) + bool trait_object_mode = false) { TyTyResolveCompile compiler (ctx, trait_object_mode); ty->accept_vis (compiler); @@ -410,7 +410,7 @@ public: tree result_type = TyTyResolveCompile::compile (ctx, type.get_return_type ()); - std::vector<tree > parameters; + std::vector<tree> parameters; type.iterate_params ([&] (TyTy::BaseType *p) mutable -> bool { tree pty = TyTyResolveCompile::compile (ctx, p); parameters.push_back (pty); @@ -440,8 +440,8 @@ public: = TyTyResolveCompile::compile (ctx, field->get_field_type ()); Backend::typed_identifier f (field->get_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)); } @@ -488,9 +488,9 @@ public: // 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 ( - type.get_ty_ref ())); + compiled_field_ty, + ctx->get_mappings ()->lookup_location ( + type.get_ty_ref ())); fields.push_back (std::move (f)); } @@ -515,7 +515,7 @@ public: void visit (const TyTy::BoolType &type) override { - ::tree compiled_type = nullptr; + tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -523,7 +523,7 @@ public: void visit (const TyTy::IntType &type) override { - ::tree compiled_type = nullptr; + tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -531,7 +531,7 @@ public: void visit (const TyTy::UintType &type) override { - ::tree compiled_type = nullptr; + tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -539,7 +539,7 @@ public: void visit (const TyTy::FloatType &type) override { - ::tree compiled_type = nullptr; + tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -547,7 +547,7 @@ public: void visit (const TyTy::USizeType &type) override { - ::tree compiled_type = nullptr; + tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -555,7 +555,7 @@ public: void visit (const TyTy::ISizeType &type) override { - ::tree compiled_type = nullptr; + tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -563,7 +563,7 @@ public: void visit (const TyTy::CharType &type) override { - ::tree compiled_type = nullptr; + tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -601,7 +601,7 @@ public: void visit (const TyTy::StrType &type) override { - ::tree compiled_type = nullptr; + tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -633,8 +633,8 @@ public: tree uintptr_ty = ctx->get_backend ()->pointer_type (uint); Backend::typed_identifier f ("__receiver_trait_obj_ptr", uintptr_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)); for (size_t i = 0; i < items.size (); i++) @@ -645,8 +645,8 @@ public: tree uintptr_ty = ctx->get_backend ()->pointer_type (uint); Backend::typed_identifier f ("__" + std::to_string (i), uintptr_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)); } @@ -672,7 +672,7 @@ private: Context *ctx; bool trait_object_mode; - ::tree translated; + tree translated; size_t recursion_count; static const size_t kDefaultRecusionLimit = 5; diff --git a/gcc/rust/rust-backend.h b/gcc/rust/rust-backend.h index 6a06cd7..64144bc 100644 --- a/gcc/rust/rust-backend.h +++ b/gcc/rust/rust-backend.h @@ -65,7 +65,7 @@ public: {} typed_identifier (const std::string &a_name, tree a_type, - Location a_location) + Location a_location) : name (a_name), type (a_type), location (a_location) {} }; @@ -180,11 +180,10 @@ public: // one result, RESULT_STRUCT is a struct type to hold the results, // and RESULTS may be ignored; if there are zero or one results, // RESULT_STRUCT is NULL. - virtual tree - function_type (const typed_identifier &receiver, - const std::vector<typed_identifier> ¶meters, - const std::vector<typed_identifier> &results, - tree result_struct, Location location) + virtual tree function_type (const typed_identifier &receiver, + const std::vector<typed_identifier> ¶meters, + const std::vector<typed_identifier> &results, + tree result_struct, Location location) = 0; virtual tree diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc index 482d11f..12df769 100644 --- a/gcc/rust/rust-gcc.cc +++ b/gcc/rust/rust-gcc.cc @@ -199,14 +199,14 @@ public: tree insert_type_attribute (tree, const std::string &); tree function_type (const typed_identifier &, - const std::vector<typed_identifier> &, - const std::vector<typed_identifier> &, tree, - const Location); + const std::vector<typed_identifier> &, + const std::vector<typed_identifier> &, tree, + const Location); tree function_type_varadic (const typed_identifier &, - const std::vector<typed_identifier> &, - const std::vector<typed_identifier> &, tree, - const Location); + const std::vector<typed_identifier> &, + const std::vector<typed_identifier> &, tree, + const Location); tree function_ptr_type (tree, const std::vector<tree> &, Location); @@ -360,8 +360,8 @@ public: Bvariable *temporary_variable (tree, tree, tree, tree, bool, Location, tree *); - Bvariable *implicit_variable (const std::string &, const std::string &, - tree, bool, bool, bool, int64_t); + Bvariable *implicit_variable (const std::string &, const std::string &, tree, + bool, bool, bool, int64_t); void implicit_variable_set_init (Bvariable *, const std::string &, tree, bool, bool, bool, tree); @@ -376,8 +376,7 @@ public: tree, Location, tree); Bvariable *immutable_struct_reference (const std::string &, - const std::string &, tree, - Location); + const std::string &, tree, Location); // Labels. @@ -416,7 +415,6 @@ public: void write_export_data (const char *bytes, unsigned int size); private: - tree fill_in_fields (tree, const std::vector<typed_identifier> &); tree fill_in_array (tree, tree, tree); @@ -1080,9 +1078,8 @@ Gcc_backend::fill_in_array (tree fill, tree element_type, tree length_tree) SET_TYPE_STRUCTURAL_EQUALITY (fill); else if (TYPE_CANONICAL (element_type) != element_type || TYPE_CANONICAL (index_type_tree) != index_type_tree) - TYPE_CANONICAL (fill) - = build_array_type (TYPE_CANONICAL (element_type), - TYPE_CANONICAL (index_type_tree)); + TYPE_CANONICAL (fill) = build_array_type (TYPE_CANONICAL (element_type), + TYPE_CANONICAL (index_type_tree)); return fill; } @@ -1387,7 +1384,8 @@ Gcc_backend::convert_expression (tree type_tree, tree expr_tree, return this->error_expression (); tree ret; - if (this->type_size (type_tree) == 0 || TREE_TYPE (expr_tree) == void_type_node) + if (this->type_size (type_tree) == 0 + || TREE_TYPE (expr_tree) == void_type_node) { // Do not convert zero-sized types. ret = expr_tree; |