Allow loading package interface if in same package.

Add a new flag to enable package interface loading.
Use the last value of package-name in case of dupes.
Rename PrintInterfaceContentMode as InterfaceMode.
Update diagnostics.
Test package interface loading with various scenarios.
Test duplicate package-name.
This commit is contained in:
Ellie Shin
2023-11-08 17:40:40 -08:00
parent aba3b6c24e
commit e5ca8e5c0b
18 changed files with 316 additions and 140 deletions

View File

@@ -67,11 +67,12 @@ struct SerializedModuleBaseName {
/// private interface if there is one, else public). Return an empty optional otherwise.
llvm::Optional<std::string>
findInterfacePath(llvm::vfs::FileSystem &fs, ASTContext &ctx) const;
/// Returns the .package.swiftinterface path if its package-name also applies to
/// the the importing module. Returns an empty optional otherwise.
llvm::Optional<std::string>
getPackageInterfacePathIfInSamePackage(llvm::vfs::FileSystem &fs, ASTContext &ctx) const;
getPackageInterfacePathIfInSamePackage(llvm::vfs::FileSystem &fs,
ASTContext &ctx) const;
};
/// Common functionality shared between \c ImplicitSerializedModuleLoader,
@@ -183,6 +184,7 @@ protected:
/// Load the module file into a buffer and also collect its module name.
static std::unique_ptr<llvm::MemoryBuffer>
getModuleName(ASTContext &Ctx, StringRef modulePath, std::string &Name);
public:
virtual ~SerializedModuleLoaderBase();
SerializedModuleLoaderBase(const SerializedModuleLoaderBase &) = delete;