Skip to content

Commit fb9bff3

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

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
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/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)