Skip to content

[stdlib] Fix assertion failures in SwiftRuntimeTests (aka unittests/runtime). #4581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions include/swift/Runtime/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -1569,10 +1569,21 @@ struct TargetClassMetadata : public TargetHeapMetadata<Runtime> {
Reserved(0), ClassSize(classSize), ClassAddressPoint(classAddressPoint),
Description(nullptr), IVarDestroyer(ivarDestroyer) {}

TargetClassMetadata(const TargetClassMetadata& other): Description(other.getDescription().get()) {
memcpy(this, &other, sizeof(*this));
setDescription(other.getDescription().get());
}
// Description's copy ctor is deleted so we have to do this the hard way.
TargetClassMetadata(const TargetClassMetadata& other)
: TargetHeapMetadata<Runtime>(other),
SuperClass(other.SuperClass),
CacheData{other.CacheData[0], other.CacheData[1]},
Data(other.Data),
Flags(other.Flags),
InstanceAddressPoint(other.InstanceAddressPoint),
InstanceSize(other.InstanceSize),
InstanceAlignMask(other.InstanceAlignMask),
Reserved(other.Reserved),
ClassSize(other.ClassSize),
ClassAddressPoint(other.ClassAddressPoint),
Description(other.Description.get()),
IVarDestroyer(other.IVarDestroyer) {}

/// The metadata for the superclass. This is null for the root class.
ConstTargetMetadataPointer<Runtime, swift::TargetClassMetadata> SuperClass;
Expand Down
3 changes: 2 additions & 1 deletion unittests/runtime/Metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ TEST(MetadataTest, getGenericMetadata) {

FullMetadata<ClassMetadata> MetadataTest2 = {
{ { nullptr }, { &_TWVBo } },
{ { { MetadataKind::Class } }, nullptr, 0, ClassFlags(), nullptr, 0, 0, 0, 0, 0 }
{ { { MetadataKind::Class } }, nullptr, /*rodata*/ 1,
ClassFlags(), nullptr, 0, 0, 0, 0, 0 }
};

TEST(MetadataTest, getMetatypeMetadata) {
Expand Down