Merge pull request #63975 from artemcm/ClangModuleValidatePerSeshhhh

Add Swift compilation flags to enable Clang's validate-per-build-session module behavior
This commit is contained in:
Artem Chikin
2023-03-01 08:40:37 -08:00
committed by GitHub
9 changed files with 104 additions and 0 deletions

View File

@@ -1220,6 +1220,15 @@ static bool ParseTypeCheckerArgs(TypeCheckerOptions &Opts, ArgList &Args,
return HadError;
}
static bool ValidateModulesOnceOptions(const ClangImporterOptions &Opts,
DiagnosticEngine &Diags) {
if (Opts.ValidateModulesOnce && Opts.BuildSessionFilePath.empty()) {
Diags.diagnose(SourceLoc(), diag::error_clang_validate_once_requires_session_file);
return true;
}
return false;
}
static bool ParseClangImporterArgs(ClangImporterOptions &Opts,
ArgList &Args,
DiagnosticEngine &Diags,
@@ -1314,6 +1323,12 @@ static bool ParseClangImporterArgs(ClangImporterOptions &Opts,
Opts.PCHDisableValidation |= Args.hasArg(OPT_pch_disable_validation);
}
Opts.ValidateModulesOnce |= Args.hasArg(OPT_validate_clang_modules_once);
if (auto *A = Args.getLastArg(OPT_clang_build_session_file))
Opts.BuildSessionFilePath = A->getValue();
if (ValidateModulesOnceOptions(Opts, Diags))
return true;
if (Args.hasFlag(options::OPT_warnings_as_errors,
options::OPT_no_warnings_as_errors, false))
Opts.ExtraArgs.push_back("-Werror");