Skip to content
Open
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
2 changes: 2 additions & 0 deletions lldb/include/lldb/Target/Target.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ class TargetProperties : public Properties {

bool GetSwiftAllowExplicitModules() const;

bool GetSwiftAllowImplicitModules() const;

AutoBool GetSwiftPCMValidation() const;

bool GetSwiftUseTasksPlugin() const;
Expand Down
3 changes: 3 additions & 0 deletions lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9421,6 +9421,9 @@ bool SwiftASTContext::GetCompileUnitImportsImpl(
// If EBM is enabled, disable implicit modules during contextual imports.
// fixme nullptr!
bool turn_off_implicit = m_has_explicit_modules;
if (Target::GetGlobalProperties().GetSwiftAllowImplicitModules())
turn_off_implicit = false;

auto reset = llvm::make_scope_exit([&] {
if (turn_off_implicit) {
LOG_PRINTF(GetLog(LLDBLog::Types), "Turning on implicit modules");
Expand Down
13 changes: 13 additions & 0 deletions lldb/source/Target/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4708,6 +4708,19 @@ bool TargetProperties::GetSwiftAllowExplicitModules() const {
return true;
}

bool TargetProperties::GetSwiftAllowImplicitModules() const {
const Property *exp_property =
m_collection_sp->GetPropertyAtIndex(ePropertyExperimental);
OptionValueProperties *exp_values =
exp_property->GetValue()->GetAsProperties();
if (exp_values)
return exp_values
->GetPropertyAtIndexAs<bool>(ePropertySwiftAllowImplicitModules)
.value_or(false);

return false;
}

AutoBool TargetProperties::GetSwiftPCMValidation() const {
const Property *exp_property =
m_collection_sp->GetPropertyAtIndex(ePropertyExperimental);
Expand Down
3 changes: 3 additions & 0 deletions lldb/source/Target/TargetProperties.td
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ let Definition = "target_experimental" in {
def SwiftAllowExplicitModules: Property<"swift-allow-explicit-modules", "Boolean">,
DefaultTrue,
Desc<"Allows explicit module flags to be passed through to ClangImporter.">;
def SwiftAllowImplicitModules: Property<"swift-allow-implicit-modules", "Boolean">,
DefaultFalse,
Desc<"Allows implicit module imports in an explicitly-built target.">;
def SwiftPCMValidation: Property<"swift-pcm-validation", "Enum">,
Global,
DefaultEnumValue<"llvm::to_underlying(AutoBool::Auto)">,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


class TestCase(lldbtest.TestBase):
NO_DEBUG_INFO_TESTCASE = True
@swiftTest
def test_missing_explicit_modules(self):
"""Test missing explicit Swift modules and fallback to implicit modules."""
Expand Down Expand Up @@ -53,3 +54,23 @@ def test_sanity(self):
# CHECK-SANITY: Explicit modules : true
# CHECK-SANITY: Turning off implicit modules
# CHECK-SANITY: Turning on implicit modules

@swiftTest
def test_setting(self):
"""Check the normal behavior."""
self.build()

lldbutil.run_to_source_breakpoint(
self, "Set breakpoint here", lldb.SBFileSpec("main.swift")
)

log = self.getBuildArtifact("types.log")
self.runCmd(f"log enable lldb types -f '{log}'")
self.expect("settings set target.experimental.swift-allow-implicit-modules true")

self.expect("expression c")

self.filecheck(f"platform shell cat {log}", __file__,
'--check-prefix=CHECK-SETTING')
# CHECK-SETTING: Explicit modules : true
# CHECK-SETTING-NOT: Turning {{.*}} implicit modules