-
Notifications
You must be signed in to change notification settings - Fork 342
[Clang][driver][cc1] Fix handling of of C++20 modules in ObjectiveC++ #6015
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
Conversation
Default<!strconcat("(", fmodules_ts.KeyPath, "||", fcxx_modules.KeyPath, | ||
") && !LangOpts->ObjC")>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's either enhance the TableGen infrastructure so that this doesn't have to be string concatenation, or parse/generate these flags manually in CompilerInvocation.cpp
.
I just updated this patch to better handle the overall situation. Defaults to no LSV and no C++20 modules. Adds -cc1 overrides to change this, but rejects invalid combinations. I didn't switch off of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with my suggestions resolved.
@@ -1516,8 +1517,8 @@ defm async_exceptions: BoolFOption<"async-exceptions", | |||
LangOpts<"EHAsynch">, DefaultFalse, | |||
PosFlag<SetTrue, [CC1Option], "Enable EH Asynchronous exceptions">, NegFlag<SetFalse>>; | |||
defm cxx_modules : BoolFOption<"cxx-modules", | |||
LangOpts<"CPlusPlusModules">, Default<cpp20.KeyPath>, | |||
NegFlag<SetFalse, [CC1Option], "Disable">, PosFlag<SetTrue, [], "Enable">, | |||
LangOpts<"CPlusPlusModules">, Default<!strconcat(cpp20.KeyPath, " && !", objc.KeyPath)>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave a FIXME behind to teach TableGen to handle this in a more structured way.
Default<!strconcat("(", fmodules_ts.KeyPath, "||", fcxx_modules.KeyPath, | ||
") && !", objc.KeyPath)>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, it's no longer necessary to have !ObjC
here since it's covered by the defm cxx_modules
logic.
if ((Opts.ModulesTS || Opts.CPlusPlusModules) && !Opts.ModulesLocalVisibility) | ||
Diags.Report(diag::err_modules_no_lsv) << (Opts.CPlusPlusModules ? 0 : 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests that cover all the cases.
Unfortunately, ObjectiveC++ does not currently support C++20 modules. This is because ObjectiveC requires Local Submodule Visibility in practice, which is not compatible with C++20 modules. Given our options are to either drop ObjectiveC compatibility, or C++20 modules compatibility, we currently choose to disable C++20 modules to allow using other C++20 features in ObjectiveC++20 mode. This patch also allows enabling LSV and C++20 modules in ObjectiveC++20 mode for the few cases it does work. It adds errors for incompatible configurations.
@swift-ci test |
Previous failures looked unrelated. @swift-ci test |
Currently there is no way to have Objective-C++20 without LSV. This is a problem because some existing ObjectiveC code is not compatible with LSV. This patch provides a way to disable LSV even in C++20 mode and makes it the default for ObjC++20.
I intend to cherry-pick this into stable/20220421 and stable/20221013.