Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
powerboat9 committed Oct 10, 2023
1 parent cae91e0 commit 2ad8c35
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 47 deletions.
8 changes: 5 additions & 3 deletions gcc/rust/ast/rust-ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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
Expand Down
69 changes: 40 additions & 29 deletions gcc/rust/ast/rust-item.h
Original file line number Diff line number Diff line change
Expand Up @@ -1034,9 +1034,10 @@ class Module : public VisItem, public LocatedImpl
Module (Identifier module_name, Visibility visibility,
std::vector<Attribute> outer_attrs, location_t locus,
std::string outer_filename, std::vector<std::string> 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<Attribute> ()),
: 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<Attribute> ()),
items (std::vector<std::unique_ptr<Item>> ()),
module_scope (std::move (module_scope))
{}
Expand All @@ -1047,8 +1048,8 @@ class Module : public VisItem, public LocatedImpl
Visibility visibility = Visibility::create_error (),
std::vector<Attribute> inner_attrs = std::vector<Attribute> (),
std::vector<Attribute> outer_attrs = std::vector<Attribute> ())
: 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))
{}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<Attribute> outer_attrs;
TraitFunctionDecl decl;
Expand Down Expand Up @@ -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<Attribute> outer_attrs;
TraitMethodDecl decl;
Expand Down Expand Up @@ -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<Attribute> outer_attrs;
Identifier name;
Expand Down Expand Up @@ -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<Attribute> outer_attrs;

Expand Down Expand Up @@ -3429,9 +3439,9 @@ class Trait : public VisItem
std::vector<std::unique_ptr<GenericParam>> generic_params,
std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds,
WhereClause where_clause,
std::vector<std::unique_ptr<AssociatedItem>> trait_items, Visibility vis,
std::vector<Attribute> outer_attrs, std::vector<Attribute> inner_attrs,
location_t locus)
std::vector<std::unique_ptr<AssociatedItem>> trait_items,
Visibility vis, std::vector<Attribute> outer_attrs,
std::vector<Attribute> 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)),
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -3993,15 +4003,16 @@ class ExternalStaticItem : public ExternalItem
ExternalStaticItem (Identifier item_name, std::unique_ptr<Type> item_type,
bool is_mut, Visibility vis,
std::vector<Attribute> 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)
Expand Down Expand Up @@ -4237,9 +4248,9 @@ class ExternalFunctionItem : public ExternalItem
std::vector<NamedFunctionParam> function_params, bool has_variadics,
std::vector<Attribute> variadic_outer_attrs, Visibility vis,
std::vector<Attribute> 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)),
Expand All @@ -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)
Expand Down
21 changes: 12 additions & 9 deletions gcc/rust/ast/rust-macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Attribute> ()), LocatedImpl (UNDEF_LOCATION),
outer_attrs (std::vector<Attribute> ()), rule_name (builtin_name),
delim_type (delim_type), rules (std::vector<MacroRule> ()),
associated_transcriber (associated_transcriber),
is_builtin_rule (true), kind (kind)
: VisItem (std::move (vis), std::vector<Attribute> ()),
LocatedImpl (UNDEF_LOCATION), outer_attrs (std::vector<Attribute> ()),
rule_name (builtin_name), delim_type (delim_type),
rules (std::vector<MacroRule> ()),
associated_transcriber (associated_transcriber), is_builtin_rule (true),
kind (kind)
{}

public:
Expand Down Expand Up @@ -704,16 +705,18 @@ class MacroInvocation : public TypeNoBounds,
MacroInvocData invoc_data, std::vector<Attribute> outer_attrs,
location_t locus, bool is_semi_coloned,
std::vector<std::unique_ptr<MacroInvocation>> &&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)
Expand Down
10 changes: 6 additions & 4 deletions gcc/rust/ast/rust-path.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Attribute> outer_attrs;
bool has_opening_scope_resolution;
Expand All @@ -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.
Expand Down Expand Up @@ -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 ());
Expand Down
6 changes: 4 additions & 2 deletions gcc/rust/expand/rust-expand-visitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,8 @@ ExpandVisitor::visit (AST::Trait &trait)

expander.push_context (MacroExpander::ContextType::TRAIT);

std::function<std::unique_ptr<AST::AssociatedItem> (AST::SingleASTNode)> extractor
std::function<std::unique_ptr<AST::AssociatedItem> (AST::SingleASTNode)>
extractor
= [] (AST::SingleASTNode node) { return node.take_assoc_item (); };

expand_macro_children (MacroExpander::ContextType::TRAIT,
Expand Down Expand Up @@ -1214,7 +1215,8 @@ ExpandVisitor::visit (AST::InherentImpl &impl)
expand_where_clause (impl.get_where_clause ());

std::function<std::unique_ptr<AST::AssociatedItem> (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);
Expand Down

0 comments on commit 2ad8c35

Please sign in to comment.