mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Serialization: Stop serializing cached rename decls.
Rename decls are typically derived from the rename strings attached to a `@available` attributes. It shouldn't be necessary to serialize the cached rename decls since they can be rederived. The only decls that have rename decls and don't have reanme strings are synthesized by ClangImporter and don't get serialized.
This commit is contained in:
@@ -5615,7 +5615,6 @@ DeclDeserializer::readAvailable_DECL_ATTR(SmallVectorImpl<uint64_t> &scratch,
|
||||
DEF_VER_TUPLE_PIECES(Introduced);
|
||||
DEF_VER_TUPLE_PIECES(Deprecated);
|
||||
DEF_VER_TUPLE_PIECES(Obsoleted);
|
||||
DeclID renameDeclID;
|
||||
unsigned rawPlatform, messageSize, renameSize;
|
||||
|
||||
// Decode the record, pulling the version tuple information.
|
||||
@@ -5623,7 +5622,7 @@ DeclDeserializer::readAvailable_DECL_ATTR(SmallVectorImpl<uint64_t> &scratch,
|
||||
scratch, isImplicit, isUnavailable, isDeprecated, isNoAsync,
|
||||
isPackageDescriptionVersionSpecific, isSPI, isForEmbedded,
|
||||
LIST_VER_TUPLE_PIECES(Introduced), LIST_VER_TUPLE_PIECES(Deprecated),
|
||||
LIST_VER_TUPLE_PIECES(Obsoleted), rawPlatform, renameDeclID, messageSize,
|
||||
LIST_VER_TUPLE_PIECES(Obsoleted), rawPlatform, messageSize,
|
||||
renameSize);
|
||||
|
||||
auto maybePlatform = platformFromUnsigned(rawPlatform);
|
||||
@@ -5632,11 +5631,6 @@ DeclDeserializer::readAvailable_DECL_ATTR(SmallVectorImpl<uint64_t> &scratch,
|
||||
|
||||
PlatformKind platform = maybePlatform.value();
|
||||
|
||||
ValueDecl *renameDecl = nullptr;
|
||||
if (renameDeclID) {
|
||||
renameDecl = cast<ValueDecl>(MF.getDecl(renameDeclID));
|
||||
}
|
||||
|
||||
StringRef message = blobData.substr(0, messageSize);
|
||||
blobData = blobData.substr(messageSize);
|
||||
StringRef rename = blobData.substr(0, renameSize);
|
||||
|
||||
@@ -58,7 +58,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
|
||||
/// describe what change you made. The content of this comment isn't important;
|
||||
/// it just ensures a conflict if two people change the module format.
|
||||
/// Don't worry about adhering to the 80-column limit for this line.
|
||||
const uint16_t SWIFTMODULE_VERSION_MINOR = 903; // @main attribute moved
|
||||
const uint16_t SWIFTMODULE_VERSION_MINOR = 904; // @available renamed decl ID removed
|
||||
|
||||
/// A standard hash seed used for all string hashes in a serialized module.
|
||||
///
|
||||
@@ -2352,7 +2352,6 @@ namespace decls_block {
|
||||
BC_AVAIL_TUPLE, // Deprecated
|
||||
BC_AVAIL_TUPLE, // Obsoleted
|
||||
BCVBR<5>, // platform
|
||||
DeclIDField, // rename declaration (if any)
|
||||
BCVBR<5>, // number of bytes in message string
|
||||
BCVBR<5>, // number of bytes in rename string
|
||||
BCBlob // message, followed by rename
|
||||
|
||||
@@ -3038,7 +3038,8 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
|
||||
ENCODE_VER_TUPLE(Deprecated, theAttr->Deprecated)
|
||||
ENCODE_VER_TUPLE(Obsoleted, theAttr->Obsoleted)
|
||||
|
||||
auto renameDeclID = S.addDeclRef(theAttr->RenameDecl);
|
||||
assert(theAttr->Rename.empty() || !theAttr->hasCachedRenamedDecl());
|
||||
|
||||
llvm::SmallString<32> blob;
|
||||
blob.append(theAttr->Message);
|
||||
blob.append(theAttr->Rename);
|
||||
@@ -3056,7 +3057,6 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
|
||||
LIST_VER_TUPLE_PIECES(Deprecated),
|
||||
LIST_VER_TUPLE_PIECES(Obsoleted),
|
||||
static_cast<unsigned>(theAttr->getPlatform()),
|
||||
renameDeclID,
|
||||
theAttr->Message.size(),
|
||||
theAttr->Rename.size(),
|
||||
blob);
|
||||
|
||||
30
test/Serialization/renamed-cycle.swift
Normal file
30
test/Serialization/renamed-cycle.swift
Normal file
@@ -0,0 +1,30 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: split-file %s %t
|
||||
|
||||
// RUN: %target-swift-frontend -emit-module %t/Library.swift -o %t/Library.swiftmodule
|
||||
// RUN: %target-swift-frontend -emit-module %t/Renamed.swift -o %t/Renamed.swiftmodule -I %t/
|
||||
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t/
|
||||
|
||||
//--- Library.swift
|
||||
|
||||
public struct HasRename {
|
||||
public init(new: Int) { }
|
||||
}
|
||||
|
||||
//--- Renamed.swift
|
||||
|
||||
import Library
|
||||
|
||||
extension HasRename {
|
||||
@available(*, renamed: "init(new:)")
|
||||
public init(old: Int) {
|
||||
self.init(new: old)
|
||||
}
|
||||
}
|
||||
|
||||
//--- Client.swift
|
||||
|
||||
import Library
|
||||
import Renamed
|
||||
|
||||
_ = HasRename(old: 0)
|
||||
Reference in New Issue
Block a user