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
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
2 changes: 2 additions & 0 deletions include/swift/AST/DiagnosticsModuleDiffer.def
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ ERROR(decl_attr_change,none,"%0 changes from %1 to %2", (StringRef, StringRef, S

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))

#ifndef DIAG_NO_UNDEF
# if defined(DIAG)
# undef DIAG
Expand Down
2 changes: 2 additions & 0 deletions include/swift/IDE/DigesterEnums.def
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ KEY(throwing)
KEY(mutating)
KEY(static)
KEY(deprecated)
KEY(implicit)
KEY(typeAttributes)
KEY(declAttributes)
KEY(declKind)
Expand All @@ -109,6 +110,7 @@ KEY(hasDefaultArg)
KEY(conformingProtocols)
KEY(enumRawTypeName)
KEY(genericSig)
KEY(fixedbinaryorder)

KNOWN_TYPE(Optional)
KNOWN_TYPE(ImplicitlyUnwrappedOptional)
Expand Down
7 changes: 6 additions & 1 deletion test/api-digester/Inputs/cake.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,9 @@ public func foo3(_ a: [Int: String]) {}

public extension Int {
public func foo() {}
}
}

@_fixed_layout
public struct fixedLayoutStruct {
public var a = 1
}
14 changes: 14 additions & 0 deletions test/api-digester/Inputs/cake1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,17 @@ public protocol P2 {}
public extension P1 where Self: P2 {
func P1Constraint() {}
}

@_fixed_layout
public struct fixedLayoutStruct {
public var b = 2
public func foo() {}
public var a = 1
}

@_frozen
public enum FrozenKind {
case Unchanged
case Fixed
case Rigid
}
14 changes: 14 additions & 0 deletions test/api-digester/Inputs/cake2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,17 @@ public protocol P2 {}
public extension P1 {
func P1Constraint() {}
}

@_fixed_layout
public struct fixedLayoutStruct {
public var a = 1
public var b = 2
public func foo() {}
}

@_frozen
public enum FrozenKind {
case Unchanged
case Rigid
case Fixed
}
7 changes: 7 additions & 0 deletions test/api-digester/Outputs/Cake-abi.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ cake1: Func P1.P1Constraint() has generic signature change from <τ_0_0 where τ

/* Removed Decls */
cake1: Constructor Somestruct2.init(_:) has been removed
cake1: Constructor fixedLayoutStruct.init(b:a:) has been removed
cake1: Func C4.foo() has been removed

/* Moved Decls */
Expand All @@ -29,3 +30,9 @@ cake1: Func S1.foo3() is now static
cake1: Struct C6 is now with @_fixed_layout
cake1: Var C1.CIIns1 changes from weak to strong
cake1: Var C1.CIIns2 changes from strong to weak

/* 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: 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
1 change: 1 addition & 0 deletions test/api-digester/Outputs/Cake.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ cake1: Func P1.P1Constraint() has generic signature change from <Self where Self

/* Removed Decls */
cake1: Constructor Somestruct2.init(_:) has been removed
cake1: Constructor fixedLayoutStruct.init(b:a:) has been removed
cake1: Func C4.foo() has been removed

/* Moved Decls */
Expand Down
140 changes: 140 additions & 0 deletions test/api-digester/Outputs/cake-abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"usr": "s:4cake2S1VACycfc",
"location": "",
"moduleName": "cake",
"implicit": true,
"children": [
{
"kind": "TypeNominal",
Expand Down Expand Up @@ -125,6 +126,7 @@
"location": "",
"moduleName": "cake",
"genericSig": "<τ_0_0, τ_0_1, τ_0_2>",
"implicit": true,
"children": [
{
"kind": "TypeNominal",
Expand Down Expand Up @@ -241,6 +243,7 @@
"usr": "s:4cake2C1C3InsACSgXwvg",
"location": "",
"moduleName": "cake",
"implicit": true,
"declAttributes": [
"Transparent"
],
Expand Down Expand Up @@ -269,6 +272,7 @@
"usr": "s:4cake2C1C3InsACSgXwvs",
"location": "",
"moduleName": "cake",
"implicit": true,
"declAttributes": [
"Transparent"
],
Expand Down Expand Up @@ -323,6 +327,7 @@
"usr": "s:4cake2C1C4Ins2ACXovg",
"location": "",
"moduleName": "cake",
"implicit": true,
"declAttributes": [
"Transparent"
],
Expand All @@ -343,6 +348,7 @@
"usr": "s:4cake2C1C4Ins2ACXovs",
"location": "",
"moduleName": "cake",
"implicit": true,
"declAttributes": [
"Transparent"
],
Expand Down Expand Up @@ -370,6 +376,7 @@
"usr": "s:4cake2C1CACycfc",
"location": "",
"moduleName": "cake",
"implicit": true,
"children": [
{
"kind": "TypeNominal",
Expand Down Expand Up @@ -462,6 +469,7 @@
"usr": "s:4cake6NumberO3oneyA2CmF",
"location": "",
"moduleName": "cake",
"fixedbinaryorder": 0,
"children": [
{
"kind": "TypeFunc",
Expand Down Expand Up @@ -499,6 +507,7 @@
"usr": "s:4cake6NumberO8RawValuea",
"location": "",
"moduleName": "cake",
"implicit": true,
"children": [
{
"kind": "TypeNominal",
Expand All @@ -516,6 +525,7 @@
"usr": "s:4cake6NumberO9hashValueSivp",
"location": "",
"moduleName": "cake",
"implicit": true,
"children": [
{
"kind": "TypeNominal",
Expand All @@ -531,6 +541,7 @@
"usr": "s:4cake6NumberO9hashValueSivg",
"location": "",
"moduleName": "cake",
"implicit": true,
"children": [
{
"kind": "TypeNominal",
Expand All @@ -550,6 +561,7 @@
"usr": "s:4cake6NumberO4hash4intoys6HasherVz_tF",
"location": "",
"moduleName": "cake",
"implicit": true,
"children": [
{
"kind": "TypeNominal",
Expand All @@ -572,6 +584,7 @@
"usr": "s:4cake6NumberO8rawValueACSgSi_tcfc",
"location": "",
"moduleName": "cake",
"implicit": true,
"declAttributes": [
"Inlinable"
],
Expand Down Expand Up @@ -606,6 +619,7 @@
"usr": "s:4cake6NumberO8rawValueSivp",
"location": "",
"moduleName": "cake",
"implicit": true,
"children": [
{
"kind": "TypeNominal",
Expand All @@ -621,6 +635,7 @@
"usr": "s:4cake6NumberO8rawValueSivg",
"location": "",
"moduleName": "cake",
"implicit": true,
"declAttributes": [
"Inlinable"
],
Expand Down Expand Up @@ -673,6 +688,131 @@
}
]
},
{
"kind": "TypeDecl",
"name": "fixedLayoutStruct",
"printedName": "fixedLayoutStruct",
"declKind": "Struct",
"usr": "s:4cake17fixedLayoutStructV",
"location": "",
"moduleName": "cake",
"declAttributes": [
"FixedLayout"
],
"children": [
{
"kind": "Var",
"name": "a",
"printedName": "a",
"declKind": "Var",
"usr": "s:4cake17fixedLayoutStructV1aSivp",
"location": "",
"moduleName": "cake",
"fixedbinaryorder": 0,
"declAttributes": [
"HasInitialValue"
],
"children": [
{
"kind": "TypeNominal",
"name": "Int",
"printedName": "Int",
"usr": "s:Si"
},
{
"kind": "Getter",
"name": "_",
"printedName": "_()",
"declKind": "Accessor",
"usr": "s:4cake17fixedLayoutStructV1aSivg",
"location": "",
"moduleName": "cake",
"implicit": true,
"declAttributes": [
"Transparent"
],
"children": [
{
"kind": "TypeNominal",
"name": "Int",
"printedName": "Int",
"usr": "s:Si"
}
]
},
{
"kind": "Setter",
"name": "_",
"printedName": "_()",
"declKind": "Accessor",
"usr": "s:4cake17fixedLayoutStructV1aSivs",
"location": "",
"moduleName": "cake",
"implicit": true,
"mutating": true,
"declAttributes": [
"Transparent"
],
"children": [
{
"kind": "TypeNominal",
"name": "Void",
"printedName": "()"
},
{
"kind": "TypeNominal",
"name": "Int",
"printedName": "Int",
"usr": "s:Si"
}
]
}
]
},
{
"kind": "Constructor",
"name": "init",
"printedName": "init(a:)",
"declKind": "Constructor",
"usr": "s:4cake17fixedLayoutStructV1aACSi_tcfc",
"location": "",
"moduleName": "cake",
"implicit": true,
"children": [
{
"kind": "TypeNominal",
"name": "fixedLayoutStruct",
"printedName": "fixedLayoutStruct",
"usr": "s:4cake17fixedLayoutStructV"
},
{
"kind": "TypeNominal",
"name": "Int",
"printedName": "Int",
"usr": "s:Si"
}
]
},
{
"kind": "Constructor",
"name": "init",
"printedName": "init()",
"declKind": "Constructor",
"usr": "s:4cake17fixedLayoutStructVACycfc",
"location": "",
"moduleName": "cake",
"implicit": true,
"children": [
{
"kind": "TypeNominal",
"name": "fixedLayoutStruct",
"printedName": "fixedLayoutStruct",
"usr": "s:4cake17fixedLayoutStructV"
}
]
}
]
},
{
"kind": "TypeDecl",
"name": "Int",
Expand Down
Loading