@@ -1202,6 +1202,48 @@ void Module::ReportWarningToolchainMismatch(
12021202 }
12031203 }
12041204}
1205+
1206+ bool Module::IsSwiftCxxInteropEnabled () {
1207+ switch (m_is_swift_cxx_interop_enabled) {
1208+ case eLazyBoolYes:
1209+ return true ;
1210+ case eLazyBoolNo:
1211+ return false ;
1212+ case eLazyBoolCalculate:
1213+ break ;
1214+ }
1215+ EnableSwiftCxxInterop interop_enabled =
1216+ Target::GetGlobalProperties ().GetEnableSwiftCxxInterop ();
1217+ switch (interop_enabled) {
1218+ case eEnableSwiftCxxInterop:
1219+ m_is_swift_cxx_interop_enabled = eLazyBoolYes;
1220+ break ;
1221+ case eDisableSwiftCxxInterop:
1222+ m_is_swift_cxx_interop_enabled = eLazyBoolNo;
1223+ break ;
1224+ case eAutoDetectSwiftCxxInterop: {
1225+ // Look for the "-enable-experimental-cxx-interop" compile flag in the args
1226+ // of the compile units this module is composed of.
1227+ auto *sym_file = GetSymbolFile ();
1228+ if (sym_file) {
1229+ auto options = sym_file->GetCompileOptions ();
1230+ for (auto &[_, args] : options) {
1231+ for (const char *arg : args.GetArgumentArrayRef ()) {
1232+ if (strcmp (arg, " -enable-experimental-cxx-interop" ) == 0 ) {
1233+ m_is_swift_cxx_interop_enabled = eLazyBoolYes;
1234+ break ;
1235+ }
1236+ }
1237+ if (m_is_swift_cxx_interop_enabled == eLazyBoolYes)
1238+ break ;
1239+ }
1240+ }
1241+ if (m_is_swift_cxx_interop_enabled == eLazyBoolCalculate)
1242+ m_is_swift_cxx_interop_enabled = eLazyBoolNo;
1243+ }
1244+ }
1245+ return m_is_swift_cxx_interop_enabled == eLazyBoolYes;
1246+ }
12051247#endif
12061248
12071249void Module::ReportErrorIfModifyDetected (const char *format, ...) {
0 commit comments