@@ -2628,8 +2628,7 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
26282628 return swift_ast_sp;
26292629}
26302630
2631- // / Determine whether this CU was compiled with C++ interop enabled.
2632- bool SwiftASTContext::ShouldEnableCXXInterop (CompileUnit *cu) {
2631+ bool SwiftASTContext::CheckFlagInCU (CompileUnit *cu, const char *flag) {
26332632 AutoBool interop_enabled =
26342633 ModuleList::GetGlobalModuleListProperties ().GetSwiftEnableCxxInterop ();
26352634 switch (interop_enabled) {
@@ -2643,8 +2642,6 @@ bool SwiftASTContext::ShouldEnableCXXInterop(CompileUnit *cu) {
26432642 lldb::ModuleSP module = cu->CalculateSymbolContextModule ();
26442643 if (!module )
26452644 return false ;
2646- // Look for the "-enable-experimental-cxx-interop" compile flag in the
2647- // args of the compile units this module is composed of.
26482645 auto *sym_file = module ->GetSymbolFile ();
26492646 if (!sym_file)
26502647 return false ;
@@ -2653,7 +2650,7 @@ bool SwiftASTContext::ShouldEnableCXXInterop(CompileUnit *cu) {
26532650 if (unit.get () == cu) {
26542651 if (cu->GetLanguage () == eLanguageTypeSwift)
26552652 for (const char *arg : args.GetArgumentArrayRef ())
2656- if (strcmp (arg, " -enable-experimental-cxx-interop " ) == 0 )
2653+ if (strcmp (arg, flag ) == 0 )
26572654 return true ;
26582655 return false ;
26592656 }
@@ -2663,6 +2660,15 @@ bool SwiftASTContext::ShouldEnableCXXInterop(CompileUnit *cu) {
26632660 return false ;
26642661}
26652662
2663+ // / Determine whether this CU was compiled with C++ interop enabled.
2664+ bool SwiftASTContext::ShouldEnableCXXInterop (CompileUnit *cu) {
2665+ return CheckFlagInCU (cu, " -enable-experimental-cxx-interop" );
2666+ }
2667+
2668+ bool SwiftASTContext::ShouldEnableEmbeddedSwift (CompileUnit *cu) {
2669+ return CheckFlagInCU (cu, " -enable-embedded-swift" );
2670+ }
2671+
26662672static bool IsUnitTestExecutable (lldb_private::Module &module ) {
26672673 static ConstString s_xctest (" xctest" );
26682674 static ConstString s_XCTRunner (" XCTRunner" );
@@ -2776,7 +2782,7 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc,
27762782 swift_ast_sp->m_is_scratch_context = true ;
27772783 auto &lang_opts = swift_ast_sp->GetLanguageOptions ();
27782784 lang_opts.EnableCXXInterop = ShouldEnableCXXInterop (cu);
2779- if (target_sp-> IsEmbeddedSwift ( ))
2785+ if (ShouldEnableEmbeddedSwift (cu ))
27802786 lang_opts.enableFeature (swift::Feature::Embedded);
27812787 } else {
27822788 // Typesystem fallback context.
@@ -2792,8 +2798,8 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc,
27922798 swift_ast_sp->m_module = module_sp.get ();
27932799 auto &lang_opts = swift_ast_sp->GetLanguageOptions ();
27942800 lang_opts.EnableAccessControl = false ;
2795- lang_opts.EnableCXXInterop = module_sp-> IsSwiftCxxInteropEnabled ( );
2796- if (module_sp-> IsEmbeddedSwift ( ))
2801+ lang_opts.EnableCXXInterop = ShouldEnableCXXInterop (cu );
2802+ if (ShouldEnableEmbeddedSwift (cu ))
27972803 lang_opts.enableFeature (swift::Feature::Embedded);
27982804 }
27992805 auto defer_log = llvm::make_scope_exit (
0 commit comments