@@ -2625,8 +2625,7 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
2625
2625
return swift_ast_sp;
2626
2626
}
2627
2627
2628
- // / Determine whether this CU was compiled with C++ interop enabled.
2629
- bool SwiftASTContext::ShouldEnableCXXInterop (CompileUnit *cu) {
2628
+ bool SwiftASTContext::CheckFlagInCU (CompileUnit *cu, const char *flag) {
2630
2629
AutoBool interop_enabled =
2631
2630
ModuleList::GetGlobalModuleListProperties ().GetSwiftEnableCxxInterop ();
2632
2631
switch (interop_enabled) {
@@ -2640,8 +2639,6 @@ bool SwiftASTContext::ShouldEnableCXXInterop(CompileUnit *cu) {
2640
2639
lldb::ModuleSP module = cu->CalculateSymbolContextModule ();
2641
2640
if (!module )
2642
2641
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.
2645
2642
auto *sym_file = module ->GetSymbolFile ();
2646
2643
if (!sym_file)
2647
2644
return false ;
@@ -2650,7 +2647,7 @@ bool SwiftASTContext::ShouldEnableCXXInterop(CompileUnit *cu) {
2650
2647
if (unit.get () == cu) {
2651
2648
if (cu->GetLanguage () == eLanguageTypeSwift)
2652
2649
for (const char *arg : args.GetArgumentArrayRef ())
2653
- if (strcmp (arg, " -enable-experimental-cxx-interop " ) == 0 )
2650
+ if (strcmp (arg, flag ) == 0 )
2654
2651
return true ;
2655
2652
return false ;
2656
2653
}
@@ -2660,6 +2657,15 @@ bool SwiftASTContext::ShouldEnableCXXInterop(CompileUnit *cu) {
2660
2657
return false ;
2661
2658
}
2662
2659
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
+
2663
2669
static bool IsUnitTestExecutable (lldb_private::Module &module ) {
2664
2670
static ConstString s_xctest (" xctest" );
2665
2671
static ConstString s_XCTRunner (" XCTRunner" );
@@ -2773,7 +2779,7 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc,
2773
2779
swift_ast_sp->m_is_scratch_context = true ;
2774
2780
auto &lang_opts = swift_ast_sp->GetLanguageOptions ();
2775
2781
lang_opts.EnableCXXInterop = ShouldEnableCXXInterop (cu);
2776
- if (target_sp-> IsEmbeddedSwift ( ))
2782
+ if (ShouldEnableEmbeddedSwift (cu ))
2777
2783
lang_opts.enableFeature (swift::Feature::Embedded);
2778
2784
} else {
2779
2785
// Typesystem fallback context.
@@ -2790,7 +2796,7 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc,
2790
2796
auto &lang_opts = swift_ast_sp->GetLanguageOptions ();
2791
2797
lang_opts.EnableAccessControl = false ;
2792
2798
lang_opts.EnableCXXInterop = ShouldEnableCXXInterop (cu);
2793
- if (module_sp-> IsEmbeddedSwift ( ))
2799
+ if (ShouldEnableEmbeddedSwift (cu ))
2794
2800
lang_opts.enableFeature (swift::Feature::Embedded);
2795
2801
}
2796
2802
auto defer_log = llvm::make_scope_exit (
0 commit comments