mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[cxx-interop] Synthesize conformances to UnsafeCxxInputIterator
This teaches ClangImporter to synthesize conformances of C++ iterator types to `UnsafeCxxInputIterator` protocol from the `Cxx` module. We consider a C++ type to be an iterator if it defines a subtype (usually a typedef or a using decl) called `iterator_category` that inherits from `std::input_iterator_tag`. rdar://96235368
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
// RUN: %target-swift-ide-test -print-module -module-to-print=CustomSequence -source-filename=x -I %S/Inputs -enable-experimental-cxx-interop -module-cache-path %t | %FileCheck %s
|
||||
|
||||
// CHECK: import Cxx
|
||||
|
||||
// CHECK: struct ConstIterator : UnsafeCxxInputIterator {
|
||||
// CHECK: var pointee: Int32 { get }
|
||||
// CHECK: func successor() -> ConstIterator
|
||||
// CHECK: typealias Pointee = Int32
|
||||
// CHECK: static func == (lhs: ConstIterator, other: ConstIterator) -> Bool
|
||||
// CHECK: }
|
||||
|
||||
// TODO: ConstIteratorOutOfLineEq should also conform to UnsafeCxxInputIterator.
|
||||
// CHECK: struct ConstIteratorOutOfLineEq {
|
||||
// CHECK: var pointee: Int32 { get }
|
||||
// CHECK: func successor() -> ConstIteratorOutOfLineEq
|
||||
// CHECK: }
|
||||
// CHECK: func == (lhs: ConstIteratorOutOfLineEq, rhs: ConstIteratorOutOfLineEq) -> Bool
|
||||
|
||||
// CHECK: struct MinimalIterator : UnsafeCxxInputIterator {
|
||||
// CHECK: var pointee: Int32 { get }
|
||||
// CHECK: func successor() -> MinimalIterator
|
||||
// CHECK: typealias Pointee = Int32
|
||||
// CHECK: static func == (lhs: MinimalIterator, other: MinimalIterator) -> Bool
|
||||
// CHECK: }
|
||||
|
||||
// CHECK: struct ForwardIterator : UnsafeCxxInputIterator {
|
||||
// CHECK: var pointee: Int32 { get }
|
||||
// CHECK: func successor() -> ForwardIterator
|
||||
// CHECK: typealias Pointee = Int32
|
||||
// CHECK: static func == (lhs: ForwardIterator, other: ForwardIterator) -> Bool
|
||||
// CHECK: }
|
||||
|
||||
// CHECK: struct HasCustomIteratorTag : UnsafeCxxInputIterator {
|
||||
// CHECK: var pointee: Int32 { get }
|
||||
// CHECK: func successor() -> HasCustomIteratorTag
|
||||
// CHECK: typealias Pointee = Int32
|
||||
// CHECK: static func == (lhs: HasCustomIteratorTag, other: HasCustomIteratorTag) -> Bool
|
||||
// CHECK: }
|
||||
|
||||
// CHECK: struct HasCustomIteratorTagInline : UnsafeCxxInputIterator {
|
||||
// CHECK: var pointee: Int32 { get }
|
||||
// CHECK: func successor() -> HasCustomIteratorTagInline
|
||||
// CHECK: typealias Pointee = Int32
|
||||
// CHECK: static func == (lhs: HasCustomIteratorTagInline, other: HasCustomIteratorTagInline) -> Bool
|
||||
// CHECK: }
|
||||
|
||||
// CHECK: struct HasTypedefIteratorTag : UnsafeCxxInputIterator {
|
||||
// CHECK: var pointee: Int32 { get }
|
||||
// CHECK: func successor() -> HasTypedefIteratorTag
|
||||
// CHECK: typealias Pointee = Int32
|
||||
// CHECK: static func == (lhs: HasTypedefIteratorTag, other: HasTypedefIteratorTag) -> Bool
|
||||
// CHECK: }
|
||||
|
||||
// CHECK-NOT: struct HasNoIteratorCategory : UnsafeCxxInputIterator
|
||||
// CHECK-NOT: struct HasInvalidIteratorCategory : UnsafeCxxInputIterator
|
||||
// CHECK-NOT: struct HasNoEqualEqual : UnsafeCxxInputIterator
|
||||
// CHECK-NOT: struct HasNoIncrementOperator : UnsafeCxxInputIterator
|
||||
// CHECK-NOT: struct HasNoPreIncrementOperator : UnsafeCxxInputIterator
|
||||
// CHECK-NOT: struct HasNoDereferenceOperator : UnsafeCxxInputIterator
|
||||
Reference in New Issue
Block a user