[ParseableInterface] Fixes and tests for Graydon's fallback work

This commit is contained in:
Jordan Rose
2018-11-29 11:02:16 -08:00
parent f7200e87bd
commit 7d30f9cb1f
8 changed files with 350 additions and 44 deletions

View File

@@ -20,6 +20,8 @@
namespace swift {
class ModuleFile;
/// Spceifies how to load modules when both a parseable interface and serialized
/// AST are present, or whether to disallow one format or the other altogether.
enum class ModuleLoadingMode {
PreferParseable,
PreferSerialized,
@@ -56,6 +58,18 @@ protected:
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer,
llvm::SmallVectorImpl<char> &Scratch);
/// If the module loader subclass knows that all options have been tried for
/// loading an architecture-specific file out of a swiftmodule bundle, try
/// to list the architectures that \e are present.
///
/// \returns true if an error diagnostic was emitted
virtual bool maybeDiagnoseArchitectureMismatch(SourceLoc sourceLocation,
StringRef moduleName,
StringRef archName,
StringRef directoryPath) {
return false;
}
public:
virtual ~SerializedModuleLoaderBase();
SerializedModuleLoaderBase(const SerializedModuleLoaderBase &) = delete;
@@ -114,6 +128,18 @@ class SerializedModuleLoader : public SerializedModuleLoaderBase {
: SerializedModuleLoaderBase(ctx, tracker, loadMode)
{}
std::error_code
openModuleFiles(StringRef DirName, StringRef ModuleFilename,
StringRef ModuleDocFilename,
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer,
llvm::SmallVectorImpl<char> &Scratch) override;
bool maybeDiagnoseArchitectureMismatch(SourceLoc sourceLocation,
StringRef moduleName,
StringRef archName,
StringRef directoryPath) override;
public:
virtual ~SerializedModuleLoader();