Skip to content

Commit bc030d2

Browse files
committed
map builtin macros
1 parent 99f54a5 commit bc030d2

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

gcc/rust/resolve/rust-early-name-resolver-2.0.cc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,26 @@ Early::insert_once (AST::MacroInvocation &invocation, NodeId resolved)
3636
{
3737
// TODO: Should we use `ctx.mark_resolved()`?
3838
auto definition = ctx.mappings.lookup_macro_def (resolved);
39+
rust_assert (definition.has_value ());
40+
41+
// TODO: make sure this is proper
42+
// was copied from old early name resolver
43+
auto &outer_attrs = definition.value ()->get_outer_attrs ();
44+
bool is_builtin
45+
= std::any_of (outer_attrs.begin (), outer_attrs.end (),
46+
[] (AST::Attribute attr) {
47+
return attr.get_path ()
48+
== Values::Attributes::RUSTC_BUILTIN_MACRO;
49+
});
50+
51+
if (is_builtin)
52+
{
53+
auto builtin_kind
54+
= builtin_macro_from_string (definition.value ()->get_rule_name ().as_string ());
55+
rust_assert (builtin_kind);
56+
invocation.map_to_builtin (*builtin_kind);
57+
mark_changed ();
58+
}
3959

4060
if (!ctx.mappings.lookup_macro_invocation (invocation))
4161
ctx.mappings.insert_macro_invocation (invocation, definition.value ());

0 commit comments

Comments
 (0)