Skip to content

Move SWIFT_RETURNS_NONNULL and SWIFT_NODISCARD attributes after the function name for exported functions. #61473

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions include/swift/Runtime/Heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ namespace swift {
// Never returns nil. The returned memory is uninitialized.
//
// An "alignment mask" is just the alignment (a power of 2) minus 1.
SWIFT_RETURNS_NONNULL SWIFT_NODISCARD SWIFT_RUNTIME_EXPORT

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include/swift/Runtime/Heap.h

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allevato:shuffle-clang-attributes

void *swift_slowAlloc(size_t bytes, size_t alignMask);
SWIFT_RUNTIME_EXPORT
void *swift_slowAlloc SWIFT_RETURNS_NONNULL SWIFT_NODISCARD(size_t bytes,
size_t alignMask);

// If the caller cannot promise to zero the object during destruction,
// then call these corresponding APIs:
Expand Down
12 changes: 6 additions & 6 deletions include/swift/Runtime/HeapObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ struct OpaqueValue;
///
/// POSSIBILITIES: The argument order is fair game. It may be useful
/// to have a variant which guarantees zero-initialized memory.
SWIFT_RETURNS_NONNULL SWIFT_NODISCARD SWIFT_RUNTIME_EXPORT
HeapObject *swift_allocObject(HeapMetadata const *metadata,
size_t requiredSize,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allevato:shuffle-clang-attributes

size_t requiredAlignmentMask);
SWIFT_RUNTIME_EXPORT
HeapObject *swift_allocObject SWIFT_RETURNS_NONNULL
SWIFT_NODISCARD(HeapMetadata const *metadata, size_t requiredSize,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you okay clang-format?

size_t requiredAlignmentMask);

/// Initializes the object header of a stack allocated object.
///
Expand Down Expand Up @@ -117,8 +117,8 @@ BoxPair swift_makeBoxUnique(OpaqueValue *buffer, Metadata const *type,
size_t alignMask);

/// Returns the address of a heap object representing all empty box types.
SWIFT_RETURNS_NONNULL SWIFT_NODISCARD SWIFT_RUNTIME_EXPORT

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allevato:shuffle-clang-attributes

HeapObject* swift_allocEmptyBox();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allevato:shuffle-clang-attributes

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allevato:shuffle-clang-attributes

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allevato:shuffle-clang-attributes

SWIFT_RUNTIME_EXPORT
HeapObject *swift_allocEmptyBox SWIFT_RETURNS_NONNULL SWIFT_NODISCARD();

/// Atomically increments the retain count of an object.
///
Expand Down
20 changes: 9 additions & 11 deletions include/swift/Runtime/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,21 +313,19 @@ swift_getGenericMetadata(MetadataRequest request,
/// - installing new v-table entries and overrides; and
/// - registering the class with the runtime under ObjC interop.
/// Most of this work can be achieved by calling swift_initClassMetadata.
SWIFT_RETURNS_NONNULL SWIFT_NODISCARD SWIFT_RUNTIME_EXPORT
ClassMetadata *
swift_allocateGenericClassMetadata(const ClassDescriptor *description,
const void *arguments,
const GenericClassMetadataPattern *pattern);
SWIFT_RUNTIME_EXPORT
ClassMetadata *swift_allocateGenericClassMetadata SWIFT_RETURNS_NONNULL
SWIFT_NODISCARD(const ClassDescriptor *description, const void *arguments,
const GenericClassMetadataPattern *pattern);

/// Allocate a generic value metadata object. This is intended to be
/// called by the metadata instantiation function of a generic struct or
/// enum.
SWIFT_RETURNS_NONNULL SWIFT_NODISCARD SWIFT_RUNTIME_EXPORT
ValueMetadata *
swift_allocateGenericValueMetadata(const ValueTypeDescriptor *description,
const void *arguments,
const GenericValueMetadataPattern *pattern,
size_t extraDataSize);
SWIFT_RUNTIME_EXPORT
ValueMetadata *swift_allocateGenericValueMetadata SWIFT_RETURNS_NONNULL
SWIFT_NODISCARD(const ValueTypeDescriptor *description, const void *arguments,
const GenericValueMetadataPattern *pattern,
size_t extraDataSize);

/// Check that the given metadata has the right state.
SWIFT_RUNTIME_EXPORT SWIFT_CC(swift)
Expand Down