Skip to content

Commit 49f37ab

Browse files
committed
Add SearchPathRemapper to SearchPathOptions
This is intended to be used from LLDB to apply the remappings specified in target.source-map to remap any serialized Swiftmodule search paths that were prefixed using `-prefix-serialized-debugging-options`.
1 parent ce6b4b3 commit 49f37ab

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

include/swift/AST/SearchPathOptions.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define SWIFT_AST_SEARCHPATHOPTIONS_H
1515

1616
#include "swift/Basic/ArrayRefView.h"
17+
#include "swift/Basic/PathRemapper.h"
1718
#include "llvm/ADT/Hashing.h"
1819

1920
#include <string>
@@ -97,6 +98,11 @@ class SearchPathOptions {
9798

9899
/// A file containing modules we should perform batch scanning.
99100
std::string BatchScanInputFilePath;
101+
102+
/// Debug path mappings to apply to serialized search paths. These are
103+
/// specified in LLDB from the target.source-map entries.
104+
PathRemapper SearchPathRemapper;
105+
100106
private:
101107
static StringRef
102108
pathStringFromFrameworkSearchPath(const FrameworkSearchPath &next) {

lib/Serialization/ModuleFile.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,11 @@ Status ModuleFile::associateWithFileContext(FileUnit *file, SourceLoc diagLoc,
158158
return error(status);
159159
}
160160

161-
for (const auto &searchPath : Core->SearchPaths)
162-
ctx.addSearchPath(searchPath.Path, searchPath.IsFramework,
163-
searchPath.IsSystem);
161+
for (const auto &searchPath : Core->SearchPaths) {
162+
ctx.addSearchPath(
163+
ctx.SearchPathOpts.SearchPathRemapper.remapPath(searchPath.Path),
164+
searchPath.IsFramework, searchPath.IsSystem);
165+
}
164166

165167
auto clangImporter = static_cast<ClangImporter *>(ctx.getClangModuleLoader());
166168

0 commit comments

Comments
 (0)