mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Add Swift compilation flags to enable Clang's validate-per-build-session module behavior
Add '-validate-clang-modules-once' and '-clang-build-session-file' corresponding to Clang's '-fmodules-validate-once-per-build-session' and '-fbuild-session-file='. Ensure they are propagated to module interface build sub-invocations. We require these to be first-class Swift options in order to ensure they are propagated to both: ClangImporter and implicit interface build compiler sub-invocations. Compiler portion of rdar://105982120
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user