[ModuleInterface] <rdar://46081260> Fallback behaviour and testing env vars.

This commit is contained in:
Graydon Hoare
2018-11-21 23:44:53 -08:00
committed by Jordan Rose
parent 0ccfe34513
commit f7200e87bd
6 changed files with 103 additions and 33 deletions

View File

@@ -35,8 +35,9 @@ namespace {
// Defined out-of-line so that we can see ~ModuleFile.
SerializedModuleLoaderBase::SerializedModuleLoaderBase(ASTContext &ctx,
DependencyTracker *tracker)
: ModuleLoader(tracker), Ctx(ctx) {}
DependencyTracker *tracker,
ModuleLoadingMode loadMode)
: ModuleLoader(tracker), Ctx(ctx), LoadMode(loadMode) {}
SerializedModuleLoaderBase::~SerializedModuleLoaderBase() = default;
SerializedModuleLoader::~SerializedModuleLoader() = default;
@@ -50,6 +51,12 @@ std::error_code SerializedModuleLoaderBase::openModuleFiles(
(!ModuleBuffer && !ModuleDocBuffer)) &&
"Module and Module Doc buffer must both be initialized or NULL");
// The SerializedModuleLoaderBase implementation here only knows how to do a
// serialized (not parseable) module-load; this is valid behaviour in all
// ModuleLoadingModes except OnlyParseable mode, where it is disabled.
if (LoadMode == ModuleLoadingMode::OnlyParseable)
return std::make_error_code(std::errc::not_supported);
clang::vfs::FileSystem &FS = *Ctx.SourceMgr.getFileSystem();
// Try to open the module file first. If we fail, don't even look for the