40
40
#include " swift/Basic/Defer.h"
41
41
#include " swift/Basic/Dwarf.h"
42
42
#include " swift/Basic/FileSystem.h"
43
+ #include " swift/Basic/PathRemapper.h"
43
44
#include " swift/Basic/STLExtras.h"
44
45
#include " swift/Basic/Version.h"
45
46
#include " swift/ClangImporter/ClangImporter.h"
48
49
#include " swift/Demangling/ManglingMacros.h"
49
50
#include " swift/Serialization/SerializationOptions.h"
50
51
#include " swift/Strings.h"
51
- #include " clang/AST/DeclTemplate.h"
52
- #include " swift/SymbolGraphGen/SymbolGraphOptions.h"
53
52
#include " swift/SymbolGraphGen/SymbolGraphGen.h"
53
+ #include " swift/SymbolGraphGen/SymbolGraphOptions.h"
54
+ #include " clang/AST/DeclTemplate.h"
54
55
#include " llvm/ADT/SmallSet.h"
55
56
#include " llvm/ADT/SmallString.h"
56
57
#include " llvm/ADT/StringExtras.h"
@@ -511,7 +512,7 @@ static uint8_t getRawOpaqueReadOwnership(swift::OpaqueReadOwnership ownership) {
511
512
CASE (OwnedOrBorrowed)
512
513
#undef CASE
513
514
}
514
- llvm_unreachable (" bad kind" );
515
+ llvm_unreachable (" bad kind" );
515
516
}
516
517
517
518
static uint8_t getRawReadImplKind (swift::ReadImplKind kind) {
@@ -1058,25 +1059,35 @@ void Serializer::writeHeader(const SerializationOptions &options) {
1058
1059
options_block::SDKPathLayout SDKPath (Out);
1059
1060
options_block::XCCLayout XCC (Out);
1060
1061
1061
- SDKPath.emit (ScratchRecord, M->getASTContext ().SearchPathOpts .SDKPath );
1062
+ const auto &PathRemapper = options.DebuggingOptionsPrefixMap ;
1063
+ SDKPath.emit (
1064
+ ScratchRecord,
1065
+ PathRemapper.remapPath (M->getASTContext ().SearchPathOpts .SDKPath ));
1062
1066
auto &Opts = options.ExtraClangOptions ;
1063
- for (auto Arg = Opts.begin (), E = Opts.end (); Arg != E; ++Arg) {
1064
- // FIXME: This is a hack and calls for a better design.
1065
- //
1066
- // Filter out any -ivfsoverlay options that include an
1067
- // unextended-module-overlay.yaml overlay. By convention the Xcode
1068
- // buildsystem uses these while *building* mixed Objective-C and Swift
1069
- // frameworks; but they should never be used to *import* the module
1070
- // defined in the framework.
1071
- if (StringRef (*Arg).startswith (" -ivfsoverlay" )) {
1067
+ for (auto Arg = Opts.begin (), E = Opts.end (); Arg != E; ++Arg) {
1068
+ StringRef arg (*Arg);
1069
+ if (arg.startswith (" -ivfsoverlay" )) {
1070
+ // FIXME: This is a hack and calls for a better design.
1071
+ //
1072
+ // Filter out any -ivfsoverlay options that include an
1073
+ // unextended-module-overlay.yaml overlay. By convention the Xcode
1074
+ // buildsystem uses these while *building* mixed Objective-C and
1075
+ // Swift frameworks; but they should never be used to *import* the
1076
+ // module defined in the framework.
1072
1077
auto Next = std::next (Arg);
1073
1078
if (Next != E &&
1074
1079
StringRef (*Next).endswith (" unextended-module-overlay.yaml" )) {
1075
1080
++Arg;
1076
1081
continue ;
1077
1082
}
1083
+ } else if (arg.startswith (" -fdebug-prefix-map=" )) {
1084
+ // We don't serialize the debug prefix map flags as these
1085
+ // contain absoute paths that are not usable on different
1086
+ // machines. These flags are not necessary to compile the
1087
+ // clang modules again so are safe to remove.
1088
+ continue ;
1078
1089
}
1079
- XCC.emit (ScratchRecord, *Arg );
1090
+ XCC.emit (ScratchRecord, arg );
1080
1091
}
1081
1092
}
1082
1093
}
@@ -1127,14 +1138,16 @@ void Serializer::writeInputBlock(const SerializationOptions &options) {
1127
1138
input_block::ModuleInterfaceLayout ModuleInterface (Out);
1128
1139
1129
1140
if (options.SerializeOptionsForDebugging ) {
1141
+ const auto &PathMapper = options.DebuggingOptionsPrefixMap ;
1130
1142
const SearchPathOptions &searchPathOpts = M->getASTContext ().SearchPathOpts ;
1131
1143
// Put the framework search paths first so that they'll be preferred upon
1132
1144
// deserialization.
1133
1145
for (auto &framepath : searchPathOpts.FrameworkSearchPaths )
1134
1146
SearchPath.emit (ScratchRecord, /* framework=*/ true , framepath.IsSystem ,
1135
- framepath.Path );
1147
+ PathMapper. remapPath ( framepath.Path ) );
1136
1148
for (auto &path : searchPathOpts.ImportSearchPaths )
1137
- SearchPath.emit (ScratchRecord, /* framework=*/ false , /* system=*/ false , path);
1149
+ SearchPath.emit (ScratchRecord, /* framework=*/ false , /* system=*/ false ,
1150
+ PathMapper.remapPath (path));
1138
1151
}
1139
1152
1140
1153
// Note: We're not using StringMap here because we don't need to own the
@@ -1468,7 +1481,7 @@ void Serializer::writeASTBlockEntity(const SILLayout *layout) {
1468
1481
typeRef |= 0x80000000U ;
1469
1482
data.push_back (typeRef);
1470
1483
}
1471
-
1484
+
1472
1485
unsigned abbrCode
1473
1486
= DeclTypeAbbrCodes[SILLayoutLayout::Code];
1474
1487
@@ -1703,7 +1716,7 @@ static bool shouldSerializeMember(Decl *D) {
1703
1716
1704
1717
case DeclKind::OpaqueType:
1705
1718
return true ;
1706
-
1719
+
1707
1720
case DeclKind::EnumElement:
1708
1721
case DeclKind::Protocol:
1709
1722
case DeclKind::Constructor:
@@ -1801,14 +1814,14 @@ void Serializer::writeCrossReference(const DeclContext *DC, uint32_t pathLen) {
1801
1814
if (auto opaque = dyn_cast<OpaqueTypeDecl>(generic)) {
1802
1815
if (!opaque->hasName ()) {
1803
1816
abbrCode = DeclTypeAbbrCodes[XRefOpaqueReturnTypePathPieceLayout::Code];
1804
-
1817
+
1805
1818
XRefOpaqueReturnTypePathPieceLayout::emitRecord (Out, ScratchRecord,
1806
1819
abbrCode,
1807
1820
addDeclBaseNameRef (opaque->getOpaqueReturnTypeIdentifier ()));
1808
1821
break ;
1809
1822
}
1810
1823
}
1811
-
1824
+
1812
1825
assert (generic->hasName ());
1813
1826
1814
1827
abbrCode = DeclTypeAbbrCodes[XRefTypePathPieceLayout::Code];
@@ -1849,7 +1862,7 @@ void Serializer::writeCrossReference(const DeclContext *DC, uint32_t pathLen) {
1849
1862
case DeclContextKind::SubscriptDecl: {
1850
1863
auto SD = cast<SubscriptDecl>(DC);
1851
1864
writeCrossReference (DC->getParent (), pathLen + 1 );
1852
-
1865
+
1853
1866
Type ty = SD->getInterfaceType ()->getCanonicalType ();
1854
1867
1855
1868
abbrCode = DeclTypeAbbrCodes[XRefValuePathPieceLayout::Code];
@@ -1860,7 +1873,7 @@ void Serializer::writeCrossReference(const DeclContext *DC, uint32_t pathLen) {
1860
1873
SD->isStatic ());
1861
1874
break ;
1862
1875
}
1863
-
1876
+
1864
1877
case DeclContextKind::AbstractFunctionDecl: {
1865
1878
if (auto fn = dyn_cast<AccessorDecl>(DC)) {
1866
1879
auto storage = fn->getStorage ();
@@ -1972,7 +1985,7 @@ void Serializer::writeCrossReference(const Decl *D) {
1972
1985
addDeclBaseNameRef (opaque->getOpaqueReturnTypeIdentifier ()));
1973
1986
return ;
1974
1987
}
1975
-
1988
+
1976
1989
if (auto genericParam = dyn_cast<GenericTypeParamDecl>(D)) {
1977
1990
assert (!D->getDeclContext ()->isModuleScopeContext () &&
1978
1991
" Cannot cross reference a generic type decl at module scope." );
@@ -4673,7 +4686,7 @@ class ClangToSwiftBasicWriter :
4673
4686
4674
4687
Serializer &S;
4675
4688
SmallVectorImpl<uint64_t > &Record;
4676
- using TypeWriter =
4689
+ using TypeWriter =
4677
4690
clang::serialization::AbstractTypeWriter<ClangToSwiftBasicWriter>;
4678
4691
TypeWriter Types;
4679
4692
@@ -5477,7 +5490,7 @@ void Serializer::writeAST(ModuleOrSourceFile DC) {
5477
5490
/* isLocal=*/ true );
5478
5491
}
5479
5492
}
5480
-
5493
+
5481
5494
for (auto OTD : opaqueReturnTypeDecls) {
5482
5495
// FIXME: We should delay parsing function bodies so these type decls
5483
5496
// don't even get added to the file.
0 commit comments