Skip to content

Commit 0b265c7

Browse files
committed
[interop][SwiftToCxx] CollectionIterator in the stdlib overlay should have 'noexcept' annotations
1 parent 8862b1b commit 0b265c7

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/PrintAsClang/_SwiftStdlibCxxOverlay.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,28 @@ template <class Collection, class T> class CollectionIterator {
8181
using Index =
8282
decltype(reinterpret_cast<Collection *>(0x123)->getStartIndex());
8383

84-
SWIFT_INLINE_THUNK CollectionIterator(const Collection &c) : collection(c) {
84+
SWIFT_INLINE_THUNK CollectionIterator(const Collection &c) noexcept(
85+
noexcept(c.getStartIndex()) &&noexcept(c.getEndIndex()))
86+
: collection(c) {
8587
index = collection.getStartIndex();
8688
endIndex = collection.getEndIndex();
8789
// FIXME: Begin read access.
8890
}
8991

90-
SWIFT_INLINE_THUNK ~CollectionIterator() {
92+
SWIFT_INLINE_THUNK ~CollectionIterator() noexcept {
9193
// FIXME: End read access.
9294
}
9395

94-
SWIFT_INLINE_THUNK T operator*() const { return collection[index]; }
95-
SWIFT_INLINE_THUNK void operator++() {
96+
SWIFT_INLINE_THUNK T operator*() const noexcept(noexcept(collection[index])) {
97+
return collection[index];
98+
}
99+
SWIFT_INLINE_THUNK void operator++() noexcept(noexcept(++index)) {
96100
++index;
97101
// FIXME: assert(index <= endIndex); // No need to go past the end.
98102
}
99103

100-
SWIFT_INLINE_THUNK bool operator!=(const IterationEndSentinel &) const {
104+
SWIFT_INLINE_THUNK bool
105+
operator!=(const IterationEndSentinel &) const noexcept {
101106
return index != endIndex;
102107
}
103108

0 commit comments

Comments
 (0)