Skip to content

Commit fbccda9

Browse files
authored
Merge pull request #60304 from hyp/eng/generic-trait-move-hdr
[interop][SwiftToCxx] NFC, move generic traits declarations to shims …
2 parents 3f1dd13 + 9ff7f94 commit fbccda9

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

lib/PrintAsClang/PrintSwiftToClangCoreScaffold.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,6 @@ void printCxxNaiveException(raw_ostream &os) {
210210
os << "};\n";
211211
}
212212

213-
void printGenericTypeTraits(raw_ostream &os) {
214-
os << "template<class T>\n";
215-
os << "static inline const constexpr bool isUsableInGenericContext = "
216-
"false;\n\n";
217-
os << "template<class T> inline void * _Nonnull getTypeMetadata();\n\n";
218-
}
219-
220213
void printPrimitiveGenericTypeTraits(raw_ostream &os, ASTContext &astContext,
221214
PrimitiveTypeMapping &typeMapping,
222215
bool isCForwardDefinition) {
@@ -287,7 +280,6 @@ void swift::printSwiftToClangCoreScaffold(SwiftToClangInteropContext &ctx,
287280
// C++ only supports inline variables from C++17.
288281
// FIXME: silence the warning instead?
289282
os << "#if __cplusplus > 201402L\n";
290-
printGenericTypeTraits(os);
291283
printPrimitiveGenericTypeTraits(os, astContext, typeMapping,
292284
/*isCForwardDefinition=*/false);
293285
os << "#endif\n";

stdlib/public/SwiftShims/_SwiftCxxInteroperability.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,20 @@ inline void opaqueFree(void *_Nonnull p) noexcept {
5050
}
5151

5252
} // namespace _impl
53+
54+
#pragma clang diagnostic push
55+
#pragma clang diagnostic ignored "-Wc++17-extensions"
56+
57+
/// True if the given type is a Swift type that can be used in a generic context
58+
/// in Swift.
59+
template <class T>
60+
static inline const constexpr bool isUsableInGenericContext = false;
61+
62+
#pragma clang diagnostic pop
63+
64+
/// Returns the type metadat for the given Swift type T.
65+
template <class T> inline void *_Nonnull getTypeMetadata();
66+
5367
} // namespace swift
5468
#endif
5569

test/Interop/SwiftToCxx/core/swift-impl-defs-in-cxx.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,6 @@
129129
// CHECK-EMPTY:
130130
// CHECK-EMPTY:
131131
// CHECK-NEXT: #if __cplusplus > 201402L
132-
// CHECK-NEXT: template<class T>
133-
// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext = false;
134-
// CHECK-EMPTY:
135-
// CHECK-NEXT: template<class T> inline void * _Nonnull getTypeMetadata();
136-
// CHECK-EMPTY:
137132
// CHECK-NEXT: template<>
138133
// CHECK-NEXT: static inline const constexpr bool isUsableInGenericContext<bool> = true;
139134
// CHECK-EMPTY:

0 commit comments

Comments
 (0)