Skip to content

Commit 95ac153

Browse files
authored
[lldb] Add experimental setting for Swift explicit modules (#8291) (#8364)
(cherry-picked from commit 22782c4)
1 parent 9a494d6 commit 95ac153

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

lldb/include/lldb/Target/Target.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ class TargetProperties : public Properties {
188188

189189
bool GetSwiftEnableFullDwarfDebugging() const;
190190

191+
bool GetSwiftAllowExplicitModules() const;
192+
191193
Args GetSwiftPluginServerForPath() const;
192194

193195
bool GetSwiftAutoImportFrameworks() const;

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,9 +1579,10 @@ void SwiftASTContext::AddExtraClangArgs(const std::vector<std::string> &source,
15791579
// module loading.
15801580
// TODO: Incorporate loading explicit module dependencies to
15811581
// speedup dependency resolution.
1582-
if (has_explicit_builds_enabled &&
1583-
match_explicit_build_option(clang_argument))
1584-
continue;
1582+
if (!Target::GetGlobalProperties().GetSwiftAllowExplicitModules())
1583+
if (has_explicit_builds_enabled &&
1584+
match_explicit_build_option(clang_argument))
1585+
continue;
15851586

15861587
// Otherwise add the argument to the list.
15871588
if (!IsMacroDefinition(clang_argument))

lldb/source/Target/Target.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4878,6 +4878,19 @@ bool TargetProperties::GetSwiftEnableFullDwarfDebugging() const {
48784878
return false;
48794879
}
48804880

4881+
bool TargetProperties::GetSwiftAllowExplicitModules() const {
4882+
const Property *exp_property =
4883+
m_collection_sp->GetPropertyAtIndex(ePropertyExperimental);
4884+
OptionValueProperties *exp_values =
4885+
exp_property->GetValue()->GetAsProperties();
4886+
if (exp_values)
4887+
return exp_values
4888+
->GetPropertyAtIndexAs<bool>(ePropertySwiftAllowExplicitModules)
4889+
.value_or(false);
4890+
4891+
return false;
4892+
}
4893+
48814894
Args TargetProperties::GetSwiftPluginServerForPath() const {
48824895
const uint32_t idx = ePropertySwiftPluginServerForPath;
48834896

lldb/source/Target/TargetProperties.td

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ let Definition = "target_experimental" in {
2828
ElementType<"String">,
2929
Desc<"A dictionary of plugin paths as keys and swift-plugin-server binaries as values">;
3030
def SwiftEnableFullDwarfDebugging: Property<"swift-enable-full-dwarf-debugging", "Boolean">,
31-
DefaultFalse,
32-
Desc<"Read full debug information from DWARF for Swift debugging, whenever possible">;
31+
DefaultFalse,
32+
Desc<"Read full debug information from DWARF for Swift debugging, whenever possible">;
33+
def SwiftAllowExplicitModules: Property<"swift-allow-explicit-modules", "Boolean">,
34+
DefaultFalse,
35+
Desc<"Allows explicit module flags to be passed through to ClangImporter.">;
3336
}
3437

3538
let Definition = "target" in {

0 commit comments

Comments
 (0)