From 2ad8c35f7281c8acf0a729b7f28cd521c1846169 Mon Sep 17 00:00:00 2001 From: Owen Avery Date: Tue, 10 Oct 2023 02:36:42 -0400 Subject: [PATCH] fix formatting --- gcc/rust/ast/rust-ast.h | 8 +-- gcc/rust/ast/rust-item.h | 69 +++++++++++++++----------- gcc/rust/ast/rust-macro.h | 21 ++++---- gcc/rust/ast/rust-path.h | 10 ++-- gcc/rust/expand/rust-expand-visitor.cc | 6 ++- 5 files changed, 67 insertions(+), 47 deletions(-) diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 7a0eb4e6b25a..fc5ccfc8d858 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -85,13 +85,13 @@ class Located virtual location_t get_locus () const = 0; }; -class LocatedImpl: virtual public Located +class LocatedImpl : virtual public Located { private: location_t locus; protected: - LocatedImpl (location_t locus): locus (locus) {} + LocatedImpl (location_t locus) : locus (locus) {} public: location_t get_locus () const override final { return locus; } @@ -1181,7 +1181,9 @@ class IdentifierExpr : public ExprWithoutBlock }; // Pattern base AST node -class Pattern : public Visitable, virtual public Located, virtual public NodeIdStore +class Pattern : public Visitable, + virtual public Located, + virtual public NodeIdStore { public: // Unique pointer custom clone function diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h index 7facdd411e72..d44cdbbd931c 100644 --- a/gcc/rust/ast/rust-item.h +++ b/gcc/rust/ast/rust-item.h @@ -1034,9 +1034,10 @@ class Module : public VisItem, public LocatedImpl Module (Identifier module_name, Visibility visibility, std::vector outer_attrs, location_t locus, std::string outer_filename, std::vector module_scope) - : VisItem (std::move (visibility), std::move (outer_attrs)), LocatedImpl (locus), - module_name (module_name), kind (ModuleKind::UNLOADED), - outer_filename (outer_filename), inner_attrs (std::vector ()), + : VisItem (std::move (visibility), std::move (outer_attrs)), + LocatedImpl (locus), module_name (module_name), + kind (ModuleKind::UNLOADED), outer_filename (outer_filename), + inner_attrs (std::vector ()), items (std::vector> ()), module_scope (std::move (module_scope)) {} @@ -1047,8 +1048,8 @@ class Module : public VisItem, public LocatedImpl Visibility visibility = Visibility::create_error (), std::vector inner_attrs = std::vector (), std::vector outer_attrs = std::vector ()) - : VisItem (std::move (visibility), std::move (outer_attrs)), LocatedImpl (locus), - module_name (name), kind (ModuleKind::LOADED), + : VisItem (std::move (visibility), std::move (outer_attrs)), + LocatedImpl (locus), module_name (name), kind (ModuleKind::LOADED), outer_filename (std::string ()), inner_attrs (std::move (inner_attrs)), items (std::move (items)) {} @@ -1700,7 +1701,9 @@ class Function : public VisItem, public AssociatedItem }; // Rust type alias (i.e. typedef) AST node -class TypeAlias : public VisItem, public AssociatedItem, virtual public LocatedImpl +class TypeAlias : public VisItem, + public AssociatedItem, + virtual public LocatedImpl { Identifier new_type_name; @@ -2572,8 +2575,7 @@ class Union : public VisItem /* "Constant item" AST node - used for constant, compile-time expressions * within module scope (like constexpr) */ -class ConstantItem : public VisItem, - public AssociatedItem +class ConstantItem : public VisItem, public AssociatedItem { // either has an identifier or "_" - maybe handle in identifier? // bool identifier_is_underscore; @@ -2910,7 +2912,9 @@ class TraitFunctionDecl }; // Actual trait item function declaration within traits -class TraitItemFunc : public AssociatedItem, public LocatedImpl, public NodeIdStore +class TraitItemFunc : public AssociatedItem, + public LocatedImpl, + public NodeIdStore { std::vector outer_attrs; TraitFunctionDecl decl; @@ -3123,7 +3127,9 @@ class TraitMethodDecl }; // Actual trait item method declaration within traits -class TraitItemMethod : public AssociatedItem, public LocatedImpl, public NodeIdStore +class TraitItemMethod : public AssociatedItem, + public LocatedImpl, + public NodeIdStore { std::vector outer_attrs; TraitMethodDecl decl; @@ -3204,7 +3210,9 @@ class TraitItemMethod : public AssociatedItem, public LocatedImpl, public NodeId }; // Constant item within traits -class TraitItemConst : public AssociatedItem, public LocatedImpl, public NodeIdStore +class TraitItemConst : public AssociatedItem, + public LocatedImpl, + public NodeIdStore { std::vector outer_attrs; Identifier name; @@ -3304,7 +3312,9 @@ class TraitItemConst : public AssociatedItem, public LocatedImpl, public NodeIdS }; // Type items within traits -class TraitItemType : public AssociatedItem, public LocatedImpl, public NodeIdStore +class TraitItemType : public AssociatedItem, + public LocatedImpl, + public NodeIdStore { std::vector outer_attrs; @@ -3429,9 +3439,9 @@ class Trait : public VisItem std::vector> generic_params, std::vector> type_param_bounds, WhereClause where_clause, - std::vector> trait_items, Visibility vis, - std::vector outer_attrs, std::vector inner_attrs, - location_t locus) + std::vector> trait_items, + Visibility vis, std::vector outer_attrs, + std::vector inner_attrs, location_t locus) : VisItem (std::move (vis), std::move (outer_attrs)), has_unsafe (is_unsafe), has_auto (is_auto), name (std::move (name)), generic_params (std::move (generic_params)), @@ -3920,9 +3930,9 @@ class ExternalTypeItem : public ExternalItem {} ExternalTypeItem (ExternalTypeItem const &other) - : ExternalItem (other), outer_attrs (other.outer_attrs), visibility (other.visibility), - item_name (other.item_name), locus (other.locus), - marked_for_strip (other.marked_for_strip) + : ExternalItem (other), outer_attrs (other.outer_attrs), + visibility (other.visibility), item_name (other.item_name), + locus (other.locus), marked_for_strip (other.marked_for_strip) {} ExternalTypeItem &operator= (ExternalTypeItem const &other) @@ -3993,15 +4003,16 @@ class ExternalStaticItem : public ExternalItem ExternalStaticItem (Identifier item_name, std::unique_ptr item_type, bool is_mut, Visibility vis, std::vector outer_attrs, location_t locus) - : outer_attrs (std::move (outer_attrs)), - visibility (std::move (vis)), item_name (std::move (item_name)), - locus (locus), has_mut (is_mut), item_type (std::move (item_type)) + : outer_attrs (std::move (outer_attrs)), visibility (std::move (vis)), + item_name (std::move (item_name)), locus (locus), has_mut (is_mut), + item_type (std::move (item_type)) {} // Copy constructor ExternalStaticItem (ExternalStaticItem const &other) - : ExternalItem (other), outer_attrs (other.outer_attrs), visibility (other.visibility), - item_name (other.item_name), locus (other.locus), has_mut (other.has_mut) + : ExternalItem (other), outer_attrs (other.outer_attrs), + visibility (other.visibility), item_name (other.item_name), + locus (other.locus), has_mut (other.has_mut) { // guard to prevent null dereference (only required if error state) if (other.item_type != nullptr) @@ -4237,9 +4248,9 @@ class ExternalFunctionItem : public ExternalItem std::vector function_params, bool has_variadics, std::vector variadic_outer_attrs, Visibility vis, std::vector outer_attrs, location_t locus) - : outer_attrs (std::move (outer_attrs)), - visibility (std::move (vis)), item_name (std::move (item_name)), - locus (locus), generic_params (std::move (generic_params)), + : outer_attrs (std::move (outer_attrs)), visibility (std::move (vis)), + item_name (std::move (item_name)), locus (locus), + generic_params (std::move (generic_params)), return_type (std::move (return_type)), where_clause (std::move (where_clause)), function_params (std::move (function_params)), @@ -4252,9 +4263,9 @@ class ExternalFunctionItem : public ExternalItem // Copy constructor with clone ExternalFunctionItem (ExternalFunctionItem const &other) - : ExternalItem (other), outer_attrs (other.outer_attrs), visibility (other.visibility), - item_name (other.item_name), locus (other.locus), - where_clause (other.where_clause), + : ExternalItem (other), outer_attrs (other.outer_attrs), + visibility (other.visibility), item_name (other.item_name), + locus (other.locus), where_clause (other.where_clause), function_params (other.function_params), has_variadics (other.has_variadics), variadic_outer_attrs (other.variadic_outer_attrs) diff --git a/gcc/rust/ast/rust-macro.h b/gcc/rust/ast/rust-macro.h index b789b96c6ed0..79c1ce54161c 100644 --- a/gcc/rust/ast/rust-macro.h +++ b/gcc/rust/ast/rust-macro.h @@ -505,11 +505,12 @@ class MacroRulesDefinition : public VisItem, public LocatedImpl MacroRulesDefinition (Identifier builtin_name, DelimType delim_type, MacroTranscriberFunc associated_transcriber, MacroKind kind, Visibility vis) - : VisItem (std::move (vis), std::vector ()), LocatedImpl (UNDEF_LOCATION), - outer_attrs (std::vector ()), rule_name (builtin_name), - delim_type (delim_type), rules (std::vector ()), - associated_transcriber (associated_transcriber), - is_builtin_rule (true), kind (kind) + : VisItem (std::move (vis), std::vector ()), + LocatedImpl (UNDEF_LOCATION), outer_attrs (std::vector ()), + rule_name (builtin_name), delim_type (delim_type), + rules (std::vector ()), + associated_transcriber (associated_transcriber), is_builtin_rule (true), + kind (kind) {} public: @@ -704,16 +705,18 @@ class MacroInvocation : public TypeNoBounds, MacroInvocData invoc_data, std::vector outer_attrs, location_t locus, bool is_semi_coloned, std::vector> &&pending_eager_invocs) - : LocatedImpl (locus), outer_attrs (std::move (outer_attrs)), macro_node_id (Analysis::Mappings::get ()->get_next_node_id ()), + : LocatedImpl (locus), outer_attrs (std::move (outer_attrs)), + macro_node_id (Analysis::Mappings::get ()->get_next_node_id ()), invoc_data (std::move (invoc_data)), is_semi_coloned (is_semi_coloned), kind (kind), builtin_kind (builtin_kind), pending_eager_invocs (std::move (pending_eager_invocs)) {} MacroInvocation (const MacroInvocation &other) - : NodeIdStore (other), LocatedImpl (other), outer_attrs (other.outer_attrs), macro_node_id (other.macro_node_id), - invoc_data (other.invoc_data), is_semi_coloned (other.is_semi_coloned), - kind (other.kind), builtin_kind (other.builtin_kind) + : NodeIdStore (other), LocatedImpl (other), outer_attrs (other.outer_attrs), + macro_node_id (other.macro_node_id), invoc_data (other.invoc_data), + is_semi_coloned (other.is_semi_coloned), kind (other.kind), + builtin_kind (other.builtin_kind) { if (other.kind == InvocKind::Builtin) for (auto &pending : other.pending_eager_invocs) diff --git a/gcc/rust/ast/rust-path.h b/gcc/rust/ast/rust-path.h index a3ad6816e862..c6fbff50174e 100644 --- a/gcc/rust/ast/rust-path.h +++ b/gcc/rust/ast/rust-path.h @@ -575,7 +575,9 @@ class PathPattern : public Pattern /* AST node representing a path-in-expression pattern (path that allows * generic arguments) */ -class PathInExpression : public PathPattern, public PathExpr, virtual public NodeIdStore +class PathInExpression : public PathPattern, + public PathExpr, + virtual public NodeIdStore { std::vector outer_attrs; bool has_opening_scope_resolution; @@ -590,8 +592,7 @@ class PathInExpression : public PathPattern, public PathExpr, virtual public Nod bool has_opening_scope_resolution = false) : PathPattern (std::move (path_segments)), outer_attrs (std::move (outer_attrs)), - has_opening_scope_resolution (has_opening_scope_resolution), - locus (locus) + has_opening_scope_resolution (has_opening_scope_resolution), locus (locus) {} // Creates an error state path in expression. @@ -1034,7 +1035,8 @@ class TypePath : public TypeNoBounds // Copy constructor with vector clone TypePath (TypePath const &other) - : TypeNoBounds (other), has_opening_scope_resolution (other.has_opening_scope_resolution), + : TypeNoBounds (other), + has_opening_scope_resolution (other.has_opening_scope_resolution), locus (other.locus) { segments.reserve (other.segments.size ()); diff --git a/gcc/rust/expand/rust-expand-visitor.cc b/gcc/rust/expand/rust-expand-visitor.cc index 5cab2b547b96..e33fd4e3a77a 100644 --- a/gcc/rust/expand/rust-expand-visitor.cc +++ b/gcc/rust/expand/rust-expand-visitor.cc @@ -1186,7 +1186,8 @@ ExpandVisitor::visit (AST::Trait &trait) expander.push_context (MacroExpander::ContextType::TRAIT); - std::function (AST::SingleASTNode)> extractor + std::function (AST::SingleASTNode)> + extractor = [] (AST::SingleASTNode node) { return node.take_assoc_item (); }; expand_macro_children (MacroExpander::ContextType::TRAIT, @@ -1214,7 +1215,8 @@ ExpandVisitor::visit (AST::InherentImpl &impl) expand_where_clause (impl.get_where_clause ()); std::function (AST::SingleASTNode)> - extractor = [] (AST::SingleASTNode node) { return node.take_assoc_item (); }; + extractor + = [] (AST::SingleASTNode node) { return node.take_assoc_item (); }; expand_macro_children (MacroExpander::ContextType::IMPL, impl.get_impl_items (), extractor);