Skip to content

Commit b5626c0

Browse files
authored
Merge pull request #3200 from apple/jan_svoboda/cherry-pick_2
Cherry-pick "[clang][cli] Expose -fno-cxx-modules in cc1"
2 parents 720b9cb + 7545203 commit b5626c0

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,6 @@ defvar render_script = LangOpts<"RenderScript">;
467467
defvar hip = LangOpts<"HIP">;
468468
defvar gnu_mode = LangOpts<"GNUMode">;
469469
defvar asm_preprocessor = LangOpts<"AsmPreprocessor">;
470-
defvar cpp_modules = LangOpts<"CPlusPlusModules">;
471470

472471
defvar std = !strconcat("LangStandard::getLangStandardForKind(", lang_std.KeyPath, ")");
473472

@@ -1362,8 +1361,11 @@ defm cxx_exceptions: BoolFOption<"cxx-exceptions",
13621361
defm async_exceptions: BoolFOption<"async-exceptions",
13631362
LangOpts<"EHAsynch">, DefaultFalse,
13641363
PosFlag<SetTrue, [CC1Option], "Enable EH Asynchronous exceptions">, NegFlag<SetFalse>>;
1365-
def fcxx_modules : Flag <["-"], "fcxx-modules">, Group<f_Group>,
1366-
Flags<[NoXarchOption]>;
1364+
defm cxx_modules : BoolFOption<"cxx-modules",
1365+
LangOpts<"CPlusPlusModules">, Default<cpp20.KeyPath>,
1366+
NegFlag<SetFalse, [CC1Option], "Disable">, PosFlag<SetTrue, [], "Enable">,
1367+
BothFlags<[NoXarchOption], " modules for C++">>,
1368+
ShouldParseIf<cplusplus.KeyPath>;
13671369
def fdebug_pass_arguments : Flag<["-"], "fdebug-pass-arguments">, Group<f_Group>;
13681370
def fdebug_pass_structure : Flag<["-"], "fdebug-pass-structure">, Group<f_Group>;
13691371
def fdepfile_entry : Joined<["-"], "fdepfile-entry=">,
@@ -2181,7 +2183,7 @@ def fmodules_ts : Flag <["-"], "fmodules-ts">, Group<f_Group>,
21812183
Flags<[CC1Option]>, HelpText<"Enable support for the C++ Modules TS">,
21822184
MarshallingInfoFlag<LangOpts<"ModulesTS">>;
21832185
defm modules : BoolFOption<"modules",
2184-
LangOpts<"Modules">, Default<!strconcat(fmodules_ts.KeyPath, "||", cpp_modules.KeyPath)>,
2186+
LangOpts<"Modules">, Default<!strconcat(fmodules_ts.KeyPath, "||", fcxx_modules.KeyPath)>,
21852187
PosFlag<SetTrue, [CC1Option], "Enable the 'modules' language feature">,
21862188
NegFlag<SetFalse>, BothFlags<[NoXarchOption]>>;
21872189
def fmodule_maps : Flag <["-"], "fmodule-maps">, Alias<fimplicit_module_maps>;
@@ -2239,8 +2241,6 @@ def fno_diagnostics_color : Flag<["-"], "fno-diagnostics-color">, Group<f_Group>
22392241
Flags<[CoreOption, NoXarchOption]>;
22402242
def fno_common : Flag<["-"], "fno-common">, Group<f_Group>, Flags<[CC1Option]>,
22412243
HelpText<"Compile common globals like normal definitions">;
2242-
def fno_cxx_modules : Flag <["-"], "fno-cxx-modules">, Group<f_Group>,
2243-
Flags<[NoXarchOption]>;
22442244
defm digraphs : BoolFOption<"digraphs",
22452245
LangOpts<"Digraphs">, Default<std#".hasDigraphs()">,
22462246
PosFlag<SetTrue, [], "Enable alternative token representations '<:', ':>', '<%', '%>', '%:', '%:%:' (default)">,
@@ -5368,7 +5368,7 @@ def fmodules_local_submodule_visibility :
53685368
HelpText<"Enforce name visibility rules across submodules of the same "
53695369
"top-level module.">,
53705370
MarshallingInfoFlag<LangOpts<"ModulesLocalVisibility">>,
5371-
ImpliedByAnyOf<[fmodules_ts.KeyPath, cpp_modules.KeyPath]>;
5371+
ImpliedByAnyOf<[fmodules_ts.KeyPath, fcxx_modules.KeyPath]>;
53725372
def fmodules_codegen :
53735373
Flag<["-"], "fmodules-codegen">,
53745374
HelpText<"Generate code for uses of this module that assumes an explicit "

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3299,8 +3299,6 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
32993299
Opts.HexFloats = Std.hasHexFloats();
33003300
Opts.ImplicitInt = Std.hasImplicitInt();
33013301

3302-
Opts.CPlusPlusModules = Opts.CPlusPlus20;
3303-
33043302
// Set OpenCL Version.
33053303
Opts.OpenCL = Std.isOpenCL();
33063304
if (LangStd == LangStandard::lang_opencl10)

clang/test/Modules/cxx20-disable.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: rm -rf %t && mkdir %t
2+
// RUN: %clang_cc1 -x objective-c++ -std=c++20 -I %t %s -verify=enabled
3+
// RUN: %clang_cc1 -x objective-c++ -std=c++20 -fno-cxx-modules -I %t %s -verify=disabled
4+
5+
// enabled-no-diagnostics
6+
7+
// The spelling of these errors is misleading.
8+
// The important thing is Clang rejected C++20 modules syntax.
9+
export module Foo; // disabled-error{{expected template}}
10+
// disabled-error@-1{{unknown type name 'module'}}

0 commit comments

Comments
 (0)