Skip to content

Commit ffa7b0e

Browse files
committed
[se-0370] add notes regarding overlapping memory regions
1 parent 559e5ed commit ffa7b0e

File tree

3 files changed

+53
-18
lines changed

3 files changed

+53
-18
lines changed

stdlib/public/core/UnsafeBufferPointer.swift.gyb

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,9 @@ extension Unsafe${Mutable}BufferPointer {
702702
///
703703
/// - Precondition: `self.count` >= `source.count`
704704
///
705+
/// - Note: The memory regions referenced by `source` and this buffer
706+
/// must not overlap.
707+
///
705708
/// - Parameter source: A collection of elements to be used to
706709
/// initialize the buffer's storage.
707710
/// - Returns: The index one past the last element of the buffer initialized
@@ -801,6 +804,9 @@ extension Unsafe${Mutable}BufferPointer {
801804
/// buffer's `startIndex`. If `source` contains as many elements as the buffer
802805
/// can hold, the returned index is equal to the buffer's `endIndex`.
803806
///
807+
/// - Note: The memory regions referenced by `source` and this buffer
808+
/// may overlap.
809+
///
804810
/// - Precondition: `self.count` >= `source.count`
805811
///
806812
/// - Parameter source: A collection of elements to be used to update
@@ -870,9 +876,11 @@ extension Unsafe${Mutable}BufferPointer {
870876
///
871877
/// - Precondition: `self.count` >= `source.count`
872878
///
879+
/// - Note: The memory regions referenced by `source` and this buffer
880+
/// may overlap.
881+
///
873882
/// - Parameter source: A buffer containing the values to copy. The memory
874-
/// region underlying `source` must be initialized. The memory regions
875-
/// referenced by `source` and this buffer may overlap.
883+
/// region underlying `source` must be initialized.
876884
/// - Returns: The index one past the last element of the buffer initialized
877885
/// by this function.
878886
@inlinable
@@ -910,9 +918,11 @@ extension Unsafe${Mutable}BufferPointer {
910918
///
911919
/// - Precondition: `self.count` >= `source.count`
912920
///
921+
/// - Note: The memory regions referenced by `source` and this buffer
922+
/// may overlap.
923+
///
913924
/// - Parameter source: A buffer containing the values to copy. The memory
914-
/// region underlying `source` must be initialized. The memory regions
915-
/// referenced by `source` and this buffer may overlap.
925+
/// region underlying `source` must be initialized.
916926
/// - Returns: The index one past the last element of the buffer initialized
917927
/// by this function.
918928
@inlinable
@@ -937,11 +947,13 @@ extension Unsafe${Mutable}BufferPointer {
937947
/// buffer's `startIndex`. If `source` contains as many elements as the buffer
938948
/// can hold, the returned index is equal to the buffer's `endIndex`.
939949
///
950+
/// - Note: The memory regions referenced by `source` and this buffer
951+
/// must not overlap.
952+
///
940953
/// - Precondition: `self.count` >= `source.count`
941954
///
942955
/// - Parameter source: A buffer containing the values to move.
943-
/// The memory region underlying `source` must be initialized. The memory
944-
/// regions referenced by `source` and this buffer must not overlap.
956+
/// The memory region underlying `source` must be initialized.
945957
/// - Returns: An index one past the index of the last element updated.
946958
@inlinable
947959
@_alwaysEmitIntoClient
@@ -973,11 +985,13 @@ extension Unsafe${Mutable}BufferPointer {
973985
/// buffer's `startIndex`. If `source` contains as many elements as the buffer
974986
/// can hold, the returned index is equal to the buffer's `endIndex`.
975987
///
988+
/// - Note: The memory regions referenced by `source` and this buffer
989+
/// must not overlap.
990+
///
976991
/// - Precondition: `self.count` >= `source.count`
977992
///
978993
/// - Parameter source: A buffer slice containing the values to move.
979-
/// The memory region underlying `source` must be initialized. The
980-
/// memory regions referenced by `source` and this pointer must not overlap.
994+
/// The memory region underlying `source` must be initialized.
981995
/// - Returns: An index one past the index of the last element updated.
982996
@inlinable
983997
@_alwaysEmitIntoClient

stdlib/public/core/UnsafeBufferPointerSlice.swift

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,9 @@ extension Slice {
752752
///
753753
/// - Precondition: `self.count` >= `source.count`
754754
///
755+
/// - Note: The memory regions referenced by `source` and this buffer slice
756+
/// must not overlap.
757+
///
755758
/// - Parameter source: A collection of elements to be used to
756759
/// initialize the buffer slice's storage.
757760
/// - Returns: The index one past the last element of the buffer slice
@@ -818,6 +821,9 @@ extension Slice {
818821
/// `startIndex`. If `source` contains as many elements as the buffer slice
819822
/// can hold, the returned index is the buffer slice's `endIndex`.
820823
///
824+
/// - Note: The memory regions referenced by `source` and this buffer slice
825+
/// may overlap.
826+
///
821827
/// - Precondition: `self.count` >= `source.count`
822828
///
823829
/// - Parameter source: A collection of elements to be used to update
@@ -853,11 +859,13 @@ extension Slice {
853859
/// slice's `startIndex`. If `source` contains as many elements as the slice
854860
/// can hold, the returned index is equal to the slice's `endIndex`.
855861
///
862+
/// - Note: The memory regions referenced by `source` and this buffer slice
863+
/// may overlap.
864+
///
856865
/// - Precondition: `self.count` >= `source.count`
857866
///
858867
/// - Parameter source: A buffer containing the values to copy.
859-
/// The memory region underlying `source` must be initialized. The memory
860-
/// regions referenced by `source` and this buffer may overlap.
868+
/// The memory region underlying `source` must be initialized.
861869
/// - Returns: The index one past the last element of the buffer slice
862870
/// initialized by this function.
863871
@inlinable
@@ -890,11 +898,13 @@ extension Slice {
890898
/// slice's `startIndex`. If `source` contains as many elements as the slice
891899
/// can hold, the returned index is equal to the slice's `endIndex`.
892900
///
901+
/// - Note: The memory regions referenced by `source` and this buffer slice
902+
/// may overlap.
903+
///
893904
/// - Precondition: `self.count` >= `source.count`
894905
///
895906
/// - Parameter source: A buffer slice containing the values to copy.
896-
/// The memory region underlying `source` must be initialized. The memory
897-
/// regions referenced by `source` and this buffer slice may overlap.
907+
/// The memory region underlying `source` must be initialized.
898908
/// - Returns: The index one past the last element of the buffer slice
899909
/// initialized by this function.
900910
@inlinable
@@ -925,11 +935,13 @@ extension Slice {
925935
/// buffer's `startIndex`. If `source` contains as many elements as the buffer
926936
/// slice can hold, the returned index is equal to the slice's `endIndex`.
927937
///
938+
/// - Note: The memory regions referenced by `source` and this buffer slice
939+
/// must not overlap.
940+
///
928941
/// - Precondition: `self.count` >= `source.count`
929942
///
930943
/// - Parameter source: A buffer containing the values to move.
931-
/// The memory region underlying `source` must be initialized. The memory
932-
/// regions referenced by `source` and this buffer slice must not overlap.
944+
/// The memory region underlying `source` must be initialized.
933945
/// - Returns: An index one past the index of the last element updated.
934946
@inlinable
935947
@_alwaysEmitIntoClient
@@ -959,11 +971,13 @@ extension Slice {
959971
/// buffer's `startIndex`. If `source` contains as many elements as the buffer
960972
/// slice can hold, the returned index is equal to the slice's `endIndex`.
961973
///
974+
/// - Note: The memory regions referenced by `source` and this buffer slice
975+
/// must not overlap.
976+
///
962977
/// - Precondition: `self.count` >= `source.count`
963978
///
964979
/// - Parameter source: A buffer slice containing the values to move.
965-
/// The memory region underlying `source` must be initialized. The memory
966-
/// regions referenced by `source` and this buffer slice must not overlap.
980+
/// The memory region underlying `source` must be initialized.
967981
/// - Returns: An index one past the index of the last element updated.
968982
@inlinable
969983
@_alwaysEmitIntoClient

stdlib/public/core/UnsafeRawBufferPointer.swift.gyb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,9 @@ extension Unsafe${Mutable}RawBufferPointer {
804804
/// to the type `C.Element` and is initialized. This method does not change
805805
/// the binding state of the unused portion of the buffer, if any.
806806
///
807+
/// - Note: The memory regions referenced by `source` and this buffer
808+
/// must not overlap.
809+
///
807810
/// - Parameters:
808811
/// - type: The type of element to which this buffer's memory will be bound.
809812
/// - source: A collection of elements to be used to
@@ -889,11 +892,13 @@ extension Unsafe${Mutable}RawBufferPointer {
889892
/// to the type `T` and is initialized. This method does not change
890893
/// the binding state of the unused portion of the buffer, if any.
891894
///
895+
/// - Note: The memory regions referenced by `source` and this buffer
896+
/// may overlap.
897+
///
892898
/// - Parameters:
893899
/// - type: The type of element to which this buffer's memory will be bound.
894900
/// - source: A buffer referencing the values to copy.
895901
/// The memory region underlying `source` must be initialized.
896-
/// The memory regions referenced by `source` and this buffer may overlap.
897902
/// - Returns: A typed buffer referencing the initialized elements.
898903
/// The returned buffer references memory starting at the same
899904
/// base address as this buffer, and its count is equal to `source.count`.
@@ -940,11 +945,13 @@ extension Unsafe${Mutable}RawBufferPointer {
940945
/// to the type `T` and is initialized. This method does not change
941946
/// the binding state of the unused portion of the buffer, if any.
942947
///
948+
/// - Note: The memory regions referenced by `source` and this buffer
949+
/// may overlap.
950+
///
943951
/// - Parameters:
944952
/// - type: The type of element to which this buffer's memory will be bound.
945953
/// - source: A buffer referencing the values to copy.
946954
/// The memory region underlying `source` must be initialized.
947-
/// The memory regions referenced by `source` and this buffer may overlap.
948955
/// - Returns: A typed buffer referencing the initialized elements.
949956
/// The returned buffer references memory starting at the same
950957
/// base address as this buffer, and its count is equal to `source.count`.

0 commit comments

Comments
 (0)