Skip to content

Commit 497b266

Browse files
Merge pull request #75658 from adrian-prantl/133088201-6.0
Expose a ImportPrivateDependencies LangOpt for LLDB (NFC).
2 parents f6c311c + a1ba715 commit 497b266

File tree

5 files changed

+17
-18
lines changed

5 files changed

+17
-18
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ namespace swift {
267267
/// Enable features useful for running in the debugger.
268268
bool DebuggerSupport = false;
269269

270+
/// Used only by the debugger. When set, the module loader will try to
271+
/// import non-public transitive dependencies.
272+
bool ImportNonPublicDependencies = false;
273+
270274
/// Enable the MemoryBufferSerializedModuleImporter.
271275
/// Only used by lldb-moduleimport-test.
272276
bool EnableMemoryBufferImporter = false;

lib/Serialization/ModuleFile.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,9 @@ ModuleFile::getTransitiveLoadingBehavior(const Dependency &dependency,
308308
// as a partial module.
309309
auto isPartialModule = mod->isMainModule();
310310

311-
return Core->getTransitiveLoadingBehavior(dependency.Core,
312-
ctx.LangOpts.DebuggerSupport,
313-
isPartialModule,
314-
ctx.LangOpts.PackageName,
315-
forTestable);
311+
return Core->getTransitiveLoadingBehavior(
312+
dependency.Core, ctx.LangOpts.ImportNonPublicDependencies,
313+
isPartialModule, ctx.LangOpts.PackageName, forTestable);
316314
}
317315

318316
bool ModuleFile::mayHaveDiagnosticsPointingAtBuffer() const {

lib/Serialization/ModuleFileSharedCore.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,7 +1789,7 @@ std::string ModuleFileSharedCore::resolveModuleDefiningFilePath(const StringRef
17891789
ModuleLoadingBehavior
17901790
ModuleFileSharedCore::getTransitiveLoadingBehavior(
17911791
const Dependency &dependency,
1792-
bool debuggerMode,
1792+
bool importNonPublicDependencies,
17931793
bool isPartialModule,
17941794
StringRef packageName,
17951795
bool forTestable) const {
@@ -1805,7 +1805,7 @@ ModuleFileSharedCore::getTransitiveLoadingBehavior(
18051805
if (dependency.isImplementationOnly()) {
18061806
// Implementation-only dependencies are not usually loaded from
18071807
// transitive imports.
1808-
if (debuggerMode || forTestable) {
1808+
if (importNonPublicDependencies || forTestable) {
18091809
// In the debugger, try to load the module if possible.
18101810
// Same in the case of a testable import, try to load the dependency
18111811
// but don't fail if it's missing as this could be source breaking.
@@ -1823,7 +1823,7 @@ ModuleFileSharedCore::getTransitiveLoadingBehavior(
18231823
// on testable imports.
18241824
if (forTestable || !moduleIsResilient) {
18251825
return ModuleLoadingBehavior::Required;
1826-
} else if (debuggerMode) {
1826+
} else if (importNonPublicDependencies) {
18271827
return ModuleLoadingBehavior::Optional;
18281828
} else {
18291829
return ModuleLoadingBehavior::Ignored;
@@ -1837,7 +1837,7 @@ ModuleFileSharedCore::getTransitiveLoadingBehavior(
18371837
forTestable ||
18381838
!moduleIsResilient) {
18391839
return ModuleLoadingBehavior::Required;
1840-
} else if (debuggerMode) {
1840+
} else if (importNonPublicDependencies) {
18411841
return ModuleLoadingBehavior::Optional;
18421842
} else {
18431843
return ModuleLoadingBehavior::Ignored;

lib/Serialization/ModuleFileSharedCore.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,8 @@ class ModuleFileSharedCore {
624624

625625
/// How should \p dependency be loaded for a transitive import via \c this?
626626
///
627-
/// If \p debuggerMode, more transitive dependencies should try to be loaded
628-
/// as they can be useful in debugging.
627+
/// If \p importNonPublicDependencies, more transitive dependencies
628+
/// should try to be loaded as they can be useful in debugging.
629629
///
630630
/// If \p isPartialModule, transitive dependencies should be loaded as we're
631631
/// in merge-module mode.
@@ -637,12 +637,9 @@ class ModuleFileSharedCore {
637637
/// import. Reports non-public dependencies as required for a testable
638638
/// client so it can access internal details, which in turn can reference
639639
/// those non-public dependencies.
640-
ModuleLoadingBehavior
641-
getTransitiveLoadingBehavior(const Dependency &dependency,
642-
bool debuggerMode,
643-
bool isPartialModule,
644-
StringRef packageName,
645-
bool forTestable) const;
640+
ModuleLoadingBehavior getTransitiveLoadingBehavior(
641+
const Dependency &dependency, bool importNonPublicDependencies,
642+
bool isPartialModule, StringRef packageName, bool forTestable) const;
646643
};
647644

648645
template <typename T, typename RawData>

lib/Serialization/SerializedModuleLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ SerializedModuleLoaderBase::getImportsOfModule(
411411
ModuleLoadingBehavior dependencyTransitiveBehavior =
412412
loadedModuleFile.getTransitiveLoadingBehavior(
413413
dependency,
414-
/*debuggerMode*/ false,
414+
/*importPrivateDependencies*/ false,
415415
/*isPartialModule*/ false, packageName, isTestableImport);
416416
if (dependencyTransitiveBehavior > transitiveBehavior)
417417
continue;

0 commit comments

Comments
 (0)