Skip to content

[interop][SwiftToCxx] NFC, adopt SWIFT_INLINE_THUNK in the stdlib ove… #61958

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
merged 1 commit into from
Nov 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lib/PrintAsClang/_SwiftStdlibCxxOverlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,24 @@ template <class Collection, class T> class CollectionIterator {
using Index =
decltype(reinterpret_cast<Collection *>(0x123)->getStartIndex());

inline CollectionIterator(const Collection &collection)
SWIFT_INLINE_THUNK CollectionIterator(const Collection &collection)
: collection(collection) {
index = collection.getStartIndex();
endIndex = collection.getEndIndex();
// FIXME: Begin read access.
}

inline ~CollectionIterator() {
SWIFT_INLINE_THUNK ~CollectionIterator() {
// FIXME: End read access.
}

inline T operator*() const { return collection[index]; }
inline void operator++() {
SWIFT_INLINE_THUNK T operator*() const { return collection[index]; }
SWIFT_INLINE_THUNK void operator++() {
++index;
// FIXME: assert(index <= endIndex); // No need to go past the end.
}

inline bool operator!=(const IterationEndSentinel &) const {
SWIFT_INLINE_THUNK bool operator!=(const IterationEndSentinel &) const {
return index != endIndex;
}

Expand All @@ -81,13 +81,13 @@ template <class T> using ArrayIterator = CollectionIterator<Array<T>, T>;

// FIXME: This should apply to more than the Array type.
template <class T>
inline cxxOverlay::ArrayIterator<T> begin(const Array<T> &array
SWIFT_INLINE_THUNK cxxOverlay::ArrayIterator<T> begin(const Array<T> &array
[[clang::lifetimebound]]) {
return cxxOverlay::ArrayIterator<T>(array);
}

template <class T>
inline cxxOverlay::IterationEndSentinel end(const Array<T> &) {
SWIFT_INLINE_THUNK cxxOverlay::IterationEndSentinel end(const Array<T> &) {
return {};
}

Expand Down