File tree Expand file tree Collapse file tree 4 files changed +53
-1
lines changed Expand file tree Collapse file tree 4 files changed +53
-1
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ namespace swift {
35
35
36
36
class PathRemapper {
37
37
SmallVector<std::pair<std::string, std::string>, 2 > PathMappings;
38
-
38
+ friend class PathObfuscator ;
39
39
public:
40
40
// / Adds a mapping such that any paths starting with `FromPrefix` have that
41
41
// / portion replaced with `ToPrefix`.
@@ -72,6 +72,11 @@ class PathObfuscator {
72
72
std::string recover (StringRef Path) const {
73
73
return recoverer.remapPath (Path);
74
74
}
75
+ void forEachPair (llvm::function_ref<void (StringRef, StringRef)> op) const {
76
+ for (auto pair: obfuscator.PathMappings ) {
77
+ op (pair.first , pair.second );
78
+ }
79
+ }
75
80
};
76
81
77
82
} // end namespace swift
Original file line number Diff line number Diff line change @@ -174,6 +174,11 @@ class CompilerInvocation {
174
174
SearchPathOpts.setImportSearchPaths (Paths);
175
175
}
176
176
177
+ void setSerializedPathObfuscator (const PathObfuscator &obfuscator) {
178
+ FrontendOpts.serializedPathObfuscator = obfuscator;
179
+ SearchPathOpts.DeserializedPathRecoverer = obfuscator;
180
+ }
181
+
177
182
ArrayRef<std::string> getImportSearchPaths () const {
178
183
return SearchPathOpts.getImportSearchPaths ();
179
184
}
Original file line number Diff line number Diff line change @@ -1341,6 +1341,15 @@ void InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface(
1341
1341
genericSubInvocation.getLangOptions ().DisableAvailabilityChecking = true ;
1342
1342
GenericArgs.push_back (" -disable-availability-checking" );
1343
1343
}
1344
+
1345
+ // Pass-down the obfuscators so we can get the serialized search paths properly.
1346
+ genericSubInvocation.setSerializedPathObfuscator (
1347
+ SearchPathOpts.DeserializedPathRecoverer );
1348
+ SearchPathOpts.DeserializedPathRecoverer
1349
+ .forEachPair ([&](StringRef lhs, StringRef rhs) {
1350
+ GenericArgs.push_back (ArgSaver.save (llvm::Twine (" -serialized-path-obfuscate " )
1351
+ + lhs + " =" + rhs).str ());
1352
+ });
1344
1353
}
1345
1354
1346
1355
bool InterfaceSubContextDelegateImpl::extractSwiftInterfaceVersionAndArgs (
Original file line number Diff line number Diff line change
1
+ // REQUIRES: VENDOR=apple
2
+ // RUN: %empty-directory(%t)
3
+ // RUN: %empty-directory(%t/module-cache)
4
+
5
+ // RUN: %target-swift-frontend -emit-module -emit-module-path %t/Foo.swiftmodule -module-name Foo -enable-library-evolution %s -DFoo -I %S/Inputs/imports-clang-modules/ -serialized-path-obfuscate %S=%S_obfuscated
6
+
7
+ // RUN: %target-swift-frontend -typecheck -emit-module-interface-path %t/Bar.swiftinterface -module-name Bar -enable-library-evolution %s -DBar -I %t -serialized-path-obfuscate %S=%S_obfuscated
8
+
9
+ // RUN: %target-swift-frontend -typecheck %s -I %t -serialized-path-obfuscate %S=%S_obfuscated -DFooBar
10
+
11
+ #if Foo
12
+
13
+ import A
14
+ public func fooFunc( ) { }
15
+
16
+ #endif
17
+
18
+ #if Bar
19
+
20
+ import Foo
21
+
22
+ func barFunc( ) {
23
+ fooFunc ( )
24
+ }
25
+
26
+ #endif
27
+
28
+ #if FooBar
29
+
30
+ import Bar
31
+ import A
32
+
33
+ #endif
You can’t perform that action at this time.
0 commit comments