Skip to content

[PackageInterface] Reduce parsing interface file for package-name #72091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions lib/Serialization/SerializedModuleLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,12 +652,21 @@ SerializedModuleBaseName::findInterfacePath(llvm::vfs::FileSystem &fs,
if (!fs.exists(interfacePath))
return std::nullopt;

// If in the same package, try return the package interface path if not
// preferring the interface file.
if (!ctx.LangOpts.AllowNonPackageInterfaceImportFromSamePackage) {
if (auto packageName = getPackageNameFromInterface(interfacePath, fs)) {
if (*packageName == ctx.LangOpts.PackageName)
return getPackageInterfacePathIfInSamePackage(fs, ctx);
// If there is a package name, try look for the package interface.
if (!ctx.LangOpts.PackageName.empty()) {
if (auto maybePackageInterface =
getPackageInterfacePathIfInSamePackage(fs, ctx))
return *maybePackageInterface;

// If package interface is not found, check if we can load the
// public/private interface file by checking:
// * if AllowNonPackageInterfaceImportFromSamePackage is true
// * if the package name is not equal so not in the same package.
if (!ctx.LangOpts.AllowNonPackageInterfaceImportFromSamePackage) {
if (auto packageName = getPackageNameFromInterface(interfacePath, fs)) {
if (*packageName == ctx.LangOpts.PackageName)
return std::nullopt;
}
}
}

Expand Down