@@ -2625,8 +2625,7 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
26252625 return swift_ast_sp;
26262626}
26272627
2628- // / Determine whether this CU was compiled with C++ interop enabled.
2629- static bool ShouldEnableCXXInterop (CompileUnit *cu) {
2628+ bool SwiftASTContext::CheckFlagInCU (CompileUnit *cu, const char *flag) {
26302629 AutoBool interop_enabled =
26312630 ModuleList::GetGlobalModuleListProperties ().GetSwiftEnableCxxInterop ();
26322631 switch (interop_enabled) {
@@ -2640,8 +2639,6 @@ static bool ShouldEnableCXXInterop(CompileUnit *cu) {
26402639 lldb::ModuleSP module = cu->CalculateSymbolContextModule ();
26412640 if (!module )
26422641 return false ;
2643- // Look for the "-enable-experimental-cxx-interop" compile flag in the
2644- // args of the compile units this module is composed of.
26452642 auto *sym_file = module ->GetSymbolFile ();
26462643 if (!sym_file)
26472644 return false ;
@@ -2650,7 +2647,7 @@ static bool ShouldEnableCXXInterop(CompileUnit *cu) {
26502647 if (unit.get () == cu) {
26512648 if (cu->GetLanguage () == eLanguageTypeSwift)
26522649 for (const char *arg : args.GetArgumentArrayRef ())
2653- if (strcmp (arg, " -enable-experimental-cxx-interop " ) == 0 )
2650+ if (strcmp (arg, flag ) == 0 )
26542651 return true ;
26552652 return false ;
26562653 }
@@ -2660,6 +2657,15 @@ static bool ShouldEnableCXXInterop(CompileUnit *cu) {
26602657 return false ;
26612658}
26622659
2660+ // / Determine whether this CU was compiled with C++ interop enabled.
2661+ bool SwiftASTContext::ShouldEnableCXXInterop (CompileUnit *cu) {
2662+ return CheckFlagInCU (cu, " -enable-experimental-cxx-interop" );
2663+ }
2664+
2665+ bool SwiftASTContext::ShouldEnableEmbeddedSwift (CompileUnit *cu) {
2666+ return CheckFlagInCU (cu, " -enable-embedded-swift" );
2667+ }
2668+
26632669static bool IsUnitTestExecutable (lldb_private::Module &module ) {
26642670 static ConstString s_xctest (" xctest" );
26652671 static ConstString s_XCTRunner (" XCTRunner" );
@@ -2773,7 +2779,7 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc,
27732779 swift_ast_sp->m_is_scratch_context = true ;
27742780 auto &lang_opts = swift_ast_sp->GetLanguageOptions ();
27752781 lang_opts.EnableCXXInterop = ShouldEnableCXXInterop (cu);
2776- if (target_sp-> IsEmbeddedSwift ( ))
2782+ if (ShouldEnableEmbeddedSwift (cu ))
27772783 lang_opts.enableFeature (swift::Feature::Embedded);
27782784 } else {
27792785 // Typesystem fallback context.
@@ -2789,8 +2795,8 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc,
27892795 swift_ast_sp->m_module = module_sp.get ();
27902796 auto &lang_opts = swift_ast_sp->GetLanguageOptions ();
27912797 lang_opts.EnableAccessControl = false ;
2792- lang_opts.EnableCXXInterop = module_sp-> IsSwiftCxxInteropEnabled ( );
2793- if (module_sp-> IsEmbeddedSwift ( ))
2798+ lang_opts.EnableCXXInterop = ShouldEnableCXXInterop (cu );
2799+ if (ShouldEnableEmbeddedSwift (cu ))
27942800 lang_opts.enableFeature (swift::Feature::Embedded);
27952801 }
27962802 auto defer_log = llvm::make_scope_exit (
0 commit comments