Skip to content

Commit

Permalink
fixup: builtin macro checks
Browse files Browse the repository at this point in the history
  • Loading branch information
powerboat9 committed Sep 17, 2024
1 parent d2abade commit 9ab350c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions gcc/rust/resolve/rust-early-name-resolver-2.0.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ Early::insert_once (AST::MacroInvocation &invocation, NodeId resolved)
{
// TODO: Should we use `ctx.mark_resolved()`?
auto definition = ctx.mappings.lookup_macro_def (resolved);
rust_assert (definition.has_value ());

// TODO: make sure this is proper
// was copied from old early name resolver
auto &outer_attrs = definition->get_outer_attrs ();
auto &outer_attrs = definition.value ()->get_outer_attrs ();
bool is_builtin
= std::any_of (outer_attrs.begin (), outer_attrs.end (),
[] (AST::Attribute attr) {
Expand All @@ -48,9 +49,10 @@ Early::insert_once (AST::MacroInvocation &invocation, NodeId resolved)
if (is_builtin)
{
auto builtin_kind
= builtin_macro_from_string (definition->get_rule_name ().as_string ());
= builtin_macro_from_string (definition.value ()->get_rule_name ().as_string ());
rust_assert (builtin_kind);
invocation.map_to_builtin (*builtin_kind);
mark_changed ();
}

if (!ctx.mappings.lookup_macro_invocation (invocation))
Expand Down

0 comments on commit 9ab350c

Please sign in to comment.