Skip to content

Commit 5f2a641

Browse files
committed
[cxx-interop][SwiftCompilerSources] Use swift::SILWitnessTable::WitnessKind instead of `
SILWitnessTableEntryKind` rdar://83361087
1 parent 3f1a30c commit 5f2a641

File tree

7 files changed

+17
-49
lines changed

7 files changed

+17
-49
lines changed

SwiftCompilerSources/Sources/Optimizer/DataStructures/FunctionUses.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ struct FunctionUses {
134134

135135
for witnessTable in context.witnessTables {
136136
for entry in witnessTable.entries {
137-
if entry.kind == .method, let f = entry.methodFunction {
137+
if entry.kind == .Method, let f = entry.methodFunction {
138138
markUnknown(f)
139139
}
140140
}
141141
}
142142

143143
for witnessTable in context.defaultWitnessTables {
144144
for entry in witnessTable.entries {
145-
if entry.kind == .method, let f = entry.methodFunction {
145+
if entry.kind == .Method, let f = entry.methodFunction {
146146
markUnknown(f)
147147
}
148148
}

SwiftCompilerSources/Sources/SIL/WitnessTable.swift

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,14 @@ public struct WitnessTable : CustomStringConvertible, CustomReflectable {
2020
public struct Entry : CustomStringConvertible, CustomReflectable {
2121
fileprivate let bridged: BridgedWitnessTableEntry
2222

23-
public enum Kind {
24-
case invalid
25-
case method
26-
case associatedType
27-
case associatedTypeProtocol
28-
case baseProtocol
29-
}
23+
public typealias Kind = swift.SILWitnessTable.WitnessKind
3024

3125
public var kind: Kind {
32-
switch SILWitnessTableEntry_getKind(bridged) {
33-
case SILWitnessTableEntry_Invalid: return .invalid
34-
case SILWitnessTableEntry_Method: return .method
35-
case SILWitnessTableEntry_AssociatedType: return .associatedType
36-
case SILWitnessTableEntry_AssociatedTypeProtocol: return .associatedTypeProtocol
37-
case SILWitnessTableEntry_BaseProtocol: return .baseProtocol
38-
default:
39-
fatalError("unknown witness table kind")
40-
}
26+
return SILWitnessTableEntry_getKind(bridged)
4127
}
4228

4329
public var methodFunction: Function? {
44-
assert(kind == .method)
30+
assert(kind == .Method)
4531
return SILWitnessTableEntry_getMethodFunction(bridged).function
4632
}
4733

include/swift/AST/ASTBridging.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@ SWIFT_BEGIN_NULLABILITY_ANNOTATIONS
2525
// Diagnostic Engine
2626
//===----------------------------------------------------------------------===//
2727

28-
// TODO: Move this to somewhere common header.
29-
#if __has_attribute(enum_extensibility)
30-
#define ENUM_EXTENSIBILITY_ATTR(arg) __attribute__((enum_extensibility(arg)))
31-
#else
32-
#define ENUM_EXTENSIBILITY_ATTR(arg)
33-
#endif
34-
3528
// NOTE: This must be the same underlying value as C++ 'swift::DiagID' defined
3629
// in 'DiagnosticList.cpp'.
3730
typedef enum ENUM_EXTENSIBILITY_ATTR(open) BridgedDiagID : uint32_t {

include/swift/Basic/Compiler.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,10 @@
187187
#define SWIFT_IMPORT_REFERENCE
188188
#endif
189189

190+
#if __has_attribute(enum_extensibility)
191+
#define ENUM_EXTENSIBILITY_ATTR(arg) __attribute__((enum_extensibility(arg)))
192+
#else
193+
#define ENUM_EXTENSIBILITY_ATTR(arg)
194+
#endif
195+
190196
#endif // SWIFT_BASIC_COMPILER_H

include/swift/SIL/SILBridging.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "swift/AST/SubstitutionMap.h"
2020
#include "swift/SIL/SILInstruction.h"
2121
#include "swift/SIL/SILLocation.h"
22+
#include "swift/SIL/SILWitnessTable.h"
2223
#include <stdbool.h>
2324
#include <stddef.h>
2425
#include <string>
@@ -96,14 +97,6 @@ typedef struct {
9697
const void * _Nonnull ptr;
9798
} BridgedWitnessTableEntry;
9899

99-
typedef enum {
100-
SILWitnessTableEntry_Invalid,
101-
SILWitnessTableEntry_Method,
102-
SILWitnessTableEntry_AssociatedType,
103-
SILWitnessTableEntry_AssociatedTypeProtocol,
104-
SILWitnessTableEntry_BaseProtocol
105-
} SILWitnessTableEntryKind;
106-
107100
typedef struct {
108101
SwiftObject obj;
109102
} BridgedFunction;
@@ -265,7 +258,7 @@ BridgedArrayRef SILWitnessTable_getEntries(BridgedWitnessTable table);
265258
std::string SILDefaultWitnessTable_debugDescription(BridgedDefaultWitnessTable table);
266259
BridgedArrayRef SILDefaultWitnessTable_getEntries(BridgedDefaultWitnessTable table);
267260
std::string SILWitnessTableEntry_debugDescription(BridgedWitnessTableEntry entry);
268-
SILWitnessTableEntryKind SILWitnessTableEntry_getKind(BridgedWitnessTableEntry entry);
261+
swift::SILWitnessTable::WitnessKind SILWitnessTableEntry_getKind(BridgedWitnessTableEntry entry);
269262
OptionalBridgedFunction SILWitnessTableEntry_getMethodFunction(BridgedWitnessTableEntry entry);
270263

271264
OptionalBridgedBasicBlock SILBasicBlock_next(BridgedBasicBlock block);

include/swift/SIL/SILWitnessTable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class SILWitnessTable : public llvm::ilist_node<SILWitnessTable>,
9090
AssociatedType,
9191
AssociatedTypeProtocol,
9292
BaseProtocol
93-
};
93+
} ENUM_EXTENSIBILITY_ATTR(open);
9494

9595
/// A witness table entry.
9696
class Entry {

lib/SIL/Utils/SILBridging.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -653,19 +653,9 @@ std::string SILWitnessTableEntry_debugDescription(BridgedWitnessTableEntry entry
653653
return str;
654654
}
655655

656-
SILWitnessTableEntryKind SILWitnessTableEntry_getKind(BridgedWitnessTableEntry entry) {
657-
switch (castToWitnessTableEntry(entry)->getKind()) {
658-
case SILWitnessTable::Invalid:
659-
return SILWitnessTableEntry_Invalid;
660-
case SILWitnessTable::Method:
661-
return SILWitnessTableEntry_Method;
662-
case SILWitnessTable::AssociatedType:
663-
return SILWitnessTableEntry_AssociatedType;
664-
case SILWitnessTable::AssociatedTypeProtocol:
665-
return SILWitnessTableEntry_AssociatedTypeProtocol;
666-
case SILWitnessTable::BaseProtocol:
667-
return SILWitnessTableEntry_BaseProtocol;
668-
}
656+
SILWitnessTable::WitnessKind
657+
SILWitnessTableEntry_getKind(BridgedWitnessTableEntry entry) {
658+
return castToWitnessTableEntry(entry)->getKind();
669659
}
670660

671661
OptionalBridgedFunction SILWitnessTableEntry_getMethodFunction(BridgedWitnessTableEntry entry) {

0 commit comments

Comments
 (0)