[ParseableInterfaces] Handle swiftdoc files correctly

The previous 'openModuleFiles' interface in SerializedModuleLoaderBase
still assumed that swiftmodule files and swiftdoc files would be found
next to each other, but that's not true anymore with
swiftinterfaces-built-to-modules. Give up on this assumption (and on
the minor optimization of passing down a scratch buffer) and split out
the interface into the customization point
'findModuleFilesInDirectory' and the implementation 'openModuleFiles'.
The latter now takes two full paths: one for the swiftmodule, one for
the swiftdoc.
This commit is contained in:
Jordan Rose
2018-12-17 18:06:37 -08:00
parent 1c3d467fe9
commit 5417ca0aa2
5 changed files with 97 additions and 75 deletions

View File

@@ -51,12 +51,17 @@ protected:
std::unique_ptr<llvm::MemoryBuffer> *moduleDocBuffer,
bool &isFramework);
virtual std::error_code
openModuleFiles(AccessPathElem ModuleID, StringRef DirName,
StringRef ModuleFilename, StringRef ModuleDocFilename,
virtual std::error_code findModuleFilesInDirectory(
AccessPathElem ModuleID, StringRef DirPath, StringRef ModuleFilename,
StringRef ModuleDocFilename,
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer) = 0;
std::error_code
openModuleFiles(AccessPathElem ModuleID,
StringRef ModulePath, StringRef ModuleDocPath,
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer,
llvm::SmallVectorImpl<char> &Scratch);
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer);
/// If the module loader subclass knows that all options have been tried for
/// loading an architecture-specific file out of a swiftmodule bundle, try
@@ -128,12 +133,11 @@ class SerializedModuleLoader : public SerializedModuleLoaderBase {
: SerializedModuleLoaderBase(ctx, tracker, loadMode)
{}
std::error_code
openModuleFiles(AccessPathElem ModuleID, StringRef DirName,
StringRef ModuleFilename, StringRef ModuleDocFilename,
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer,
llvm::SmallVectorImpl<char> &Scratch) override;
std::error_code findModuleFilesInDirectory(
AccessPathElem ModuleID, StringRef DirPath, StringRef ModuleFilename,
StringRef ModuleDocFilename,
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer) override;
bool maybeDiagnoseArchitectureMismatch(SourceLoc sourceLocation,
StringRef moduleName,