Skip to content

[lldb] Add a setting to allow Swift AST context instantiations #8460

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lldb/include/lldb/Core/ModuleList.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class ModuleListProperties : public Properties {

AutoBool GetSwiftEnableCxxInterop() const;
AutoBool GetSwiftEnableFullDwarfDebugging() const;
bool GetSwiftEnableASTContext() const;
// END SWIFT

FileSpec GetClangModulesCachePath() const;
Expand Down
4 changes: 4 additions & 0 deletions lldb/source/Core/CoreProperties.td
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ let Definition = "modulelist" in {
DefaultEnumValue<"llvm::to_underlying(AutoBool::Auto)">,
EnumValues<"OptionEnumValues(g_enable_full_dwarf_debugging)">,
Desc<"Read full debug information from DWARF for Swift debugging. By default LLDB will use DWARF debug information if it cannot use reflection metadata.">;
def SwiftEnableASTContext: Property<"swift-enable-ast-context", "Boolean">,
Global,
DefaultTrue,
Desc<"Enable instantiating Swift AST contexts.">;
// END SWIFT
def SymLinkPaths: Property<"debug-info-symlink-paths", "FileSpecList">,
Global,
Expand Down
6 changes: 6 additions & 0 deletions lldb/source/Core/ModuleList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ AutoBool ModuleListProperties::GetSwiftEnableFullDwarfDebugging() const {
idx, static_cast<AutoBool>(
g_modulelist_properties[idx].default_uint_value));
}

bool ModuleListProperties::GetSwiftEnableASTContext() const {
const uint32_t idx = ePropertySwiftEnableASTContext;
return GetPropertyAtIndexAs<bool>(
idx, g_modulelist_properties[idx].default_uint_value != 0);
}
// END SWIFT

FileSpec ModuleListProperties::GetLLDBIndexCachePath() const {
Expand Down
16 changes: 16 additions & 0 deletions lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,10 @@ SwiftASTContext::SwiftASTContext(std::string description,
: TypeSystemSwift(), m_typeref_typesystem(&typeref_typesystem),
m_compiler_invocation_ap(new swift::CompilerInvocation()),
m_diagnostic_consumer_ap(new StoringDiagnosticConsumer(*this)) {
assert(
ModuleList::GetGlobalModuleListProperties().GetSwiftEnableASTContext() &&
"Swift AST context instantiation is disabled!");

m_description = description;

// Set the clang modules cache path.
Expand Down Expand Up @@ -1884,6 +1888,10 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
if (!SwiftASTContextSupportsLanguage(language))
return lldb::TypeSystemSP();

if (!ModuleList::GetGlobalModuleListProperties()
.GetSwiftEnableASTContext())
return lldb::TypeSystemSP();

std::string m_description;
{
llvm::raw_string_ostream ss(m_description);
Expand Down Expand Up @@ -2359,6 +2367,10 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
if (!SwiftASTContextSupportsLanguage(language))
return lldb::TypeSystemSP();

if (!ModuleList::GetGlobalModuleListProperties()
.GetSwiftEnableASTContext())
return lldb::TypeSystemSP();

LLDB_SCOPED_TIMER();
std::string m_description = "SwiftASTContextForExpressions";
std::vector<swift::PluginSearchOption> plugin_search_options;
Expand Down Expand Up @@ -2650,6 +2662,10 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
TypeSystemSwiftTypeRefForExpressions &typeref_typesystem) {
LLDB_SCOPED_TIMER();

if (!ModuleList::GetGlobalModuleListProperties()
.GetSwiftEnableASTContext())
return lldb::TypeSystemSP();

CompileUnit *cu = sc.comp_unit;
StringRef swift_module_name = TypeSystemSwiftTypeRef::GetSwiftModuleFor(&sc);
std::string m_description;
Expand Down