-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[InterfaceGen] Print private/internal properties #19127
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
harlanhaskins
merged 5 commits into
swiftlang:master
from
harlanhaskins:private-property
Sep 6, 2018
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ba5564a
[Interface] Print private/internal properties
00d8908
Address review comments
aaecce9
Disable accessor generation for nameless vars
31b9b4b
Test to ensure interface files preserve type layout
5cecee0
Ignore attribute differences on Linux
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
test/ModuleInterface/private-stored-member-type-layout.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// RUN: %empty-directory(%t) | ||
|
||
// Check that importing this module creates the right types | ||
|
||
// RUN: %target-swift-frontend -emit-interface-path %t/private-stored-members.swiftinterface -module-name PrivateStoredMembers -emit-module -o %t/PrivateStoredMembers.swiftmodule %S/private-stored-members.swift | ||
// RUN: %target-swift-frontend -emit-ir %s -I %t 2>&1 -DSHOULD_IMPORT | %FileCheck %s --check-prefix CHECK-EXEC --check-prefix CHECK | ||
|
||
// Check that the types are also correct when importing a module created from an interface | ||
|
||
// RUN: %target-swift-frontend -emit-module -o %t/PrivateStoredMembers.swiftmodule -module-name PrivateStoredMembers %t/private-stored-members.swiftinterface -disable-objc-attr-requires-foundation-module | ||
// RUN: %target-swift-frontend -emit-ir %s -I %t 2>&1 -DSHOULD_IMPORT | %FileCheck %s --check-prefix CHECK-EXEC --check-prefix CHECK | ||
|
||
// Check the types generated when the source file is the primary file, and ensure they're the same layout. | ||
|
||
// RUN: %target-swift-frontend -emit-ir %S/private-stored-members.swift %s 2>&1 -module-name main | %FileCheck %s --check-prefix CHECK-MAIN --check-prefix CHECK-EXEC | ||
|
||
// These two appear out-of-order between run lines | ||
|
||
// CHECK-DAG: [[MYCLASS:%T20PrivateStoredMembers7MyClassC]] = type opaque | ||
// CHECK-DAG: [[MYSTRUCT:%T20PrivateStoredMembers8MyStructV]] = type <{ %Ts5Int64V, %TSb, [7 x i8], %Ts5Int64V, %TSb, [7 x i8], %Ts5Int64V, %TSb, [7 x i8], %Ts5Int64V }> | ||
|
||
// CHECK-MAIN-DAG: [[MYCLASS:%T4main7MyClassC]] = type <{ %swift.refcounted, %Ts5Int64V, %TSb, [7 x i8], %Ts5Int64V, %TSb, [7 x i8], %Ts5Int64V, %TSb, [7 x i8], %Ts5Int64V }> | ||
// CHECK-MAIN-DAG: [[MYSTRUCT:%T4main8MyStructV]] = type <{ %Ts5Int64V, %TSb, [7 x i8], %Ts5Int64V, %TSb, [7 x i8], %Ts5Int64V, %TSb, [7 x i8], %Ts5Int64V }> | ||
|
||
#if SHOULD_IMPORT | ||
import PrivateStoredMembers | ||
#endif | ||
|
||
// CHECK-EXEC: swiftcc void @"$S{{[^ ]+}}8makeUseryyF"() #0 { | ||
public func makeUser() { | ||
let ptr = UnsafeMutablePointer<MyStruct>.allocate(capacity: 1) | ||
// CHECK-EXEC: %.publicEndVar = getelementptr inbounds [[MYSTRUCT]], [[MYSTRUCT]]* %{{[0-9]+}}, i32 0, i32 [[PUBLIC_END_VAR_IDX:9]] | ||
// CHECK-EXEC: %.publicEndVar._value = getelementptr inbounds %Ts5Int64V, %Ts5Int64V* %.publicEndVar, i32 0, i32 0 | ||
// CHECK-EXEC: store i64 4, i64* %.publicEndVar._value | ||
ptr.pointee.publicEndVar = 4 | ||
|
||
// CHECK-EXEC: %.publicEndVar1 = getelementptr inbounds [[MYSTRUCT]], [[MYSTRUCT]]* %{{[0-9]+}}, i32 0, i32 [[PUBLIC_END_VAR_IDX]] | ||
// CHECK-EXEC: %.publicEndVar1._value = getelementptr inbounds %Ts5Int64V, %Ts5Int64V* %.publicEndVar1, i32 0, i32 0 | ||
// CHECK-EXEC: [[PUBLIC_END_VAR_LOAD:%[0-9]+]] = load i64, i64* %.publicEndVar1._value, align 8 | ||
|
||
// CHECK-EXEC: %.publicVar = getelementptr inbounds [[MYSTRUCT]], [[MYSTRUCT]]* %{{[0-9]+}}, i32 0, i32 0 | ||
// CHECK-EXEC: %.publicVar._value = getelementptr inbounds %Ts5Int64V, %Ts5Int64V* %.publicVar, i32 0, i32 0 | ||
// CHECK-EXEC: store i64 [[PUBLIC_END_VAR_LOAD]], i64* %.publicVar._value, align 8 | ||
ptr.pointee.publicVar = ptr.pointee.publicEndVar | ||
ptr.deallocate() | ||
|
||
// CHECK-EXEC: %[[MYCLASS_INIT:[0-9]+]] = call swiftcc [[MYCLASS]]* @"$S{{[^ ]+}}7MyClassCACycfC"(%swift.type* swiftself %{{[0-9]+}}) | ||
let myClass = MyClass() | ||
|
||
// These are uninteresting as they just call into the standard getter and setter. | ||
myClass.publicEndVar = 4 | ||
myClass.publicVar = myClass.publicEndVar | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// RUN: %empty-directory(%t) | ||
|
||
// RUN: %target-swift-frontend -emit-interface-path %t.swiftinterface -emit-module -o /dev/null %s | ||
// RUN: %FileCheck %s < %t.swiftinterface | ||
|
||
// RUN: %target-swift-frontend -emit-interface-path %t-resilient.swiftinterface -enable-resilience -emit-module -o /dev/null %s | ||
// RUN: %FileCheck %s --check-prefix RESILIENT < %t-resilient.swiftinterface | ||
|
||
// RUN: %target-swift-frontend -emit-module -o %t/Test.swiftmodule %t.swiftinterface -disable-objc-attr-requires-foundation-module | ||
// FIXME(rdar44144435): %target-swift-frontend -emit-module -o /dev/null -merge-modules %t/Test.swiftmodule -emit-interface-path - | %FileCheck %s | ||
|
||
// RUN: %target-swift-frontend -emit-module -o %t/TestResilient.swiftmodule -enable-resilience %t.swiftinterface -disable-objc-attr-requires-foundation-module | ||
// FIXME(rdar44144435): %target-swift-frontend -emit-module -o /dev/null -merge-modules %t/Test.swiftmodule -enable-resilience -emit-interface-path - | %FileCheck %s | ||
|
||
|
||
// CHECK: struct MyStruct {{{$}} | ||
// RESILIENT: struct MyStruct {{{$}} | ||
public struct MyStruct { | ||
// CHECK-NEXT: var publicVar: Int64{{$}} | ||
// RESILIENT-NEXT: var publicVar: Int64{{$}} | ||
public var publicVar: Int64 | ||
|
||
// CHECK-NEXT: let publicLet: Bool{{$}} | ||
// RESILIENT-NEXT: let publicLet: Bool{{$}} | ||
public let publicLet: Bool | ||
|
||
// CHECK-NEXT: internal var _: Int64{{$}} | ||
// RESILIENT-NOT: internal var _: Int64{{$}} | ||
var internalVar: Int64 | ||
|
||
// CHECK-NEXT: internal let _: Bool{{$}} | ||
// RESILIENT-NOT: internal let _: Bool{{$}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm curious whether this is printed as (This doesn't have to block this PR.) |
||
let internalLet: Bool | ||
|
||
// CHECK-NEXT: private var _: Int64{{$}} | ||
// RESILIENT-NOT: private var _: Int64{{$}} | ||
private var privateVar: Int64 | ||
|
||
// CHECK-NEXT: private let _: Bool{{$}} | ||
// RESILIENT-NOT: private let _: Bool{{$}} | ||
private let privateLet: Bool | ||
|
||
// CHECK-NOT: private var | ||
// RESILIENT-NOT: private var | ||
private var computedPrivateVar: Int64 { | ||
return 0 | ||
} | ||
|
||
// CHECK-NOT: private static var | ||
// RESILIENT-NOT: private static var | ||
private static var staticPrivateVar: Int64 = 0 | ||
|
||
// CHECK-NEXT: var publicEndVar: Int64{{$}} | ||
// RESILIENT-NEXT: var publicEndVar: Int64{{$}} | ||
public var publicEndVar: Int64 = 0 | ||
|
||
// CHECK: }{{$}} | ||
// RESILIENT: }{{$}} | ||
} | ||
|
||
// CHECK: class MyClass {{{$}} | ||
// RESILIENT: class MyClass {{{$}} | ||
public class MyClass { | ||
// CHECK-NEXT: var publicVar: Int64{{$}} | ||
// RESILIENT-NEXT: var publicVar: Int64{{$}} | ||
public var publicVar: Int64 = 0 | ||
|
||
// CHECK-NEXT: let publicLet: Bool{{$}} | ||
// RESILIENT-NEXT: let publicLet: Bool{{$}} | ||
public let publicLet: Bool = true | ||
|
||
// CHECK-NEXT: internal var _: Int64{{$}} | ||
// RESILIENT-NOT: internal var _: Int64{{$}} | ||
var internalVar: Int64 = 0 | ||
|
||
// CHECK-NEXT: internal let _: Bool{{$}} | ||
// RESILIENT-NOT: internal let _: Bool{{$}} | ||
let internalLet: Bool = true | ||
|
||
// CHECK-NEXT: private var _: Int64{{$}} | ||
// RESILIENT-NOT: private var _: Int64{{$}} | ||
private var privateVar: Int64 = 0 | ||
|
||
// CHECK-NEXT: private let _: Bool{{$}} | ||
// RESILIENT-NOT: private let _: Bool{{$}} | ||
private let privateLet: Bool = true | ||
|
||
// CHECK-NOT: private var | ||
// RESILIENT-NOT: private var | ||
private var computedPrivateVar: Int64 { | ||
return 0 | ||
} | ||
|
||
// CHECK-NOT: private static var | ||
// RESILIENT-NOT: private static var | ||
private static var staticPrivateVar: Int64 = 0 | ||
|
||
// CHECK-NEXT: var publicEndVar: Int64{{$}} | ||
// RESILIENT-NEXT: var publicEndVar: Int64{{$}} | ||
public var publicEndVar: Int64 = 0 | ||
|
||
public init() {} | ||
|
||
// CHECK: }{{$}} | ||
// RESILIENT: }{{$}} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think it's worth CHECKing that they do.
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.
Discussed offline, since it ends up just reaching into the table at pretty opaque offsets (in this case, 21, 20, and 11) it's not a super interesting check...