[Macros] Resolve macro names using unqualified lookup that ignores expansions

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.
This commit is contained in:
Doug Gregor
2023-04-02 23:15:38 -07:00
parent 706b3e1d62
commit 828de17b00
18 changed files with 116 additions and 38 deletions

View File

@@ -1501,6 +1501,7 @@ bool SerializedASTFile::isSystemModule() const {
}
void SerializedASTFile::lookupValue(DeclName name, NLKind lookupKind,
OptionSet<ModuleLookupFlags> Flags,
SmallVectorImpl<ValueDecl*> &results) const{
File.lookupValue(name, results);
}