Skip to content

Commit de45648

Browse files
committed
Separate CC attrs in the compatibility-override macro; NFC.
1 parent 84be3f0 commit de45648

File tree

5 files changed

+43
-41
lines changed

5 files changed

+43
-41
lines changed

stdlib/public/runtime/CompatibilityOverride.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ using namespace swift;
3838
struct OverrideSection {
3939
uintptr_t version;
4040

41-
#define OVERRIDE(name, ret, attrs, namespace, typedArgs, namedArgs) \
41+
#define OVERRIDE(name, ret, attrs, ccAttrs, namespace, typedArgs, namedArgs) \
4242
Override_ ## name name;
4343
#include "CompatibilityOverride.def"
4444
};
@@ -61,7 +61,7 @@ static OverrideSection *getOverrideSectionPtr() {
6161
return OverrideSectionPtr;
6262
}
6363

64-
#define OVERRIDE(name, ret, attrs, namespace, typedArgs, namedArgs) \
64+
#define OVERRIDE(name, ret, attrs, ccAttrs, namespace, typedArgs, namedArgs) \
6565
Override_ ## name swift::getOverride_ ## name() { \
6666
auto *Section = getOverrideSectionPtr(); \
6767
if (Section == nullptr) \

stdlib/public/runtime/CompatibilityOverride.def

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -69,104 +69,104 @@
6969
# endif
7070
#endif
7171

72-
OVERRIDE_CASTING(dynamicCast, bool, , swift::,
72+
OVERRIDE_CASTING(dynamicCast, bool, , , swift::,
7373
(OpaqueValue *dest, OpaqueValue *src,
7474
const Metadata *srcType,
7575
const Metadata *targetType,
7676
DynamicCastFlags flags),
7777
(dest, src, srcType, targetType, flags))
7878

7979

80-
OVERRIDE_CASTING(dynamicCastClass, const void *, , swift::,
80+
OVERRIDE_CASTING(dynamicCastClass, const void *, , , swift::,
8181
(const void *object,
8282
const ClassMetadata *targetType),
8383
(object, targetType))
8484

8585

86-
OVERRIDE_CASTING(dynamicCastClassUnconditional, const void *, , swift::,
86+
OVERRIDE_CASTING(dynamicCastClassUnconditional, const void *, , , swift::,
8787
(const void *object,
8888
const ClassMetadata *targetType,
8989
const char *file, unsigned line, unsigned column),
9090
(object, targetType, file, line, column))
9191

9292

9393

94-
OVERRIDE_CASTING(dynamicCastUnknownClass, const void *, , swift::,
94+
OVERRIDE_CASTING(dynamicCastUnknownClass, const void *, , , swift::,
9595
(const void *object, const Metadata *targetType),
9696
(object, targetType))
9797

9898

99-
OVERRIDE_CASTING(dynamicCastUnknownClassUnconditional, const void *, , swift::,
99+
OVERRIDE_CASTING(dynamicCastUnknownClassUnconditional, const void *, , , swift::,
100100
(const void *object, const Metadata *targetType,
101101
const char *file, unsigned line, unsigned column),
102102
(object, targetType, file, line, column))
103103

104104

105-
OVERRIDE_CASTING(dynamicCastMetatype, const Metadata *, , swift::,
105+
OVERRIDE_CASTING(dynamicCastMetatype, const Metadata *, , , swift::,
106106
(const Metadata *sourceType,
107107
const Metadata *targetType),
108108
(sourceType, targetType))
109109

110110

111-
OVERRIDE_CASTING(dynamicCastMetatypeUnconditional, const Metadata *, , swift::,
111+
OVERRIDE_CASTING(dynamicCastMetatypeUnconditional, const Metadata *, , , swift::,
112112
(const Metadata *sourceType,
113113
const Metadata *targetType,
114114
const char *file, unsigned line, unsigned column),
115115
(sourceType, targetType, file, line, column))
116116

117117

118-
OVERRIDE_FOREIGN(dynamicCastForeignClassMetatype, const ClassMetadata *, , swift::,
118+
OVERRIDE_FOREIGN(dynamicCastForeignClassMetatype, const ClassMetadata *, , , swift::,
119119
(const ClassMetadata *sourceType,
120120
const ClassMetadata *targetType),
121121
(sourceType, targetType))
122122

123123

124124
OVERRIDE_FOREIGN(dynamicCastForeignClassMetatypeUnconditional,
125-
const ClassMetadata *, , swift::,
125+
const ClassMetadata *, , , swift::,
126126
(const ClassMetadata *sourceType,
127127
const ClassMetadata *targetType,
128128
const char *file, unsigned line, unsigned column),
129129
(sourceType, targetType, file, line, column))
130130

131131

132-
OVERRIDE_PROTOCOLCONFORMANCE(conformsToProtocol, const WitnessTable *, , swift::,
132+
OVERRIDE_PROTOCOLCONFORMANCE(conformsToProtocol, const WitnessTable *, , , swift::,
133133
(const Metadata * const type,
134134
const ProtocolDescriptor *protocol),
135135
(type, protocol))
136136

137137
OVERRIDE_PROTOCOLCONFORMANCE(conformsToSwiftProtocol,
138-
const ProtocolConformanceDescriptor *, , swift::,
138+
const ProtocolConformanceDescriptor *, , , swift::,
139139
(const Metadata * const type,
140140
const ProtocolDescriptor *protocol,
141141
StringRef moduleName),
142142
(type, protocol, moduleName))
143143

144-
OVERRIDE_KEYPATH(getKeyPath, const HeapObject *, , swift::,
144+
OVERRIDE_KEYPATH(getKeyPath, const HeapObject *, , , swift::,
145145
(const void *pattern, const void *arguments),
146146
(pattern, arguments))
147147

148-
OVERRIDE_METADATALOOKUP(getTypeByMangledNode, TypeInfo, , swift::,
148+
OVERRIDE_METADATALOOKUP(getTypeByMangledNode, TypeInfo, , , swift::,
149149
(Demangler &demangler,
150150
Demangle::NodePointer node,
151151
SubstGenericParameterFn substGenericParam,
152152
SubstDependentWitnessTableFn substWitnessTable),
153153
(demangler, node, substGenericParam, substWitnessTable))
154-
OVERRIDE_METADATALOOKUP(getTypeByMangledName, TypeInfo, , swift::,
154+
OVERRIDE_METADATALOOKUP(getTypeByMangledName, TypeInfo, , , swift::,
155155
(StringRef typeName,
156156
SubstGenericParameterFn substGenericParam,
157157
SubstDependentWitnessTableFn substWitnessTable),
158158
(typeName, substGenericParam, substWitnessTable))
159159

160160
OVERRIDE_WITNESSTABLE(getAssociatedTypeWitnessSlow, MetadataResponse,
161-
SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERNAL, swift::,
161+
SWIFT_RUNTIME_STDLIB_INTERNAL, SWIFT_CC(swift), swift::,
162162
(MetadataRequest request, WitnessTable *wtable,
163163
const Metadata *conformingType,
164164
const ProtocolRequirement *reqBase,
165165
const ProtocolRequirement *assocType),
166166
(request, wtable, conformingType, reqBase, assocType))
167167

168168
OVERRIDE_WITNESSTABLE(getAssociatedConformanceWitnessSlow, const WitnessTable *,
169-
SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERNAL, swift::,
169+
SWIFT_RUNTIME_STDLIB_INTERNAL, SWIFT_CC(swift), swift::,
170170
(WitnessTable *wtable, const Metadata *conformingType,
171171
const Metadata *assocType,
172172
const ProtocolRequirement *reqBase,
@@ -175,37 +175,37 @@ OVERRIDE_WITNESSTABLE(getAssociatedConformanceWitnessSlow, const WitnessTable *,
175175
assocConformance))
176176
#if SWIFT_OBJC_INTEROP
177177

178-
OVERRIDE_OBJC(dynamicCastObjCClass, const void *, , swift::,
178+
OVERRIDE_OBJC(dynamicCastObjCClass, const void *, , , swift::,
179179
(const void *object,
180180
const ClassMetadata *targetType),
181181
(object, targetType))
182182

183183

184-
OVERRIDE_OBJC(dynamicCastObjCClassUnconditional, const void *, , swift::,
184+
OVERRIDE_OBJC(dynamicCastObjCClassUnconditional, const void *, , , swift::,
185185
(const void *object,
186186
const ClassMetadata *targetType,
187187
const char *file, unsigned line, unsigned column),
188188
(object, targetType, file, line, column))
189189

190-
OVERRIDE_OBJC(dynamicCastObjCClassMetatype, const ClassMetadata *, , swift::,
190+
OVERRIDE_OBJC(dynamicCastObjCClassMetatype, const ClassMetadata *, , , swift::,
191191
(const ClassMetadata *sourceType,
192192
const ClassMetadata *targetType),
193193
(sourceType, targetType))
194194

195195

196-
OVERRIDE_OBJC(dynamicCastObjCClassMetatypeUnconditional, const ClassMetadata *, , swift::,
196+
OVERRIDE_OBJC(dynamicCastObjCClassMetatypeUnconditional, const ClassMetadata *, , , swift::,
197197
(const ClassMetadata *sourceType, const ClassMetadata *targetType,
198198
const char *file, unsigned line, unsigned column),
199199
(sourceType, targetType, file, line, column))
200200

201201

202-
OVERRIDE_FOREIGN(dynamicCastForeignClass, const void *, , swift::,
202+
OVERRIDE_FOREIGN(dynamicCastForeignClass, const void *, , , swift::,
203203
(const void *object,
204204
const ForeignClassMetadata *targetType),
205205
(object, targetType))
206206

207207

208-
OVERRIDE_FOREIGN(dynamicCastForeignClassUnconditional, const void *, , swift::,
208+
OVERRIDE_FOREIGN(dynamicCastForeignClassUnconditional, const void *, , , swift::,
209209
(const void *object, const ForeignClassMetadata *targetType,
210210
const char *file, unsigned line, unsigned column),
211211
(object, targetType, file, line, column))

stdlib/public/runtime/CompatibilityOverride.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ namespace swift {
2626

2727
#define COMPATIBILITY_UNPAREN(...) __VA_ARGS__
2828

29-
#define OVERRIDE(name, ret, attrs, namespace, typedArgs, namedArgs) \
30-
typedef ret (*Original_ ## name) typedArgs;
29+
#define OVERRIDE(name, ret, attrs, ccAttrs, namespace, typedArgs, namedArgs) \
30+
ccAttrs typedef ret (*Original_ ## name) typedArgs;
3131
#include "CompatibilityOverride.def"
3232

33-
#define OVERRIDE(name, ret, attrs, namespace, typedArgs, namedArgs) \
34-
typedef ret (*Override_ ## name)(COMPATIBILITY_UNPAREN typedArgs, \
35-
Original_ ## name originalImpl);
33+
#define OVERRIDE(name, ret, attrs, ccAttrs, namespace, typedArgs, namedArgs) \
34+
ccAttrs typedef ret (*Override_ ## name)(COMPATIBILITY_UNPAREN typedArgs, \
35+
Original_ ## name originalImpl);
3636
#include "CompatibilityOverride.def"
3737

38-
#define OVERRIDE(name, ret, attrs, namespace, typedArgs, namedArgs) \
38+
#define OVERRIDE(name, ret, attrs, ccAttrs, namespace, typedArgs, namedArgs) \
3939
Override_ ## name getOverride_ ## name();
4040
#include "CompatibilityOverride.def"
4141

@@ -44,8 +44,8 @@ namespace swift {
4444
/// OVERRIDE macro from CompatibilityOverride.def to this macro, then includes
4545
/// the file to generate the override points. The original implementation of the
4646
/// functionality must be available as swift_funcNameHereImpl.
47-
#define COMPATIBILITY_OVERRIDE(name, ret, attrs, namespace, typedArgs, namedArgs) \
48-
attrs ret namespace swift_ ## name typedArgs { \
47+
#define COMPATIBILITY_OVERRIDE(name, ret, attrs, ccAttrs, namespace, typedArgs, namedArgs) \
48+
attrs ccAttrs ret namespace swift_ ## name typedArgs { \
4949
static Override_ ## name Override; \
5050
static swift_once_t Predicate; \
5151
swift_once(&Predicate, [](void *) { \

stdlib/public/runtime/Metadata.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4139,6 +4139,7 @@ static StringRef findAssociatedTypeName(const ProtocolDescriptor *protocol,
41394139
return StringRef();
41404140
}
41414141

4142+
SWIFT_CC(swift)
41424143
static MetadataResponse
41434144
swift_getAssociatedTypeWitnessSlowImpl(
41444145
MetadataRequest request,
@@ -4275,6 +4276,7 @@ swift::swift_getAssociatedTypeWitness(MetadataRequest request,
42754276
reqBase, assocType);
42764277
}
42774278

4279+
SWIFT_CC(swift)
42784280
static const WitnessTable *swift_getAssociatedConformanceWitnessSlowImpl(
42794281
WitnessTable *wtable,
42804282
const Metadata *conformingType,

unittests/runtime/CompatibilityOverride.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,28 @@ namespace {
4141
}
4242
}
4343

44-
#define OVERRIDE(name, ret, attrs, namespace, typedArgs, namedArgs) \
45-
static ret name ## Override(COMPATIBILITY_UNPAREN typedArgs, \
46-
Original_ ## name originalImpl) { \
47-
if (!EnableOverride) \
48-
return originalImpl namedArgs; \
49-
Ran = true; \
50-
return getEmptyValue<ret>(); \
44+
#define OVERRIDE(name, ret, attrs, ccAttrs, namespace, typedArgs, namedArgs) \
45+
static ccAttrs ret name ## Override(COMPATIBILITY_UNPAREN typedArgs, \
46+
Original_ ## name originalImpl) { \
47+
if (!EnableOverride) \
48+
return originalImpl namedArgs; \
49+
Ran = true; \
50+
return getEmptyValue<ret>(); \
5151
}
5252
#include "../../stdlib/public/runtime/CompatibilityOverride.def"
5353

5454

5555
struct OverrideSection {
5656
uintptr_t version;
5757

58-
#define OVERRIDE(name, ret, attrs, namespace, typedArgs, namedArgs) \
58+
#define OVERRIDE(name, ret, attrs, ccAttrs, namespace, typedArgs, namedArgs) \
5959
Override_ ## name name;
6060
#include "../../stdlib/public/runtime/CompatibilityOverride.def"
6161
};
6262

6363
OverrideSection Overrides __attribute__((section("__DATA,__swift_hooks"))) = {
6464
0,
65-
#define OVERRIDE(name, ret, attrs, namespace, typedArgs, namedArgs) \
65+
#define OVERRIDE(name, ret, attrs, ccAttrs, namespace, typedArgs, namedArgs) \
6666
name ## Override,
6767
#include "../../stdlib/public/runtime/CompatibilityOverride.def"
6868
};

0 commit comments

Comments
 (0)