forked from OSchip/llvm-project
[NFC] Judge if we have std c++ modules in RenderModulesOptions
This patch moves the judgement if the std c++ modules feature is enabled into the RenderModulesOptions function. It simplify the code a little bit further more. It also helps further patches.
This commit is contained in:
parent
95935d3f6d
commit
f461e8045e
|
@ -3660,10 +3660,19 @@ bool Driver::getDefaultModuleCachePath(SmallVectorImpl<char> &Result) {
|
|||
return false;
|
||||
}
|
||||
|
||||
static void RenderModulesOptions(Compilation &C, const Driver &D,
|
||||
static bool RenderModulesOptions(Compilation &C, const Driver &D,
|
||||
const ArgList &Args, const InputInfo &Input,
|
||||
const InputInfo &Output,
|
||||
ArgStringList &CmdArgs, bool &HaveModules) {
|
||||
const InputInfo &Output, const Arg *Std,
|
||||
ArgStringList &CmdArgs) {
|
||||
bool IsCXX = types::isCXX(Input.getType());
|
||||
// FIXME: Find a better way to determine whether the input has standard c++
|
||||
// modules support by default.
|
||||
bool HaveStdCXXModules =
|
||||
IsCXX && Std &&
|
||||
(Std->containsValue("c++2a") || Std->containsValue("c++20") ||
|
||||
Std->containsValue("c++2b") || Std->containsValue("c++latest"));
|
||||
bool HaveModules = HaveStdCXXModules;
|
||||
|
||||
// -fmodules enables the use of precompiled modules (off by default).
|
||||
// Users can pass -fno-cxx-modules to turn off modules support for
|
||||
// C++/Objective-C++ programs.
|
||||
|
@ -3671,7 +3680,7 @@ static void RenderModulesOptions(Compilation &C, const Driver &D,
|
|||
if (Args.hasFlag(options::OPT_fmodules, options::OPT_fno_modules, false)) {
|
||||
bool AllowedInCXX = Args.hasFlag(options::OPT_fcxx_modules,
|
||||
options::OPT_fno_cxx_modules, true);
|
||||
if (AllowedInCXX || !types::isCXX(Input.getType())) {
|
||||
if (AllowedInCXX || !IsCXX) {
|
||||
CmdArgs.push_back("-fmodules");
|
||||
HaveClangModules = true;
|
||||
}
|
||||
|
@ -3842,6 +3851,8 @@ static void RenderModulesOptions(Compilation &C, const Driver &D,
|
|||
Args.ClaimAllArgs(options::OPT_fno_modules_validate_system_headers);
|
||||
Args.ClaimAllArgs(options::OPT_fmodules_disable_diagnostic_validation);
|
||||
}
|
||||
|
||||
return HaveModules;
|
||||
}
|
||||
|
||||
static void RenderCharacterOptions(const ArgList &Args, const llvm::Triple &T,
|
||||
|
@ -6688,12 +6699,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
|
||||
Args.AddLastArg(CmdArgs, options::OPT_finline_max_stacksize_EQ);
|
||||
|
||||
// FIXME: Find a better way to determine whether the language has modules
|
||||
// support by default, or just assume that all languages do.
|
||||
bool HaveModules =
|
||||
Std && (Std->containsValue("c++2a") || Std->containsValue("c++20") ||
|
||||
Std->containsValue("c++2b") || Std->containsValue("c++latest"));
|
||||
RenderModulesOptions(C, D, Args, Input, Output, CmdArgs, HaveModules);
|
||||
RenderModulesOptions(C, D, Args, Input, Output, Std, CmdArgs);
|
||||
|
||||
if (Args.hasFlag(options::OPT_fpch_validate_input_files_content,
|
||||
options::OPT_fno_pch_validate_input_files_content, false))
|
||||
|
|
Loading…
Reference in New Issue