@@ -682,7 +682,8 @@ static void diagnoseCxxInteropCompatMode(Arg *verArg, ArgList &Args,
682
682
}
683
683
684
684
void LangOptions::setCxxInteropFromArgs (ArgList &Args,
685
- swift::DiagnosticEngine &Diags) {
685
+ swift::DiagnosticEngine &Diags,
686
+ const FrontendOptions &FrontendOpts) {
686
687
if (Arg *A = Args.getLastArg (options::OPT_cxx_interoperability_mode)) {
687
688
if (Args.hasArg (options::OPT_enable_experimental_cxx_interop)) {
688
689
Diags.diagnose (SourceLoc (), diag::dont_enable_interop_and_compat);
@@ -737,7 +738,12 @@ void LangOptions::setCxxInteropFromArgs(ArgList &Args,
737
738
// version, and is either 4, 5, 6, or 7 (even though only 5.9 and 6.* make
738
739
// any sense). For now, we don't actually care about the version, so we'll
739
740
// just use version 6 (i.e., 'swift-6') to mean that C++ interop mode is on.
740
- if (EnableCXXInterop)
741
+ //
742
+ // FIXME: We always declare the 'Darwin' module as formally having been built
743
+ // without C++Interop, for compatibility with prior versions. Once we are certain
744
+ // that we are only building against modules built with support of
745
+ // '-formal-cxx-interoperability-mode', this hard-coded check should be removed.
746
+ if (EnableCXXInterop && (FrontendOpts.ModuleName .compare (" Darwin" ) != 0 ))
741
747
FormalCxxInteropMode = {6 };
742
748
else
743
749
FormalCxxInteropMode = std::nullopt ;
@@ -1560,7 +1566,7 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
1560
1566
if (const Arg *A = Args.getLastArg (OPT_clang_target_variant))
1561
1567
Opts.ClangTargetVariant = llvm::Triple (A->getValue ());
1562
1568
1563
- Opts.setCxxInteropFromArgs (Args, Diags);
1569
+ Opts.setCxxInteropFromArgs (Args, Diags, FrontendOpts );
1564
1570
if (!Args.hasArg (options::OPT_formal_cxx_interoperability_mode))
1565
1571
ModuleInterfaceOpts.PublicFlags .IgnorableFlags +=
1566
1572
" " + printFormalCxxInteropVersion (Opts);
0 commit comments