Skip to content

Commit 36d1db7

Browse files
committed
Basic, SIL: Include <swift/bridging> instead of defining our own macros
1 parent c2271e2 commit 36d1db7

File tree

4 files changed

+36
-16
lines changed

4 files changed

+36
-16
lines changed

include/swift/Basic/BasicBridging.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
#include "swift/Basic/BridgedSwiftObject.h"
4141
#include "swift/Basic/Compiler.h"
42+
#include "swift/Basic/SwiftBridging.h"
4243

4344
#include <stddef.h>
4445
#include <stdint.h>
@@ -55,13 +56,6 @@
5556
#include <vector>
5657
#endif
5758

58-
// FIXME: We ought to be importing '<swift/bridging>' instead.
59-
#if __has_attribute(swift_name)
60-
#define SWIFT_NAME(NAME) __attribute__((swift_name(NAME)))
61-
#else
62-
#define SWIFT_NAME(NAME)
63-
#endif
64-
6559
#if __has_attribute(availability)
6660
#define SWIFT_UNAVAILABLE(msg) \
6761
__attribute__((availability(swift, unavailable, message=msg)))

include/swift/Basic/Compiler.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,6 @@
9090
#define SWIFT_IMPORT_UNSAFE
9191
#endif
9292

93-
/// Same as `SWIFT_SELF_CONTAINED` in <swift/bridging>.
94-
#if __has_attribute(swift_attr)
95-
#define SWIFT_SELF_CONTAINED __attribute__((swift_attr("import_owned")))
96-
#else
97-
#define SWIFT_SELF_CONTAINED
98-
#endif
99-
10093
#ifdef __GNUC__
10194
#define SWIFT_ATTRIBUTE_NORETURN __attribute__((noreturn))
10295
#elif defined(_MSC_VER)

include/swift/Basic/SwiftBridging.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//===--- Basic/SwiftBridging.h ----------------------------------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2025 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
///
13+
/// This is a wrapper around `<swift/bridging>` that redefines `SWIFT_NAME` to
14+
/// accept a string literal. String literals enable us to properly format the
15+
/// long Swift declaration names that many of our bridging functions have.
16+
///
17+
//===----------------------------------------------------------------------===//
18+
19+
#ifndef SWIFT_BASIC_SWIFT_BRIDGING_H
20+
#define SWIFT_BASIC_SWIFT_BRIDGING_H
21+
22+
#include <swift/bridging>
23+
24+
#undef SWIFT_NAME
25+
#if __has_attribute(swift_name)
26+
#define SWIFT_NAME(NAME) __attribute__((swift_name(NAME)))
27+
#else
28+
#define SWIFT_NAME(NAME)
29+
#endif
30+
31+
#endif // SWIFT_BASIC_SWIFT_BRIDGING_H
32+

include/swift/SIL/SILLocation.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
#ifndef SWIFT_SIL_LOCATION_H
1414
#define SWIFT_SIL_LOCATION_H
1515

16-
#include "llvm/ADT/PointerUnion.h"
1716
#include "swift/AST/ASTNode.h"
17+
#include "swift/AST/TypeAlignments.h"
1818
#include "swift/Basic/SourceLoc.h"
19+
#include "swift/Basic/SwiftBridging.h"
1920
#include "swift/SIL/SILAllocated.h"
20-
#include "swift/AST/TypeAlignments.h"
21+
#include "llvm/ADT/PointerUnion.h"
2122

2223
#include <cstddef>
2324
#include <type_traits>

0 commit comments

Comments
 (0)