[Macros] Resolve macro names using unqualified lookup that ignores expansions #64854
[Macros] Resolve macro names using unqualified lookup that ignores ex…
828de17b
rxwei
approved these changes
on 2023-04-03
DougGregor
deleted the top-level-macro-lookup branch 2 years ago
Assignees
No one assigned
The macro name resolution in the source lookup cache was only looking at macros in the current module, meaning that any names introduced by peer or declaration macros declared in one module but used in another would not be found by name lookup.
Switch the source lookup cache over to using the same
forEachPotentialResolvedMacro
API that is used by lookup within types, so we have consistent name-lookup-level macro resolution in both places.... except that would be horribly cyclic, of course, so introduce name lookup flags to ignore top-level declarations introduced by macro expansions. This is semantically correct because macro expansions are not allowed to introduce new macros anyway, because that would have been a terrible idea.
Fixes rdar://107321469. Peer and declaration macros at module scope should work a whole lot better now.