Skip to content

Commit 0a81283

Browse files
committed
ClangImporter: Remove custom AvailabilityDomain serialization.
Partially revert swiftlang#80035 now that Clang has its own APIs for querying serialized modules for the decl representing the availability domain with a given name.
1 parent fdc7626 commit 0a81283

File tree

4 files changed

+32
-246
lines changed

4 files changed

+32
-246
lines changed

lib/ClangImporter/ClangImporter.cpp

+20-5
Original file line numberDiff line numberDiff line change
@@ -4114,15 +4114,30 @@ void ClangModuleUnit::lookupObjCMethods(
41144114

41154115
void ClangModuleUnit::lookupAvailabilityDomains(
41164116
Identifier identifier, SmallVectorImpl<AvailabilityDomain> &results) const {
4117-
auto lookupTable = owner.findLookupTable(clangModule);
4118-
if (!lookupTable)
4117+
auto domainName = identifier.str();
4118+
auto &clangASTContext = getClangASTContext();
4119+
4120+
// First, check the Clang AST context for a decl matching this availability
4121+
// domain name. If the domain was defined in the bridging header and that
4122+
// bridging header wasn't precompiled, this is where it will be found.
4123+
auto *domainDecl = clangASTContext.getFeatureAvailDecl(domainName);
4124+
if (!domainDecl) {
4125+
// Next, try external sources (.pcm/.pch).
4126+
auto externalSource = clangASTContext.getExternalSource();
4127+
if (externalSource)
4128+
domainDecl = dyn_cast_or_null<clang::VarDecl>(
4129+
externalSource->getAvailabilityDomainDecl(domainName));
4130+
}
4131+
4132+
if (!domainDecl)
41194133
return;
41204134

4121-
auto varDecl = lookupTable->lookupAvailabilityDomainDecl(identifier.str());
4122-
if (!varDecl)
4135+
// The decl that was found may belong to a different Clang module.
4136+
if (domainDecl->getOwningModule() != getClangModule())
41234137
return;
41244138

4125-
auto featureInfo = getClangASTContext().getFeatureAvailInfo(varDecl);
4139+
// Construct a CustomAvailabilityDomain for the decl that was found.
4140+
auto featureInfo = clangASTContext.getFeatureAvailInfo(domainDecl);
41264141
if (featureInfo.first.empty())
41274142
return;
41284143

0 commit comments

Comments
 (0)