mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[IRGen+Runtime] Layout string getEnumTag for fixed size enums subset (#66899)
* [IRGen+Runtime] Layout string getEnumTag for fixed size enums subset getEnumTag impl for layout strings of fixed sized enums that use a function to fetch the enum tag * Fix potential UB in IRGen
This commit is contained in:
@@ -652,6 +652,17 @@ swift_generic_assignWithTake(swift::OpaqueValue *dest, swift::OpaqueValue *src,
|
||||
return swift_generic_initWithTake(dest, src, metadata);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
unsigned swift_enumFn_getEnumTag(swift::OpaqueValue *address,
|
||||
const Metadata *metadata) {
|
||||
auto addr = reinterpret_cast<const uint8_t *>(address);
|
||||
LayoutStringReader reader{metadata->getLayoutString(),
|
||||
layoutStringHeaderSize + sizeof(uint64_t)};
|
||||
auto getEnumTag = readRelativeFunctionPointer<GetEnumTagFn>(reader);
|
||||
|
||||
return getEnumTag(addr);
|
||||
}
|
||||
|
||||
extern "C" unsigned
|
||||
swift_multiPayloadEnumGeneric_getEnumTag(swift::OpaqueValue *address,
|
||||
const Metadata *metadata) {
|
||||
|
||||
Reference in New Issue
Block a user