-
Notifications
You must be signed in to change notification settings - Fork 341
[lldb] Check if C++ interop and embedded Swift are enabled on CU instead of whole module #10279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2628,8 +2628,7 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module, | |
return swift_ast_sp; | ||
} | ||
|
||
/// Determine whether this CU was compiled with C++ interop enabled. | ||
static bool ShouldEnableCXXInterop(CompileUnit *cu) { | ||
bool SwiftASTContext::CheckFlagInCU(CompileUnit *cu, const char *flag) { | ||
AutoBool interop_enabled = | ||
ModuleList::GetGlobalModuleListProperties().GetSwiftEnableCxxInterop(); | ||
switch (interop_enabled) { | ||
|
@@ -2643,8 +2642,6 @@ static bool ShouldEnableCXXInterop(CompileUnit *cu) { | |
lldb::ModuleSP module = cu->CalculateSymbolContextModule(); | ||
if (!module) | ||
return false; | ||
// Look for the "-enable-experimental-cxx-interop" compile flag in the | ||
// args of the compile units this module is composed of. | ||
auto *sym_file = module->GetSymbolFile(); | ||
if (!sym_file) | ||
return false; | ||
|
@@ -2653,7 +2650,7 @@ static bool ShouldEnableCXXInterop(CompileUnit *cu) { | |
if (unit.get() == cu) { | ||
if (cu->GetLanguage() == eLanguageTypeSwift) | ||
for (const char *arg : args.GetArgumentArrayRef()) | ||
if (strcmp(arg, "-enable-experimental-cxx-interop") == 0) | ||
if (strcmp(arg, flag) == 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we not have a DWARF attribute for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't |
||
return true; | ||
return false; | ||
} | ||
|
@@ -2663,6 +2660,15 @@ static bool ShouldEnableCXXInterop(CompileUnit *cu) { | |
return false; | ||
} | ||
|
||
/// Determine whether this CU was compiled with C++ interop enabled. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this comment should be in the header |
||
bool SwiftASTContext::ShouldEnableCXXInterop(CompileUnit *cu) { | ||
return CheckFlagInCU(cu, "-enable-experimental-cxx-interop"); | ||
} | ||
|
||
bool SwiftASTContext::ShouldEnableEmbeddedSwift(CompileUnit *cu) { | ||
return CheckFlagInCU(cu, "-enable-embedded-swift"); | ||
} | ||
|
||
static bool IsUnitTestExecutable(lldb_private::Module &module) { | ||
static ConstString s_xctest("xctest"); | ||
static ConstString s_XCTRunner("XCTRunner"); | ||
|
@@ -2776,7 +2782,7 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc, | |
swift_ast_sp->m_is_scratch_context = true; | ||
auto &lang_opts = swift_ast_sp->GetLanguageOptions(); | ||
lang_opts.EnableCXXInterop = ShouldEnableCXXInterop(cu); | ||
if (target_sp->IsEmbeddedSwift()) | ||
if (ShouldEnableEmbeddedSwift(cu)) | ||
lang_opts.enableFeature(swift::Feature::Embedded); | ||
} else { | ||
// Typesystem fallback context. | ||
|
@@ -2792,8 +2798,8 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc, | |
swift_ast_sp->m_module = module_sp.get(); | ||
auto &lang_opts = swift_ast_sp->GetLanguageOptions(); | ||
lang_opts.EnableAccessControl = false; | ||
lang_opts.EnableCXXInterop = module_sp->IsSwiftCxxInteropEnabled(); | ||
if (module_sp->IsEmbeddedSwift()) | ||
lang_opts.EnableCXXInterop = ShouldEnableCXXInterop(cu); | ||
if (ShouldEnableEmbeddedSwift(cu)) | ||
lang_opts.enableFeature(swift::Feature::Embedded); | ||
} | ||
auto defer_log = llvm::make_scope_exit( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compiler -> compile