Skip to content

Cherry-pick "[clang][cli] Expose -fno-cxx-modules in cc1" #3200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ defvar render_script = LangOpts<"RenderScript">;
defvar hip = LangOpts<"HIP">;
defvar gnu_mode = LangOpts<"GNUMode">;
defvar asm_preprocessor = LangOpts<"AsmPreprocessor">;
defvar cpp_modules = LangOpts<"CPlusPlusModules">;

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

Expand Down Expand Up @@ -1362,8 +1361,11 @@ defm cxx_exceptions: BoolFOption<"cxx-exceptions",
defm async_exceptions: BoolFOption<"async-exceptions",
LangOpts<"EHAsynch">, DefaultFalse,
PosFlag<SetTrue, [CC1Option], "Enable EH Asynchronous exceptions">, NegFlag<SetFalse>>;
def fcxx_modules : Flag <["-"], "fcxx-modules">, Group<f_Group>,
Flags<[NoXarchOption]>;
defm cxx_modules : BoolFOption<"cxx-modules",
LangOpts<"CPlusPlusModules">, Default<cpp20.KeyPath>,
NegFlag<SetFalse, [CC1Option], "Disable">, PosFlag<SetTrue, [], "Enable">,
BothFlags<[NoXarchOption], " modules for C++">>,
ShouldParseIf<cplusplus.KeyPath>;
def fdebug_pass_arguments : Flag<["-"], "fdebug-pass-arguments">, Group<f_Group>;
def fdebug_pass_structure : Flag<["-"], "fdebug-pass-structure">, Group<f_Group>;
def fdepfile_entry : Joined<["-"], "fdepfile-entry=">,
Expand Down Expand Up @@ -2181,7 +2183,7 @@ def fmodules_ts : Flag <["-"], "fmodules-ts">, Group<f_Group>,
Flags<[CC1Option]>, HelpText<"Enable support for the C++ Modules TS">,
MarshallingInfoFlag<LangOpts<"ModulesTS">>;
defm modules : BoolFOption<"modules",
LangOpts<"Modules">, Default<!strconcat(fmodules_ts.KeyPath, "||", cpp_modules.KeyPath)>,
LangOpts<"Modules">, Default<!strconcat(fmodules_ts.KeyPath, "||", fcxx_modules.KeyPath)>,
PosFlag<SetTrue, [CC1Option], "Enable the 'modules' language feature">,
NegFlag<SetFalse>, BothFlags<[NoXarchOption]>>;
def fmodule_maps : Flag <["-"], "fmodule-maps">, Alias<fimplicit_module_maps>;
Expand Down Expand Up @@ -2239,8 +2241,6 @@ def fno_diagnostics_color : Flag<["-"], "fno-diagnostics-color">, Group<f_Group>
Flags<[CoreOption, NoXarchOption]>;
def fno_common : Flag<["-"], "fno-common">, Group<f_Group>, Flags<[CC1Option]>,
HelpText<"Compile common globals like normal definitions">;
def fno_cxx_modules : Flag <["-"], "fno-cxx-modules">, Group<f_Group>,
Flags<[NoXarchOption]>;
defm digraphs : BoolFOption<"digraphs",
LangOpts<"Digraphs">, Default<std#".hasDigraphs()">,
PosFlag<SetTrue, [], "Enable alternative token representations '<:', ':>', '<%', '%>', '%:', '%:%:' (default)">,
Expand Down Expand Up @@ -5368,7 +5368,7 @@ def fmodules_local_submodule_visibility :
HelpText<"Enforce name visibility rules across submodules of the same "
"top-level module.">,
MarshallingInfoFlag<LangOpts<"ModulesLocalVisibility">>,
ImpliedByAnyOf<[fmodules_ts.KeyPath, cpp_modules.KeyPath]>;
ImpliedByAnyOf<[fmodules_ts.KeyPath, fcxx_modules.KeyPath]>;
def fmodules_codegen :
Flag<["-"], "fmodules-codegen">,
HelpText<"Generate code for uses of this module that assumes an explicit "
Expand Down
2 changes: 0 additions & 2 deletions clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3299,8 +3299,6 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
Opts.HexFloats = Std.hasHexFloats();
Opts.ImplicitInt = Std.hasImplicitInt();

Opts.CPlusPlusModules = Opts.CPlusPlus20;

// Set OpenCL Version.
Opts.OpenCL = Std.isOpenCL();
if (LangStd == LangStandard::lang_opencl10)
Expand Down
10 changes: 10 additions & 0 deletions clang/test/Modules/cxx20-disable.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// RUN: rm -rf %t && mkdir %t
// RUN: %clang_cc1 -x objective-c++ -std=c++20 -I %t %s -verify=enabled
// RUN: %clang_cc1 -x objective-c++ -std=c++20 -fno-cxx-modules -I %t %s -verify=disabled

// enabled-no-diagnostics

// The spelling of these errors is misleading.
// The important thing is Clang rejected C++20 modules syntax.
export module Foo; // disabled-error{{expected template}}
// disabled-error@-1{{unknown type name 'module'}}