swift-module-digester: diagnose adding variables with fixed binary order.

Removing these variables should be detected as API breakages already.
This commit is contained in:
Xi Ge
2018-09-19 12:20:59 -07:00
parent 971755d5a3
commit b2a159dbf9
5 changed files with 19 additions and 0 deletions

View File

@@ -54,6 +54,8 @@ ERROR(decl_new_attr,none,"%0 is now %1", (StringRef, StringRef))
ERROR(decl_reorder,none,"%0 in a fixed layout type changes position from %1 to %2", (StringRef, unsigned, unsigned))
ERROR(decl_added,none,"%0 is added to a non-resilient type", (StringRef))
#ifndef DIAG_NO_UNDEF
# if defined(DIAG)
# undef DIAG

View File

@@ -51,8 +51,12 @@ public extension P1 {
@_fixed_layout
public struct fixedLayoutStruct {
public var a = 1
public func OKChange() {}
private static let constant = 0
public var b = 2
public func foo() {}
private var c = 3
private lazy var lazy_d = 4
}
@_frozen
@@ -60,4 +64,5 @@ public enum FrozenKind {
case Unchanged
case Rigid
case Fixed
case AddedCase
}

View File

@@ -36,3 +36,6 @@ cake1: EnumElement FrozenKind.Fixed in a fixed layout type changes position from
cake1: EnumElement FrozenKind.Rigid in a fixed layout type changes position from 2 to 1
cake1: Var fixedLayoutStruct.a in a fixed layout type changes position from 1 to 0
cake1: Var fixedLayoutStruct.b in a fixed layout type changes position from 0 to 1
cake2: EnumElement FrozenKind.AddedCase is added to a non-resilient type
cake2: Var fixedLayoutStruct.c is added to a non-resilient type
cake2: Var fixedLayoutStruct.lazy_d.storage is added to a non-resilient type

View File

@@ -47,6 +47,7 @@ static StringRef getCategoryName(uint32_t ID) {
return "/* RawRepresentable Changes */";
case LocalDiagID::generic_sig_change:
return "/* Generic Signature Changes */";
case LocalDiagID::decl_added:
case LocalDiagID::decl_reorder:
return "/* Fixed-layout Type Changes */";
default:

View File

@@ -762,6 +762,14 @@ public:
case NodeMatchReason::Added:
assert(!Left);
Right->annotate(NodeAnnotation::Added);
if (Ctx.checkingABI()) {
if (auto *VAD = dyn_cast<SDKNodeDeclVar>(Right)) {
if (VAD->hasFixedBinaryOrder()) {
Ctx.getDiags().diagnose(SourceLoc(), diag::decl_added,
VAD->getScreenInfo());
}
}
}
return;
case NodeMatchReason::Removed:
assert(!Right);