Skip to content

Commit f672c77

Browse files
Merge pull request #75657 from adrian-prantl/133088201
Expose a ImportPrivateDependencies LangOpt for LLDB (NFC).
2 parents 9319102 + f0902a9 commit f672c77

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
@@ -264,6 +264,10 @@ namespace swift {
264264
/// Enable features useful for running in the debugger.
265265
bool DebuggerSupport = false;
266266

267+
/// Used only by the debugger. When set, the module loader will try to
268+
/// import non-public transitive dependencies.
269+
bool ImportNonPublicDependencies = false;
270+
267271
/// Enable the MemoryBufferSerializedModuleImporter.
268272
/// Only used by lldb-moduleimport-test.
269273
bool EnableMemoryBufferImporter = false;

lib/Serialization/ModuleFile.cpp

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

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

319317
bool ModuleFile::mayHaveDiagnosticsPointingAtBuffer() const {

lib/Serialization/ModuleFileSharedCore.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,7 @@ std::string ModuleFileSharedCore::resolveModuleDefiningFilePath(const StringRef
18011801
ModuleLoadingBehavior
18021802
ModuleFileSharedCore::getTransitiveLoadingBehavior(
18031803
const Dependency &dependency,
1804-
bool debuggerMode,
1804+
bool importNonPublicDependencies,
18051805
bool isPartialModule,
18061806
StringRef packageName,
18071807
bool forTestable) const {
@@ -1817,7 +1817,7 @@ ModuleFileSharedCore::getTransitiveLoadingBehavior(
18171817
if (dependency.isImplementationOnly()) {
18181818
// Implementation-only dependencies are not usually loaded from
18191819
// transitive imports.
1820-
if (debuggerMode || forTestable) {
1820+
if (importNonPublicDependencies || forTestable) {
18211821
// In the debugger, try to load the module if possible.
18221822
// Same in the case of a testable import, try to load the dependency
18231823
// but don't fail if it's missing as this could be source breaking.
@@ -1835,7 +1835,7 @@ ModuleFileSharedCore::getTransitiveLoadingBehavior(
18351835
// on testable imports.
18361836
if (forTestable || !moduleIsResilient) {
18371837
return ModuleLoadingBehavior::Required;
1838-
} else if (debuggerMode) {
1838+
} else if (importNonPublicDependencies) {
18391839
return ModuleLoadingBehavior::Optional;
18401840
} else {
18411841
return ModuleLoadingBehavior::Ignored;
@@ -1849,7 +1849,7 @@ ModuleFileSharedCore::getTransitiveLoadingBehavior(
18491849
forTestable ||
18501850
!moduleIsResilient) {
18511851
return ModuleLoadingBehavior::Required;
1852-
} else if (debuggerMode) {
1852+
} else if (importNonPublicDependencies) {
18531853
return ModuleLoadingBehavior::Optional;
18541854
} else {
18551855
return ModuleLoadingBehavior::Ignored;

lib/Serialization/ModuleFileSharedCore.h

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

643643
/// How should \p dependency be loaded for a transitive import via \c this?
644644
///
645-
/// If \p debuggerMode, more transitive dependencies should try to be loaded
646-
/// as they can be useful in debugging.
645+
/// If \p importNonPublicDependencies, more transitive dependencies
646+
/// should try to be loaded as they can be useful in debugging.
647647
///
648648
/// If \p isPartialModule, transitive dependencies should be loaded as we're
649649
/// in merge-module mode.
@@ -655,12 +655,9 @@ class ModuleFileSharedCore {
655655
/// import. Reports non-public dependencies as required for a testable
656656
/// client so it can access internal details, which in turn can reference
657657
/// those non-public dependencies.
658-
ModuleLoadingBehavior
659-
getTransitiveLoadingBehavior(const Dependency &dependency,
660-
bool debuggerMode,
661-
bool isPartialModule,
662-
StringRef packageName,
663-
bool forTestable) const;
658+
ModuleLoadingBehavior getTransitiveLoadingBehavior(
659+
const Dependency &dependency, bool importNonPublicDependencies,
660+
bool isPartialModule, StringRef packageName, bool forTestable) const;
664661
};
665662

666663
template <typename T, typename RawData>

lib/Serialization/SerializedModuleLoader.cpp

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

0 commit comments

Comments
 (0)