-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Conversation
…re comparing them. This allows us to add comments to the error messages without breaking the tests.
@swift-ci please smoke test |
293190e
to
1a234e5
Compare
@swift-ci please smoke test |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
1d496a3
to
2fc8c55
Compare
@swift-ci please smoke test |
…ut type under ABI mode.
2fc8c55
to
05e1592
Compare
@swift-ci please smoke test |
@swift-ci Please smoke test Linux platform |
No description provided.