Skip to content

swift-module-digester: diagnose reordering and adding decls in fixed layout types. #19373

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 3 commits into from
Sep 19, 2018

Conversation

nkcsgexi
Copy link
Contributor

No description provided.

…re comparing them.

This allows us to add comments to the error messages without breaking the tests.
@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add me as a reviewer on swift-module-digester PRs in the future.

/* Fixed-layout Type changes */
cake1: EnumElement FrozenKind.Fixed in a fixed layout type changes position from 1 to 2
cake1: EnumElement FrozenKind.Rigid in a fixed layout type changes position from 2 to 1
cake1: Func fixedLayoutStruct.foo() in a fixed layout type changes position from 0 to 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only re-ordering stored instance properties is bad.

Re-ordering anything else (computed properties, static properties, methods, etc) is OK.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is VAD->hasStorage() && !VAD->isStatic() sufficient to check this? frozen enums don't need this constraint, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is sufficient. For enums, the equivalent is to just check all EnumElementDecls.

@@ -423,6 +429,11 @@ bool SDKNodeDeclType::isConformingTo(KnownProtocolKind Kind) const {
}
}

bool SDKNodeDeclType::hasFixedLayout() const {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will still return false for non-resilient modules, where all declarations are fixed-layout/frozen. Instead, use NominalTypeDecl::isResilient().

@@ -674,6 +674,23 @@ static bool isOwnershipEquivalent(ReferenceOwnership Left,
return false;
}

static void detectReordering(SDKNodeDecl *L, SDKNodeDecl *R, SDKContext &Ctx) {
if (L->isImplicit())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not correct to ignore implicit declarations. For example, I think the underlying storage of a lazy property is implicit. Please test re-ordering lazy properties.

assert(!Left);
Right->annotate(NodeAnnotation::Added);
if (Ctx.checkingABI()) {
// Adding members to a fixed layout type is ABI-breaking.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing members too (even if they're not public).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have a separate PR for adding/removing nodes.

@nkcsgexi nkcsgexi force-pushed the diagnose-reorder branch 2 times, most recently from 1d496a3 to 2fc8c55 Compare September 19, 2018 00:12
@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@nkcsgexi
Copy link
Contributor Author

@swift-ci Please smoke test Linux platform

@nkcsgexi nkcsgexi merged commit 555ee21 into swiftlang:master Sep 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants