Skip to content

Commit 2e4df58

Browse files
committed
[Runtime] Fix up incorrect attribute ordering
Clang no longer allows attributes before `extern "C"`. See https://reviews.llvm.org/D126061. There was *another* issue where GNU and standard attributes couldn't be mixed, but that's been fixed by https://reviews.llvm.org/D137979. Move the `SWIFT_RUNTIME_EXPORT` to the beginning so that `extern "C"` is the first attribute. Also remove an unnecessary include, which would prevent the compiler itself being built on the released clang-15 (since the GNU/standard attribute mixing fix isn't in clang-15). Resolves #61468.
1 parent 0b05a1e commit 2e4df58

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

include/swift/Runtime/Heap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace swift {
2929
// Never returns nil. The returned memory is uninitialized.
3030
//
3131
// An "alignment mask" is just the alignment (a power of 2) minus 1.
32-
SWIFT_RETURNS_NONNULL SWIFT_NODISCARD SWIFT_RUNTIME_EXPORT
32+
SWIFT_RUNTIME_EXPORT SWIFT_RETURNS_NONNULL SWIFT_NODISCARD
3333
void *swift_slowAlloc(size_t bytes, size_t alignMask);
3434

3535
// If the caller cannot promise to zero the object during destruction,

include/swift/Runtime/HeapObject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct OpaqueValue;
6161
///
6262
/// POSSIBILITIES: The argument order is fair game. It may be useful
6363
/// to have a variant which guarantees zero-initialized memory.
64-
SWIFT_RETURNS_NONNULL SWIFT_NODISCARD SWIFT_RUNTIME_EXPORT
64+
SWIFT_RUNTIME_EXPORT SWIFT_RETURNS_NONNULL SWIFT_NODISCARD
6565
HeapObject *swift_allocObject(HeapMetadata const *metadata,
6666
size_t requiredSize,
6767
size_t requiredAlignmentMask);
@@ -117,7 +117,7 @@ BoxPair swift_makeBoxUnique(OpaqueValue *buffer, Metadata const *type,
117117
size_t alignMask);
118118

119119
/// Returns the address of a heap object representing all empty box types.
120-
SWIFT_RETURNS_NONNULL SWIFT_NODISCARD SWIFT_RUNTIME_EXPORT
120+
SWIFT_RUNTIME_EXPORT SWIFT_RETURNS_NONNULL SWIFT_NODISCARD
121121
HeapObject* swift_allocEmptyBox();
122122

123123
/// Atomically increments the retain count of an object.

include/swift/Runtime/Metadata.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ swift_getGenericMetadata(MetadataRequest request,
313313
/// - installing new v-table entries and overrides; and
314314
/// - registering the class with the runtime under ObjC interop.
315315
/// Most of this work can be achieved by calling swift_initClassMetadata.
316-
SWIFT_RETURNS_NONNULL SWIFT_NODISCARD SWIFT_RUNTIME_EXPORT
316+
SWIFT_RUNTIME_EXPORT SWIFT_RETURNS_NONNULL SWIFT_NODISCARD
317317
ClassMetadata *
318318
swift_allocateGenericClassMetadata(const ClassDescriptor *description,
319319
const void *arguments,
@@ -322,7 +322,7 @@ swift_allocateGenericClassMetadata(const ClassDescriptor *description,
322322
/// Allocate a generic value metadata object. This is intended to be
323323
/// called by the metadata instantiation function of a generic struct or
324324
/// enum.
325-
SWIFT_RETURNS_NONNULL SWIFT_NODISCARD SWIFT_RUNTIME_EXPORT
325+
SWIFT_RUNTIME_EXPORT SWIFT_RETURNS_NONNULL SWIFT_NODISCARD
326326
ValueMetadata *
327327
swift_allocateGenericValueMetadata(const ValueTypeDescriptor *description,
328328
const void *arguments,

lib/IRGen/GenDecl.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include "swift/ClangImporter/ClangModule.h"
3131
#include "swift/Demangling/ManglingMacros.h"
3232
#include "swift/IRGen/Linking.h"
33-
#include "swift/Runtime/HeapObject.h"
3433
#include "swift/SIL/FormalLinkage.h"
3534
#include "swift/SIL/SILDebugScope.h"
3635
#include "swift/SIL/SILModule.h"

0 commit comments

Comments
 (0)