@@ -2628,8 +2628,7 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
2628
2628
return swift_ast_sp;
2629
2629
}
2630
2630
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) {
2633
2632
AutoBool interop_enabled =
2634
2633
ModuleList::GetGlobalModuleListProperties ().GetSwiftEnableCxxInterop ();
2635
2634
switch (interop_enabled) {
@@ -2643,8 +2642,6 @@ bool SwiftASTContext::ShouldEnableCXXInterop(CompileUnit *cu) {
2643
2642
lldb::ModuleSP module = cu->CalculateSymbolContextModule ();
2644
2643
if (!module )
2645
2644
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.
2648
2645
auto *sym_file = module ->GetSymbolFile ();
2649
2646
if (!sym_file)
2650
2647
return false ;
@@ -2653,7 +2650,7 @@ bool SwiftASTContext::ShouldEnableCXXInterop(CompileUnit *cu) {
2653
2650
if (unit.get () == cu) {
2654
2651
if (cu->GetLanguage () == eLanguageTypeSwift)
2655
2652
for (const char *arg : args.GetArgumentArrayRef ())
2656
- if (strcmp (arg, " -enable-experimental-cxx-interop " ) == 0 )
2653
+ if (strcmp (arg, flag ) == 0 )
2657
2654
return true ;
2658
2655
return false ;
2659
2656
}
@@ -2663,6 +2660,15 @@ bool SwiftASTContext::ShouldEnableCXXInterop(CompileUnit *cu) {
2663
2660
return false ;
2664
2661
}
2665
2662
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
+
2666
2672
static bool IsUnitTestExecutable (lldb_private::Module &module ) {
2667
2673
static ConstString s_xctest (" xctest" );
2668
2674
static ConstString s_XCTRunner (" XCTRunner" );
@@ -2776,7 +2782,7 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc,
2776
2782
swift_ast_sp->m_is_scratch_context = true ;
2777
2783
auto &lang_opts = swift_ast_sp->GetLanguageOptions ();
2778
2784
lang_opts.EnableCXXInterop = ShouldEnableCXXInterop (cu);
2779
- if (target_sp-> IsEmbeddedSwift ( ))
2785
+ if (ShouldEnableEmbeddedSwift (cu ))
2780
2786
lang_opts.enableFeature (swift::Feature::Embedded);
2781
2787
} else {
2782
2788
// Typesystem fallback context.
@@ -2793,7 +2799,7 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc,
2793
2799
auto &lang_opts = swift_ast_sp->GetLanguageOptions ();
2794
2800
lang_opts.EnableAccessControl = false ;
2795
2801
lang_opts.EnableCXXInterop = ShouldEnableCXXInterop (cu);
2796
- if (module_sp-> IsEmbeddedSwift ( ))
2802
+ if (ShouldEnableEmbeddedSwift (cu ))
2797
2803
lang_opts.enableFeature (swift::Feature::Embedded);
2798
2804
}
2799
2805
auto defer_log = llvm::make_scope_exit (
0 commit comments