Front-end: add an option to ignore .swiftsourceinfo file for testing purposes

We generate .swiftsourceinfo for stdlib in the build directory because ABI checker
could issue diagnostics to the stdlib source. However, this may also change other
diagnostic tests. Both Brent and Jordan have raised concern about this. After
adding this flag, other diagnostic tests could ignore .swiftsourceinfo files even
though when they are present so our tests will reflect what most users experience
when sources for stdlib are unavailable.
This commit is contained in:
Xi Ge
2019-10-15 10:41:32 -07:00
parent f8209f2865
commit 0a396ab38f
7 changed files with 46 additions and 24 deletions

View File

@@ -104,8 +104,10 @@ Optional<bool> forEachModuleSearchPath(
// Defined out-of-line so that we can see ~ModuleFile.
SerializedModuleLoaderBase::SerializedModuleLoaderBase(
ASTContext &ctx, DependencyTracker *tracker, ModuleLoadingMode loadMode)
: ModuleLoader(tracker), Ctx(ctx), LoadMode(loadMode) {}
ASTContext &ctx, DependencyTracker *tracker, ModuleLoadingMode loadMode,
bool IgnoreSwiftSourceInfoFile)
: ModuleLoader(tracker), Ctx(ctx), LoadMode(loadMode),
IgnoreSwiftSourceInfoFile(IgnoreSwiftSourceInfoFile) {}
SerializedModuleLoaderBase::~SerializedModuleLoaderBase() = default;
SerializedModuleLoader::~SerializedModuleLoader() = default;
@@ -326,11 +328,12 @@ std::error_code SerializedModuleLoaderBase::openModuleFiles(
FS.getBufferForFile(ModulePath);
if (!ModuleOrErr)
return ModuleOrErr.getError();
// Open .swiftsourceinfo file if it's present.
openModuleSourceInfoFileIfPresent(ModuleID, ModulePath,
ModuleSourceInfoFileName,
ModuleSourceInfoBuffer);
if (!IgnoreSwiftSourceInfoFile) {
// Open .swiftsourceinfo file if it's present.
openModuleSourceInfoFileIfPresent(ModuleID, ModulePath,
ModuleSourceInfoFileName,
ModuleSourceInfoBuffer);
}
auto ModuleDocErr =
openModuleDocFile(ModuleID, ModuleDocPath, ModuleDocBuffer);
if (ModuleDocErr)