Teach RemoteMirror how to project enum values (#30161)

Teach RemoteMirror how to project enum values

This adds two new functions to the SwiftRemoteMirror
facility that support inspecting enum values.

Currently, these support non-payload enums and
single-payload enums, including nested enums and
payloads with struct, tuple, and reference payloads.
In particular, it handles nested `Optional` types.

TODO: Multi-payload enums use different strategies for
encoding the cases that aren't yet supported by this
code.

Note: This relies on information from dataLayoutQuery
to correctly decode invalid pointer values that are used
to encode enums.  Existing clients will need to augment
their DLQ functions before using these new APIs.

Resolves rdar://59961527

```
/// Projects the value of an enum.
///
/// Takes the address and typeref for an enum and determines the
/// index of the currently-selected case within the enum.
///
/// Returns true iff the enum case could be successfully determined.
/// In particular, note that this code may fail for valid in-memory data
/// if the compiler is using a strategy we do not yet understand.
SWIFT_REMOTE_MIRROR_LINKAGE
int swift_reflection_projectEnumValue(SwiftReflectionContextRef ContextRef,
                                      swift_addr_t EnumAddress,
                                      swift_typeref_t EnumTypeRef,
                                      uint64_t *CaseIndex);

/// Finds information about a particular enum case.
///
/// Given an enum typeref and index of a case, returns:
/// * Typeref of the associated payload or zero if there is no payload
/// * Name of the case if known.
///
/// The Name points to a freshly-allocated C string on the heap.  You
/// are responsible for freeing the string (via `free()`) when you are finished.
SWIFT_REMOTE_MIRROR_LINKAGE
int swift_reflection_getEnumCaseTypeRef(SwiftReflectionContextRef ContextRef,
                                        swift_typeref_t EnumTypeRef,
                                        unsigned CaseIndex,
                                        char **CaseName,
                                        swift_typeref_t *PayloadTypeRef);
```


Co-authored-by: Mike Ash <mikeash@apple.com>
This commit is contained in:
tbkka
2020-03-06 13:17:40 -08:00
committed by GitHub
parent c825ed8481
commit 0d361bd3ea
30 changed files with 6643 additions and 527 deletions

View File

@@ -23,6 +23,7 @@
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/Object/COFF.h"
#include "swift/ABI/Enum.h"
#include "swift/Remote/MemoryReader.h"
#include "swift/Remote/MetadataReader.h"
#include "swift/Reflection/Records.h"
@@ -710,6 +711,128 @@ public:
}
}
bool projectEnumValue(RemoteAddress EnumAddress,
const TypeRef *EnumTR,
int *CaseIndex) {
if (EnumTR == nullptr)
return false;
auto EnumTI = getTypeInfo(EnumTR);
if (EnumTI == nullptr)
return false;
auto EnumRecordTI = dyn_cast<const RecordTypeInfo>(EnumTI);
if (EnumRecordTI == nullptr)
return false;
auto EnumSize = EnumRecordTI->getSize();
auto Fields = EnumRecordTI->getFields();
auto FieldCount = Fields.size();
if (FieldCount == 0) {
return false; // No fields?
}
if (FieldCount == 1) {
*CaseIndex = 0; // Only possible field
return true;
}
switch (EnumRecordTI->getRecordKind()) {
case RecordKind::NoPayloadEnum: {
if (EnumSize == 0) {
*CaseIndex = 0;
return true;
}
return getReader().readInteger(EnumAddress, EnumSize, CaseIndex);
}
case RecordKind::SinglePayloadEnum: {
FieldInfo PayloadCase = Fields[0];
if (!PayloadCase.TR)
return false;
unsigned long NonPayloadCaseCount = FieldCount - 1;
unsigned long PayloadExtraInhabitants = PayloadCase.TI.getNumExtraInhabitants();
unsigned discriminator = 0;
auto PayloadSize = PayloadCase.TI.getSize();
if (NonPayloadCaseCount >= PayloadExtraInhabitants) {
// There are more cases than inhabitants, we need a separate discriminator.
auto TagInfo = getEnumTagCounts(PayloadSize, NonPayloadCaseCount, 1);
auto TagSize = TagInfo.numTagBytes;
auto TagAddress = RemoteAddress(EnumAddress.getAddressData() + PayloadSize);
if (!getReader().readInteger(TagAddress, TagSize, &discriminator))
return false;
}
if (PayloadExtraInhabitants == 0) {
// Payload has no XI, so discriminator fully determines the case
*CaseIndex = discriminator;
return true;
} else if (discriminator == 0) {
// The value overlays the payload ... ask the payload to decode it.
int t;
if (!PayloadCase.TI.readExtraInhabitantIndex(getReader(), EnumAddress, &t)) {
return false;
}
if (t < 0) {
*CaseIndex = 0;
return true;
} else if ((unsigned long)t <= NonPayloadCaseCount) {
*CaseIndex = t + 1;
return true;
}
return false;
} else {
// The entire payload area is available for additional cases:
auto TagSize = std::max(PayloadSize, 4U); // XXX TODO XXX CHECK THIS
auto offset = 1 + PayloadExtraInhabitants; // Cases coded with discriminator = 0
unsigned casesInPayload = 1 << (TagSize * 8U);
unsigned payloadCode;
if (!getReader().readInteger(EnumAddress, TagSize, &payloadCode))
return false;
*CaseIndex = offset + (discriminator - 1) * casesInPayload + payloadCode;
return true;
}
}
case RecordKind::MultiPayloadEnum: {
// TODO: Support multipayload enums
break;
}
default:
// Unknown record kind.
break;
}
return false;
}
bool getEnumCaseTypeRef(const TypeRef *EnumTR,
unsigned CaseIndex,
std::string &Name,
const TypeRef **OutPayloadTR) {
*OutPayloadTR = nullptr;
if (EnumTR == nullptr)
return false;
auto EnumTI = getTypeInfo(EnumTR);
if (EnumTI == nullptr)
return false;
auto EnumRecordTI = dyn_cast<const RecordTypeInfo>(EnumTI);
if (EnumRecordTI == nullptr)
return false;
auto NumCases = EnumRecordTI->getNumFields();
if (CaseIndex >= NumCases) {
return false;
} else {
const auto Case = EnumRecordTI->getFields()[CaseIndex];
Name = Case.Name;
*OutPayloadTR = Case.TR;
return true;
}
}
/// Return a description of the layout of a value with the given type.
const TypeInfo *getTypeInfo(const TypeRef *TR) {
return getBuilder().getTypeConverter().getTypeInfo(TR);

View File

@@ -106,6 +106,7 @@ enum class TypeInfoKind : unsigned {
Builtin,
Record,
Reference,
Invalid,
};
class TypeInfo {
@@ -124,6 +125,10 @@ public:
assert(Alignment > 0);
}
TypeInfo(): Kind(TypeInfoKind::Invalid), Size(0), Alignment(0), Stride(0),
NumExtraInhabitants(0), BitwiseTakable(true) {
}
TypeInfoKind getKind() const { return Kind; }
unsigned getSize() const { return Size; }
@@ -134,11 +139,24 @@ public:
void dump() const;
void dump(FILE *file, unsigned Indent = 0) const;
// Using the provided reader, inspect our value.
// Return false if we can't inspect value.
// Set *inhabitant to <0 if the value is valid (not an XI)
// Else set *inhabitant to the XI value (counting from 0)
virtual bool readExtraInhabitantIndex(remote::MemoryReader &reader,
remote::RemoteAddress address,
int *index) const {
return false;
}
virtual ~TypeInfo() { }
};
struct FieldInfo {
std::string Name;
unsigned Offset;
int Value;
const TypeRef *TR;
const TypeInfo &TI;
};
@@ -155,6 +173,10 @@ public:
return Name;
}
bool readExtraInhabitantIndex(remote::MemoryReader &reader,
remote::RemoteAddress address,
int *extraInhabitantIndex) const;
static bool classof(const TypeInfo *TI) {
return TI->getKind() == TypeInfoKind::Builtin;
}
@@ -178,6 +200,10 @@ public:
unsigned getNumFields() const { return Fields.size(); }
const std::vector<FieldInfo> &getFields() const { return Fields; }
bool readExtraInhabitantIndex(remote::MemoryReader &reader,
remote::RemoteAddress address,
int *index) const;
static bool classof(const TypeInfo *TI) {
return TI->getKind() == TypeInfoKind::Record;
}
@@ -206,6 +232,16 @@ public:
return Refcounting;
}
bool readExtraInhabitantIndex(remote::MemoryReader &reader,
remote::RemoteAddress address,
int *extraInhabitantIndex) const {
if (getNumExtraInhabitants() == 0) {
*extraInhabitantIndex = -1;
return true;
}
return reader.readHeapObjectExtraInhabitantIndex(address, extraInhabitantIndex);
}
static bool classof(const TypeInfo *TI) {
return TI->getKind() == TypeInfoKind::Reference;
}

View File

@@ -215,23 +215,24 @@ struct ClosureContextInfo {
struct FieldTypeInfo {
std::string Name;
int Value;
const TypeRef *TR;
bool Indirect;
FieldTypeInfo() : Name(""), TR(nullptr), Indirect(false) {}
FieldTypeInfo(const std::string &Name, const TypeRef *TR, bool Indirect)
: Name(Name), TR(TR), Indirect(Indirect) {}
FieldTypeInfo() : Name(""), Value(0), TR(nullptr), Indirect(false) {}
FieldTypeInfo(const std::string &Name, int Value, const TypeRef *TR, bool Indirect)
: Name(Name), Value(Value), TR(TR), Indirect(Indirect) {}
static FieldTypeInfo forEmptyCase(std::string Name) {
return FieldTypeInfo(Name, nullptr, false);
static FieldTypeInfo forEmptyCase(std::string Name, int Value) {
return FieldTypeInfo(Name, Value, nullptr, false);
}
static FieldTypeInfo forIndirectCase(std::string Name, const TypeRef *TR) {
return FieldTypeInfo(Name, TR, true);
static FieldTypeInfo forIndirectCase(std::string Name, int Value, const TypeRef *TR) {
return FieldTypeInfo(Name, Value, TR, true);
}
static FieldTypeInfo forField(std::string Name, const TypeRef *TR) {
return FieldTypeInfo(Name, TR, false);
static FieldTypeInfo forField(std::string Name, int Value, const TypeRef *TR) {
return FieldTypeInfo(Name, Value, TR, false);
}
};

View File

@@ -21,6 +21,10 @@
#include <cstring>
#if defined(__APPLE__) && defined(__MACH__)
#include <TargetConditionals.h>
#endif
namespace swift {
namespace remote {
@@ -29,19 +33,53 @@ namespace remote {
class InProcessMemoryReader final : public MemoryReader {
bool queryDataLayout(DataLayoutQueryType type, void *inBuffer,
void *outBuffer) override {
switch (type) {
case DLQ_GetPointerSize: {
auto result = static_cast<uint8_t *>(outBuffer);
*result = sizeof(void *);
return true;
}
case DLQ_GetSizeSize: {
auto result = static_cast<uint8_t *>(outBuffer);
*result = sizeof(size_t);
return true;
}
}
#if defined(__APPLE__) && __APPLE__
auto applePlatform = true;
#else
auto applePlatform = false;
#endif
#if defined(__APPLE__) && __APPLE__ && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_IOS) && TARGET_OS_WATCH) || (defined(TARGET_OS_TV) && TARGET_OS_TV))
auto iosDerivedPlatform = true;
#else
auto iosDerivedPlatform = false;
#endif
switch (type) {
case DLQ_GetPointerSize: {
auto result = static_cast<uint8_t *>(outBuffer);
*result = sizeof(void *);
return true;
}
case DLQ_GetSizeSize: {
auto result = static_cast<uint8_t *>(outBuffer);
*result = sizeof(size_t);
return true;
}
case DLQ_GetObjCReservedLowBits: {
auto result = static_cast<uint8_t *>(outBuffer);
if (applePlatform && !iosDerivedPlatform && (sizeof(void *) == 8)) {
// Obj-C reserves low bit on 64-bit macOS only.
// Other Apple platforms don't reserve this bit (even when
// running on x86_64-based simulators).
*result = 1;
} else {
*result = 0;
}
return true;
}
case DLQ_GetLeastValidPointerValue: {
auto result = static_cast<uint64_t *>(outBuffer);
if (applePlatform && (sizeof(void *) == 8)) {
// Swift reserves the first 4GiB on Apple 64-bit platforms
*result = 0x100000000;
return 1;
} else {
// Swift reserves the first 4KiB everywhere else
*result = 0x1000;
}
return true;
}
}
return false;
}

View File

@@ -61,6 +61,50 @@ public:
sizeof(IntegerType));
}
/// Attempts to read an integer of the specified size from the given
/// address in the remote process.
///
/// Returns false if the operation failed, the request size is not
/// 1, 2, 4, or 8, or the request size is larger than the provided destination.
template <typename IntegerType>
bool readInteger(RemoteAddress address, size_t bytes, IntegerType *dest) {
if (bytes > sizeof(IntegerType))
return false;
switch (bytes) {
case 1: {
uint8_t n;
if (!readInteger(address, &n))
return false;
*dest = n;
break;
}
case 2: {
uint16_t n;
if (!readInteger(address, &n))
return false;
*dest = n;
break;
}
case 4: {
uint32_t n;
if (!readInteger(address, &n))
return false;
*dest = n;
break;
}
case 8: {
uint64_t n;
if (!readInteger(address, &n))
return false;
*dest = n;
break;
}
default:
return false;
}
return true;
}
/// Attempts to read 'size' bytes from the given address in the remote process.
///
/// Returns a pointer to the requested data and a function that must be called to
@@ -125,6 +169,65 @@ public:
return resolvePointer(address, pointerData);
}
// Parse extra inhabitants stored in a pointer.
// Sets *extraInhabitant to -1 if the pointer at this address
// is actually a valid pointer.
// Otherwise, it sets *extraInhabitant to the inhabitant
// index (counting from 0).
bool readHeapObjectExtraInhabitantIndex(RemoteAddress address,
int *extraInhabitantIndex) {
uint8_t PointerSize;
if (!queryDataLayout(DataLayoutQueryType::DLQ_GetPointerSize,
nullptr, &PointerSize)) {
return false;
}
uint64_t LeastValidPointerValue;
if (!queryDataLayout(DataLayoutQueryType::DLQ_GetLeastValidPointerValue,
nullptr, &LeastValidPointerValue)) {
return false;
}
uint8_t ObjCReservedLowBits;
if (!queryDataLayout(DataLayoutQueryType::DLQ_GetObjCReservedLowBits,
nullptr, &ObjCReservedLowBits)) {
return false;
}
uint64_t RawPointerValue;
if (!readInteger(address, PointerSize, &RawPointerValue)) {
return false;
}
if (RawPointerValue >= LeastValidPointerValue) {
*extraInhabitantIndex = -1; // Valid value, not an XI
} else {
*extraInhabitantIndex = (RawPointerValue >> ObjCReservedLowBits);
}
return true;
}
bool readFunctionPointerExtraInhabitantIndex(RemoteAddress address,
int *extraInhabitantIndex) {
uint8_t PointerSize;
if (!queryDataLayout(DataLayoutQueryType::DLQ_GetPointerSize,
nullptr, &PointerSize)) {
return false;
}
uint64_t LeastValidPointerValue;
if (!queryDataLayout(DataLayoutQueryType::DLQ_GetLeastValidPointerValue,
nullptr, &LeastValidPointerValue)) {
return false;
}
uint64_t RawPointerValue;
if (!readInteger(address, PointerSize, &RawPointerValue)) {
return false;
}
if (RawPointerValue >= LeastValidPointerValue) {
*extraInhabitantIndex = -1; // Valid value, not an XI
} else {
*extraInhabitantIndex = RawPointerValue;
}
return true;
}
virtual ~MemoryReader() = default;
};

View File

@@ -85,6 +85,19 @@ typedef enum {
/// should be populated with the size of size_t in the remote process, in
/// bytes.
DLQ_GetSizeSize,
/// The query should ignore inBuffer, and treat outBuffer as uint8_t* which
/// should be populated with the number of low-order bits in each pointer
/// reserved by Obj-C in the remote process. This is generally zero except
/// for 64-bit macOS, which has to reserve the bottom bit for Obj-C
/// interoperability.
DLQ_GetObjCReservedLowBits,
/// The query should ignore inBuffer, and treat outBuffer as uint64_t* which
/// should be populated with the lowest valid pointer value in the remote
/// process. This is currently 0x1000 (4096) except on 64-bit Apple platforms
/// where it is 0x100000000.
DLQ_GetLeastValidPointerValue,
} DataLayoutQueryType;
/// Data layout query function, which returns answers based on query types (from

View File

@@ -227,6 +227,35 @@ int swift_reflection_projectExistential(SwiftReflectionContextRef ContextRef,
swift_typeref_t *OutInstanceTypeRef,
swift_addr_t *OutStartOfInstanceData);
/// Projects the value of an enum.
///
/// Takes the address and typeref for an enum and determines the
/// index of the currently-selected case within the enum.
///
/// Returns true if the enum case could be successfully determined.
/// In particular, note that this code may fail for valid in-memory data
/// if the compiler is using a strategy we do not yet understand.
SWIFT_REMOTE_MIRROR_LINKAGE
int swift_reflection_projectEnumValue(SwiftReflectionContextRef ContextRef,
swift_addr_t EnumAddress,
swift_typeref_t EnumTypeRef,
int *CaseIndex);
/// Finds information about a particular enum case.
///
/// Given an enum typeref and index of a case, returns:
/// * Typeref of the associated payload or zero if there is no payload
/// * Name of the case if known.
///
/// The Name points to a freshly-allocated C string on the heap. You
/// are responsible for freeing the string when you are finished.
SWIFT_REMOTE_MIRROR_LINKAGE
int swift_reflection_getEnumCaseTypeRef(SwiftReflectionContextRef ContextRef,
swift_typeref_t EnumTypeRef,
int CaseIndex,
char **CaseName,
swift_typeref_t *PayloadTypeRef);
/// Dump a brief description of the typeref as a tree to stderr.
SWIFT_REMOTE_MIRROR_LINKAGE
void swift_reflection_dumpTypeRef(swift_typeref_t OpaqueTypeRef);

View File

@@ -30,6 +30,7 @@
#include <mach-o/getsect.h>
#include <CoreFoundation/CFDictionary.h>
#include <TargetConditionals.h>
/// The "public" interface follows. All of these functions are the same
/// as the corresponding swift_reflection_* functions, except for taking
@@ -535,12 +536,28 @@ swift_reflection_interop_minimalDataLayoutQueryFunction4(
void *ReaderContext,
DataLayoutQueryType type,
void *inBuffer, void *outBuffer) {
if (type == DLQ_GetPointerSize || type == DLQ_GetSizeSize) {
switch (type) {
case DLQ_GetPointerSize:
case DLQ_GetSizeSize: {
uint8_t *result = (uint8_t *)outBuffer;
*result = 4;
return 1;
}
return 0;
case DLQ_GetObjCReservedLowBits: {
uint8_t *result = (uint8_t *)outBuffer;
// Swift assumes this for all 32-bit platforms, including Darwin
*result = 0;
return 1;
}
case DLQ_GetLeastValidPointerValue: {
uint64_t *result = (uint64_t *)outBuffer;
// Swift assumes this for all 32-bit platforms, including Darwin
*result = 0x1000;
return 1;
}
default:
return 0;
}
}
static inline int
@@ -548,12 +565,49 @@ swift_reflection_interop_minimalDataLayoutQueryFunction8(
void *ReaderContext,
DataLayoutQueryType type,
void *inBuffer, void *outBuffer) {
if (type == DLQ_GetPointerSize || type == DLQ_GetSizeSize) {
// Caveat: This assumes the process being examined is
// running in the same kind of environment as this host code.
#if defined(__APPLE__) && __APPLE__
auto applePlatform = true;
#else
auto applePlatform = false;
#endif
#if defined(__APPLE__) && __APPLE__ && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_IOS) && TARGET_OS_WATCH) || (defined(TARGET_OS_TV) && TARGET_OS_TV))
auto iosDerivedPlatform = true;
#else
auto iosDerivedPlatform = false;
#endif
switch (type) {
case DLQ_GetPointerSize:
case DLQ_GetSizeSize: {
uint8_t *result = (uint8_t *)outBuffer;
*result = 8;
return 1;
}
return 0;
case DLQ_GetObjCReservedLowBits: {
uint8_t *result = (uint8_t *)outBuffer;
if (applePlatform && !iosDerivedPlatform) {
*result = 1;
} else {
*result = 0;
}
return 1;
}
case DLQ_GetLeastValidPointerValue: {
uint64_t *result = (uint64_t *)outBuffer;
if (applePlatform) {
// On 64-bit Apple platforms, Swift reserves the first 4GiB
*result = 0x100000000;
} else {
// Swift reserves the first 4KiB everywhere else.
*result = 0x1000;
}
return 1;
}
default:
return 0;
}
}
static inline SwiftReflectionInteropContextRef

View File

@@ -44,6 +44,8 @@ public enum InstanceKind : UInt8 {
case Existential
case ErrorExistential
case Closure
case Enum
case EnumValue
}
/// Represents a section in a loaded image in this process.
@@ -390,12 +392,12 @@ public func reflect(object: AnyObject) {
/// The test doesn't care about the witness tables - we only care
/// about what's in the buffer, so we always put these values into
/// an Any existential.
public func reflect<T>(any: T) {
public func reflect<T>(any: T, kind: InstanceKind = .Existential) {
let any: Any = any
let anyPointer = UnsafeMutablePointer<Any>.allocate(capacity: MemoryLayout<Any>.size)
anyPointer.initialize(to: any)
let anyPointerValue = UInt(bitPattern: anyPointer)
reflect(instanceAddress: anyPointerValue, kind: .Existential)
reflect(instanceAddress: anyPointerValue, kind: kind)
anyPointer.deallocate()
}
@@ -427,6 +429,18 @@ public func reflect<T: Error>(error: T) {
reflect(instanceAddress: errorPointerValue, kind: .ErrorExistential)
}
// Reflect an `Enum`
//
// These are handled like existentials, but
// the test driver verifies a different set of data.
public func reflect<T>(enum value: T) {
reflect(any: value, kind: .Enum)
}
public func reflect<T>(enumValue value: T) {
reflect(any: value, kind: .EnumValue)
}
/// Wraps a thick function with arity 0.
struct ThickFunction0 {
var function: () -> Void

View File

@@ -92,12 +92,36 @@ class PrintTypeInfo {
Indent -= 2;
}
void printCases(const RecordTypeInfo &TI) {
Indent += 2;
int Index = -1;
for (auto Field : TI.getFields()) {
Index += 1;
fprintf(file, "\n");
printHeader("case");
if (!Field.Name.empty())
printField("name", Field.Name);
printField("index", std::to_string(Index));
if (Field.TR) {
printField("offset", std::to_string(Field.Offset));
printRec(Field.TI);
}
fprintf(file, ")");
}
Indent -= 2;
}
public:
PrintTypeInfo(FILE *file, unsigned Indent)
: file(file), Indent(Indent) {}
void print(const TypeInfo &TI) {
switch (TI.getKind()) {
case TypeInfoKind::Invalid:
printHeader("invalid");
fprintf(file, ")");
return;
case TypeInfoKind::Builtin:
printHeader("builtin");
printBasic(TI);
@@ -115,13 +139,22 @@ public:
break;
case RecordKind::NoPayloadEnum:
printHeader("no_payload_enum");
break;
printBasic(TI);
printCases(RecordTI);
fprintf(file, ")");
return;
case RecordKind::SinglePayloadEnum:
printHeader("single_payload_enum");
break;
printBasic(TI);
printCases(RecordTI);
fprintf(file, ")");
return;
case RecordKind::MultiPayloadEnum:
printHeader("multi_payload_enum");
break;
printBasic(TI);
printCases(RecordTI);
fprintf(file, ")");
return;
case RecordKind::Tuple:
printHeader("tuple");
break;
@@ -200,6 +233,130 @@ BuiltinTypeInfo::BuiltinTypeInfo(TypeRefBuilder &builder,
builder.readTypeRef(descriptor, descriptor->TypeName)))
{}
bool
BuiltinTypeInfo::readExtraInhabitantIndex(remote::MemoryReader &reader,
remote::RemoteAddress address,
int *extraInhabitantIndex) const {
if (getNumExtraInhabitants() == 0) {
*extraInhabitantIndex = -1;
return true;
}
// If it has extra inhabitants, it must be a pointer. (The only non-pointer
// data with extra inhabitants is a non-payload enum, which doesn't get here.)
if (Name == "yyXf") {
// But there are two different conventions, one for function pointers:
return reader.readFunctionPointerExtraInhabitantIndex(address, extraInhabitantIndex);
} else {
// And one for pointers to heap-allocated blocks of memory
return reader.readHeapObjectExtraInhabitantIndex(address, extraInhabitantIndex);
}
}
bool RecordTypeInfo::readExtraInhabitantIndex(remote::MemoryReader &reader,
remote::RemoteAddress address,
int *extraInhabitantIndex) const {
switch (SubKind) {
case RecordKind::Invalid:
case RecordKind::ThickFunction:
case RecordKind::OpaqueExistential:
case RecordKind::ClosureContext:
return false;
case RecordKind::ClassExistential:
case RecordKind::ExistentialMetatype:
case RecordKind::ErrorExistential:
case RecordKind::ClassInstance: {
return false; // XXX TODO XXX
}
case RecordKind::Tuple:
case RecordKind::Struct: {
if (Fields.size() == 0) {
return false;
}
// Tuples and Structs inherit XIs from their most capacious member
auto mostCapaciousField = std::max_element(
Fields.begin(), Fields.end(),
[](const FieldInfo &lhs, const FieldInfo &rhs) {
return lhs.TI.getNumExtraInhabitants() < rhs.TI.getNumExtraInhabitants();
});
if (mostCapaciousField->TI.getNumExtraInhabitants() == 0) {
return false; // No child XIs? Something is broken.
}
auto fieldAddress = remote::RemoteAddress(address.getAddressData()
+ mostCapaciousField->Offset);
return mostCapaciousField->TI.readExtraInhabitantIndex(
reader, fieldAddress, extraInhabitantIndex);
}
case RecordKind::NoPayloadEnum: {
// No payload enums export XIs
auto EnumSize = getSize();
if (EnumSize == 0) {
*extraInhabitantIndex = -1;
return true;
}
uint64_t value;
if (!reader.readInteger(address, EnumSize, &value)) {
return false;
}
if (value < getFields().size()) {
*extraInhabitantIndex = -1;
} else {
*extraInhabitantIndex = value - getFields().size();
}
return true;
}
case RecordKind::SinglePayloadEnum: {
// Single payload enums inherit XIs from their payload type
auto Fields = getFields();
FieldInfo PayloadCase = Fields[0];
if (!PayloadCase.TR)
return false;
unsigned long NonPayloadCaseCount = Fields.size() - 1;
unsigned long PayloadExtraInhabitants = PayloadCase.TI.getNumExtraInhabitants();
unsigned discriminator = 0;
auto PayloadSize = PayloadCase.TI.getSize();
if (NonPayloadCaseCount >= PayloadExtraInhabitants) {
// More cases than inhabitants, we need a separate discriminator
auto TagInfo = getEnumTagCounts(PayloadSize, NonPayloadCaseCount, 1);
auto TagSize = TagInfo.numTagBytes;
auto TagAddress = remote::RemoteAddress(address.getAddressData() + PayloadSize);
if (!reader.readInteger(TagAddress, TagSize, &discriminator))
return false;
}
if (PayloadExtraInhabitants == 0) {
*extraInhabitantIndex = -1;
return true;
} else if (discriminator == 0) {
if (PayloadCase.TI.readExtraInhabitantIndex(reader, address, extraInhabitantIndex)) {
if (*extraInhabitantIndex < 0) {
// Do nothing.
} else if ((unsigned long)*extraInhabitantIndex < NonPayloadCaseCount) {
*extraInhabitantIndex = -1;
} else {
*extraInhabitantIndex -= NonPayloadCaseCount;
}
return true;
}
} else {
*extraInhabitantIndex = -1; // XXX CHECK THIS XXX
return true;
}
return false;
}
case RecordKind::MultiPayloadEnum:// XXX TODO
return false;
}
return false;
}
/// Utility class for building values that contain witness tables.
class ExistentialTypeInfoBuilder {
TypeConverter &TC;
@@ -537,7 +694,7 @@ void RecordTypeInfoBuilder::addField(const std::string &Name,
TI->getAlignment(),
TI->getNumExtraInhabitants(),
TI->isBitwiseTakable());
Fields.push_back({Name, offset, TR, *TI});
Fields.push_back({Name, offset, -1, TR, *TI});
}
const RecordTypeInfo *RecordTypeInfoBuilder::build() {
@@ -612,7 +769,7 @@ TypeConverter::getReferenceTypeInfo(ReferenceKind Kind,
return TI;
}
/// Thick functions consist of a function pointer. We do not use
/// Thin functions consist of a function pointer. We do not use
/// Builtin.RawPointer here, since the extra inhabitants differ.
const TypeInfo *
TypeConverter::getThinFunctionTypeInfo() {
@@ -963,6 +1120,10 @@ class EnumTypeInfoBuilder {
return Case.TR;
}
void addCase(const std::string &Name) {
Cases.push_back({Name, /*offset=*/0, /*value=*/-1, nullptr, TypeInfo()});
}
void addCase(const std::string &Name, const TypeRef *TR,
const TypeInfo *TI) {
if (TI == nullptr) {
@@ -975,7 +1136,7 @@ class EnumTypeInfoBuilder {
Alignment = std::max(Alignment, TI->getAlignment());
BitwiseTakable &= TI->isBitwiseTakable();
Cases.push_back({Name, /*offset=*/0, TR, *TI});
Cases.push_back({Name, /*offset=*/0, /*value=*/-1, TR, *TI});
}
public:
@@ -998,14 +1159,17 @@ public:
for (auto Case : Fields) {
if (Case.TR == nullptr) {
NoPayloadCases++;
continue;
addCase(Case.Name);
} else {
PayloadCases.push_back(Case);
auto *CaseTR = getCaseTypeRef(Case);
auto *CaseTI = TC.getTypeInfo(CaseTR);
addCase(Case.Name, CaseTR, CaseTI);
}
PayloadCases.push_back(Case);
}
// NoPayloadEnumImplStrategy
if (PayloadCases.empty()) {
// NoPayloadEnumImplStrategy
Kind = RecordKind::NoPayloadEnum;
switch (NoPayloadCases) {
case 0:
@@ -1017,14 +1181,15 @@ public:
NoPayloadCases,
/*payloadCases=*/0);
Size += tagCounts.numTagBytes;
Alignment = tagCounts.numTagBytes;
NumExtraInhabitants =
(1 << (tagCounts.numTagBytes * 8)) - tagCounts.numTags;
NumExtraInhabitants = std::min(NumExtraInhabitants,
unsigned(ValueWitnessFlags::MaxNumExtraInhabitants));
}
}
// SinglePayloadEnumImplStrategy
} else if (PayloadCases.size() == 1) {
// SinglePayloadEnumImplStrategy
auto *CaseTR = getCaseTypeRef(PayloadCases[0]);
auto *CaseTI = TC.getTypeInfo(CaseTR);
@@ -1034,37 +1199,33 @@ public:
return CaseTI;
Kind = RecordKind::SinglePayloadEnum;
addCase(PayloadCases[0].Name, CaseTR, CaseTI);
// If we were unable to lower the payload type, do not proceed
// further.
if (CaseTI != nullptr) {
// Below logic should match the runtime function
// swift_initEnumMetadataSinglePayload().
NumExtraInhabitants = CaseTI->getNumExtraInhabitants();
if (NumExtraInhabitants >= NoPayloadCases) {
auto PayloadExtraInhabitants = CaseTI->getNumExtraInhabitants();
if (PayloadExtraInhabitants >= NoPayloadCases) {
// Extra inhabitants can encode all no-payload cases.
NumExtraInhabitants -= NoPayloadCases;
NumExtraInhabitants = PayloadExtraInhabitants - NoPayloadCases;
} else {
// Not enough extra inhabitants for all cases. We have to add an
// extra tag field.
NumExtraInhabitants = 0;
Size += getEnumTagCounts(Size,
NoPayloadCases - NumExtraInhabitants,
/*payloadCases=*/1).numTagBytes;
auto tagCounts = getEnumTagCounts(Size,
NoPayloadCases - NumExtraInhabitants,
/*payloadCases=*/1);
Size += tagCounts.numTagBytes;
Alignment = std::max(Alignment, tagCounts.numTagBytes);
}
}
// MultiPayloadEnumImplStrategy
} else {
// MultiPayloadEnumImplStrategy
Kind = RecordKind::MultiPayloadEnum;
// Check if this is a dynamic or static multi-payload enum
for (auto Case : PayloadCases) {
auto *CaseTR = getCaseTypeRef(Case);
auto *CaseTI = TC.getTypeInfo(CaseTR);
addCase(Case.Name, CaseTR, CaseTI);
}
// If we have a fixed descriptor for this type, it is a fixed-size
// multi-payload enum that possibly uses payload spare bits.
@@ -1103,9 +1264,8 @@ public:
Stride = 1;
return TC.makeTypeInfo<RecordTypeInfo>(
Size, Alignment, Stride,
NumExtraInhabitants, BitwiseTakable,
Kind, Cases);
Size, Alignment, Stride, NumExtraInhabitants,
BitwiseTakable, Kind, Cases);
}
};
@@ -1323,7 +1483,7 @@ public:
if (Field.Name == "object") {
auto *FieldTI = rebuildStorageTypeInfo(&Field.TI, Kind);
BitwiseTakable &= FieldTI->isBitwiseTakable();
Fields.push_back({Field.Name, Field.Offset, Field.TR, *FieldTI});
Fields.push_back({Field.Name, Field.Offset, /*value=*/-1, Field.TR, *FieldTI});
continue;
}
Fields.push_back(Field);

View File

@@ -211,14 +211,16 @@ bool TypeRefBuilder::getFieldTypeRefs(
if (!Subs)
return false;
int FieldValue = -1;
for (auto &FieldRef : *FD.getLocalBuffer()) {
auto Field = FD.getField(FieldRef);
auto FieldName = getTypeRefString(readTypeRef(Field, Field->FieldName));
FieldValue += 1;
// Empty cases of enums do not have a type
if (FD->isEnum() && !Field->hasMangledTypeName()) {
Fields.push_back(FieldTypeInfo::forEmptyCase(FieldName));
Fields.push_back(FieldTypeInfo::forEmptyCase(FieldName, FieldValue));
continue;
}
@@ -230,11 +232,11 @@ bool TypeRefBuilder::getFieldTypeRefs(
auto Substituted = Unsubstituted->subst(*this, *Subs);
if (FD->isEnum() && Field->isIndirectCase()) {
Fields.push_back(FieldTypeInfo::forIndirectCase(FieldName, Substituted));
Fields.push_back(FieldTypeInfo::forIndirectCase(FieldName, FieldValue, Substituted));
continue;
}
Fields.push_back(FieldTypeInfo::forField(FieldName, Substituted));
Fields.push_back(FieldTypeInfo::forField(FieldName, FieldValue, Substituted));
}
return true;
}

View File

@@ -25,6 +25,10 @@ unsigned long long swift_reflection_classIsSwiftMask = 2;
#include "swift/Remote/CMemoryReader.h"
#include "swift/Runtime/Unreachable.h"
#if defined(__APPLE__) && defined(__MACH__)
#include <TargetConditionals.h>
#endif
using namespace swift;
using namespace swift::reflection;
using namespace swift::remote;
@@ -59,14 +63,55 @@ template <uint8_t WordSize>
static int minimalDataLayoutQueryFunction(void *ReaderContext,
DataLayoutQueryType type,
void *inBuffer, void *outBuffer) {
// TODO: The following should be set based on the target.
// This code sets it to match the platform this code was compiled for.
#if defined(__APPLE__) && __APPLE__
auto applePlatform = true;
#else
auto applePlatform = false;
#endif
#if defined(__APPLE__) && __APPLE__ && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_IOS) && TARGET_OS_WATCH) || (defined(TARGET_OS_TV) && TARGET_OS_TV))
auto iosDerivedPlatform = true;
#else
auto iosDerivedPlatform = false;
#endif
if (type == DLQ_GetPointerSize || type == DLQ_GetSizeSize) {
auto result = static_cast<uint8_t *>(outBuffer);
*result = WordSize;
return 1;
}
if (type == DLQ_GetObjCReservedLowBits) {
auto result = static_cast<uint8_t *>(outBuffer);
if (applePlatform && !iosDerivedPlatform && WordSize == 8) {
// Obj-C reserves low bit on 64-bit macOS only.
// Other Apple platforms don't reserve this bit (even when
// running on x86_64-based simulators).
*result = 1;
} else {
*result = 0;
}
return 1;
}
if (type == DLQ_GetLeastValidPointerValue) {
auto result = static_cast<uint64_t *>(outBuffer);
if (applePlatform && WordSize == 8) {
// Swift reserves the first 4GiB on all 64-bit Apple platforms
*result = 0x100000000;
} else {
// Swift reserves the first 4KiB everywhere else
*result = 0x1000;
}
return 1;
}
return 0;
}
// Caveat: This basically only works correctly if running on the same
// host as the target. Otherwise, you'll need to use
// swift_reflection_createReflectionContextWithDataLayout() below
// with an appropriate data layout query function that understands
// the target environment.
SwiftReflectionContextRef
swift_reflection_createReflectionContext(void *ReaderContext,
uint8_t PointerSize,
@@ -251,6 +296,9 @@ swift_reflection_genericArgumentCountOfTypeRef(swift_typeref_t OpaqueTypeRef) {
swift_layout_kind_t getTypeInfoKind(const TypeInfo &TI) {
switch (TI.getKind()) {
case TypeInfoKind::Invalid: {
return SWIFT_UNKNOWN;
}
case TypeInfoKind::Builtin: {
auto &BuiltinTI = cast<BuiltinTypeInfo>(TI);
if (BuiltinTI.getMangledTypeName() == "Bp")
@@ -414,6 +462,39 @@ int swift_reflection_projectExistential(SwiftReflectionContextRef ContextRef,
return Success;
}
int swift_reflection_projectEnumValue(SwiftReflectionContextRef ContextRef,
swift_addr_t EnumAddress,
swift_typeref_t EnumTypeRef,
int *CaseIndex) {
auto Context = ContextRef->nativeContext;
auto EnumTR = reinterpret_cast<const TypeRef *>(EnumTypeRef);
auto RemoteEnumAddress = RemoteAddress(EnumAddress);
return Context->projectEnumValue(RemoteEnumAddress, EnumTR, CaseIndex);
}
int swift_reflection_getEnumCaseTypeRef(SwiftReflectionContextRef ContextRef,
swift_typeref_t EnumTypeRef,
int CaseIndex,
char **CaseName,
swift_typeref_t *PayloadTypeRef) {
*PayloadTypeRef = 0;
*CaseName = nullptr;
auto Context = ContextRef->nativeContext;
auto EnumTR = reinterpret_cast<const TypeRef *>(EnumTypeRef);
const TypeRef *PayloadTR = nullptr;
std::string Name;
auto success = Context->getEnumCaseTypeRef(EnumTR, CaseIndex,
Name, &PayloadTR);
if (success) {
*PayloadTypeRef = reinterpret_cast<swift_typeref_t>(PayloadTR);
// FIXME: Is there a better way to return a string here?
// Just returning Case.Name.c_str() doesn't work as the backing data gets
// released at the end of this function.
*CaseName = strdup(Name.c_str());
}
return success;
}
void swift_reflection_dumpTypeRef(swift_typeref_t OpaqueTypeRef) {
auto TR = reinterpret_cast<const TypeRef *>(OpaqueTypeRef);
if (TR == nullptr) {

View File

@@ -25,5 +25,7 @@ typedef enum InstanceKind {
Object,
Existential,
ErrorExistential,
Closure
Closure,
Enum,
EnumValue
} InstanceKind;

View File

@@ -34,6 +34,10 @@
#include <fcntl.h>
#endif
#if defined(__APPLE__) && defined(__MACH__)
#include <TargetConditionals.h>
#endif
#if defined(__clang__) || defined(__GNUC__)
#define NORETURN __attribute__((noreturn))
#elif defined(_MSC_VER)
@@ -134,6 +138,17 @@ void PipeMemoryReader_collectBytesFromPipe(const PipeMemoryReader *Reader,
static int PipeMemoryReader_queryDataLayout(void *Context,
DataLayoutQueryType type,
void *inBuffer, void *outBuffer) {
#if defined(__APPLE__) && __APPLE__
int applePlatform = 1;
#else
int applePlatform = 0;
#endif
#if defined(__APPLE__) && __APPLE__ && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_IOS) && TARGET_OS_WATCH) || (defined(TARGET_OS_TV) && TARGET_OS_TV))
int iosDerivedPlatform = 1;
#else
int iosDerivedPlatform = 0;
#endif
switch (type) {
case DLQ_GetPointerSize: {
uint8_t *result = (uint8_t *)outBuffer;
@@ -145,6 +160,28 @@ static int PipeMemoryReader_queryDataLayout(void *Context,
*result = sizeof(size_t);
return 1;
}
case DLQ_GetObjCReservedLowBits: {
uint8_t *result = (uint8_t *)outBuffer;
if (applePlatform && !iosDerivedPlatform && (sizeof(void *) == 8)) {
// Only for 64-bit macOS (not iOS, not even when simulated on x86_64)
*result = 1;
} else {
*result = 0;
}
return 1;
}
case DLQ_GetLeastValidPointerValue: {
uint64_t *result = (uint64_t *)outBuffer;
if (applePlatform && (sizeof(void *) == 8)) {
// Swift reserves the first 4GiB on Apple 64-bit platforms
*result = 0x100000000;
return 1;
} else {
// Swift reserves the first 4KiB everywhere else
*result = 0x1000;
}
return 1;
}
}
return 0;
@@ -478,6 +515,162 @@ int reflectExistential(SwiftReflectionContextRef RC,
return 1;
}
int reflectEnum(SwiftReflectionContextRef RC,
const PipeMemoryReader Pipe) {
static const char Name[] = MANGLING_PREFIX_STR "ypD";
swift_typeref_t AnyTR
= swift_reflection_typeRefForMangledTypeName(
RC, Name, sizeof(Name)-1);
uintptr_t AnyInstance = PipeMemoryReader_receiveInstanceAddress(&Pipe);
if (AnyInstance == 0) {
// Child has no more instances to examine
PipeMemoryReader_sendDoneMessage(&Pipe);
return 0;
}
swift_typeref_t EnumTypeRef;
swift_addr_t EnumInstance = 0;
if (!swift_reflection_projectExistential(RC, AnyInstance, AnyTR,
&EnumTypeRef,
&EnumInstance)) {
printf("swift_reflection_projectExistential failed.\n");
PipeMemoryReader_sendDoneMessage(&Pipe);
return 0;
}
printf("Instance pointer in child address space: 0x%lx\n",
(uintptr_t)EnumInstance);
printf("Type reference:\n");
swift_reflection_dumpTypeRef(EnumTypeRef);
printf("\n");
printf("Type info:\n");
swift_reflection_dumpInfoForTypeRef(RC, EnumTypeRef);
printf("\n");
printf("Enum value:\n");
swift_typeinfo_t InstanceTypeInfo = swift_reflection_infoForTypeRef(RC, EnumTypeRef);
if (InstanceTypeInfo.Kind != SWIFT_NO_PAYLOAD_ENUM
&& InstanceTypeInfo.Kind != SWIFT_SINGLE_PAYLOAD_ENUM
&& InstanceTypeInfo.Kind != SWIFT_MULTI_PAYLOAD_ENUM) {
// Enums with a single payload case and no non-payload cases
// can get rewritten by the compiler to just the payload
// type.
swift_reflection_dumpInfoForTypeRef(RC, EnumTypeRef);
PipeMemoryReader_sendDoneMessage(&Pipe);
return 1;
}
int CaseIndex;
if (!swift_reflection_projectEnumValue(RC, EnumInstance, EnumTypeRef, &CaseIndex)) {
printf("swift_reflection_projectEnumValue failed.\n\n");
PipeMemoryReader_sendDoneMessage(&Pipe);
return 1; // <<< Test cases also verify failures, so this must "succeed"
}
char *CaseName = NULL;
swift_typeref_t PayloadTypeRef = 0;
if (!swift_reflection_getEnumCaseTypeRef(RC, EnumTypeRef, CaseIndex, &CaseName, &PayloadTypeRef)) {
printf("swift_reflection_getEnumCaseTypeRef failed.\n");
PipeMemoryReader_sendDoneMessage(&Pipe);
return 0;
}
if (PayloadTypeRef == 0) {
// Enum case has no payload
printf("(enum_value name=%s index=%llu)\n",
CaseName, (unsigned long long)CaseIndex);
} else {
printf("(enum_value name=%s index=%llu\n",
CaseName, (unsigned long long)CaseIndex);
swift_reflection_dumpTypeRef(PayloadTypeRef);
printf(")\n");
}
printf("\n");
// FIXME: Is there a better idiom for handling the returned case name?
free(CaseName);
PipeMemoryReader_sendDoneMessage(&Pipe);
return 1;
}
int reflectEnumValue(SwiftReflectionContextRef RC,
const PipeMemoryReader Pipe) {
static const char Name[] = MANGLING_PREFIX_STR "ypD";
swift_typeref_t AnyTR
= swift_reflection_typeRefForMangledTypeName(
RC, Name, sizeof(Name)-1);
uintptr_t AnyInstance = PipeMemoryReader_receiveInstanceAddress(&Pipe);
if (AnyInstance == 0) {
// Child has no more instances to examine
PipeMemoryReader_sendDoneMessage(&Pipe);
return 0;
}
swift_typeref_t EnumTypeRef;
swift_addr_t EnumInstance = 0;
if (!swift_reflection_projectExistential(RC, AnyInstance, AnyTR,
&EnumTypeRef,
&EnumInstance)) {
printf("swift_reflection_projectExistential failed.\n");
PipeMemoryReader_sendDoneMessage(&Pipe);
return 0;
}
printf("Type reference:\n");
swift_reflection_dumpTypeRef(EnumTypeRef);
printf("Value: ");
int parens = 0;
while (EnumTypeRef != 0) {
swift_typeinfo_t EnumTypeInfo = swift_reflection_infoForTypeRef(RC, EnumTypeRef);
if (EnumTypeInfo.Kind != SWIFT_NO_PAYLOAD_ENUM
&& EnumTypeInfo.Kind != SWIFT_SINGLE_PAYLOAD_ENUM
&& EnumTypeInfo.Kind != SWIFT_MULTI_PAYLOAD_ENUM) {
if (parens == 0) {
printf(".??"); // Enum was optimized away, print "something"
} else {
printf("_");
}
break;
}
int CaseIndex;
if (!swift_reflection_projectEnumValue(RC, EnumInstance, EnumTypeRef, &CaseIndex)) {
printf("swift_reflection_projectEnumValue failed.\n\n");
PipeMemoryReader_sendDoneMessage(&Pipe);
return 1; // <<< Test cases rely on detecting this, so must "succeed"
}
char *CaseName = NULL;
swift_typeref_t PayloadTypeRef = 0;
if (!swift_reflection_getEnumCaseTypeRef(RC, EnumTypeRef, CaseIndex,
&CaseName, &PayloadTypeRef)) {
printf("swift_reflection_getEnumCaseTypeRef failed.\n");
PipeMemoryReader_sendDoneMessage(&Pipe);
return 0;
}
printf(".%s", CaseName);
// FIXME: Is there a better idiom for handling the returned case name?
free(CaseName);
EnumTypeRef = PayloadTypeRef;
if (EnumTypeRef != 0) {
printf("(");
parens += 1;
}
}
for (int i = 0; i < parens; ++i) {
printf(")");
}
printf("\n\n");
PipeMemoryReader_sendDoneMessage(&Pipe);
return 1;
}
int doDumpHeapInstance(const char *BinaryFilename) {
PipeMemoryReader Pipe = createPipeMemoryReader();
@@ -549,6 +742,18 @@ int doDumpHeapInstance(const char *BinaryFilename) {
if (!reflectHeapObject(RC, Pipe))
return EXIT_SUCCESS;
break;
case Enum: {
printf("Reflecting an enum.\n");
if (!reflectEnum(RC, Pipe))
return EXIT_SUCCESS;
break;
}
case EnumValue: {
printf("Reflecting an enum value.\n");
if (!reflectEnumValue(RC, Pipe))
return EXIT_SUCCESS;
break;
}
case None:
swift_reflection_destroyReflectionContext(RC);
printf("Done.\n");

View File

@@ -405,8 +405,9 @@
// CHECK-64-NEXT: (reference kind=strong refcounting=native))
// CHECK-64-NEXT: (field name=optionalStrongRef offset=8
// CHECK-64-NEXT: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI_SUB_1:2047|4095|2147483646]] bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=native))))
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=native))
// CHECK-64-NEXT: (case name=none index=1)))
// CHECK-64-NEXT: (field name=strongRefTuple offset=16
// CHECK-64-NEXT: (tuple size=16 alignment=8 stride=16 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field offset=0
@@ -415,12 +416,13 @@
// CHECK-64-NEXT: (reference kind=strong refcounting=native))))
// CHECK-64-NEXT: (field name=optionalStrongRefTuple offset=32
// CHECK-64-NEXT: (single_payload_enum size=16 alignment=8 stride=16 num_extra_inhabitants=[[PTR_XI_SUB_1]] bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (tuple size=16 alignment=8 stride=16 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=native))
// CHECK-64-NEXT: (field offset=8
// CHECK-64-NEXT: (reference kind=strong refcounting=native)))))))
// CHECK-64-NEXT: (reference kind=strong refcounting=native))))
// CHECK-64-NEXT: (case name=none index=1))))
// CHECK-32: (struct TypeLowering.ReferenceStruct)
// CHECK-32-NEXT: (struct size=24 alignment=4 stride=24 num_extra_inhabitants=4096 bitwise_takable=1
@@ -428,8 +430,9 @@
// CHECK-32-NEXT: (reference kind=strong refcounting=native))
// CHECK-32-NEXT: (field name=optionalStrongRef offset=4
// CHECK-32-NEXT: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (field name=some offset=0
// CHECK-32-NEXT: (reference kind=strong refcounting=native))))
// CHECK-32-NEXT: (case name=some index=0 offset=0
// CHECK-32-NEXT: (reference kind=strong refcounting=native))
// CHECK-32-NEXT: (case name=none index=1)))
// CHECK-32-NEXT: (field name=strongRefTuple offset=8
// CHECK-32-NEXT: (tuple size=8 alignment=4 stride=8 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field offset=0
@@ -438,12 +441,13 @@
// CHECK-32-NEXT: (reference kind=strong refcounting=native))))
// CHECK-32-NEXT: (field name=optionalStrongRefTuple offset=16
// CHECK-32-NEXT: (single_payload_enum size=8 alignment=4 stride=8 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (field name=some offset=0
// CHECK-32-NEXT: (case name=some index=0 offset=0
// CHECK-32-NEXT: (tuple size=8 alignment=4 stride=8 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field offset=0
// CHECK-32-NEXT: (reference kind=strong refcounting=native))
// CHECK-32-NEXT: (field offset=4
// CHECK-32-NEXT: (reference kind=strong refcounting=native)))))))
// CHECK-32-NEXT: (reference kind=strong refcounting=native))))
// CHECK-32-NEXT: (case name=none index=1))))
12TypeLowering22UnownedReferenceStructV
// CHECK-64: (struct TypeLowering.UnownedReferenceStruct)
@@ -489,24 +493,27 @@
// CHECK-64-NEXT: (reference kind=strong refcounting=native))))
// CHECK-64-NEXT: (field name=optionalThickFunction offset=16
// CHECK-64-NEXT: (single_payload_enum size=16 alignment=8 stride=16 num_extra_inhabitants=[[PTR_XI_2_SUB_1:4095|2147483646]] bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (thick_function size=16 alignment=8 stride=16 num_extra_inhabitants=[[PTR_XI_2]] bitwise_takable=1
// CHECK-64-NEXT: (field name=function offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI_2]] bitwise_takable=1))
// CHECK-64-NEXT: (field name=context offset=8
// CHECK-64-NEXT: (reference kind=strong refcounting=native))))))
// CHECK-64-NEXT: (reference kind=strong refcounting=native))))
// CHECK-64-NEXT: (case name=none index=1)))
// CHECK-64-NEXT: (field name=thinFunction offset=32
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI_2]] bitwise_takable=1))
// CHECK-64-NEXT: (field name=optionalThinFunction offset=40
// CHECK-64-NEXT: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI_2_SUB_1]] bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI_2]] bitwise_takable=1))))
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI_2]] bitwise_takable=1))
// CHECK-64-NEXT: (case name=none index=1)))
// CHECK-64-NEXT: (field name=cFunction offset=48
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI_2]] bitwise_takable=1))
// CHECK-64-NEXT: (field name=optionalCFunction offset=56
// CHECK-64-NEXT: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI_2_SUB_1]] bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI_2]] bitwise_takable=1)))))
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI_2]] bitwise_takable=1))
// CHECK-64-NEXT: (case name=none index=1))))
// CHECK-32: (struct TypeLowering.FunctionStruct)
// CHECK-32-NEXT: (struct size=32 alignment=4 stride=32 num_extra_inhabitants=4096 bitwise_takable=1
@@ -518,24 +525,27 @@
// CHECK-32-NEXT: (reference kind=strong refcounting=native))))
// CHECK-32-NEXT: (field name=optionalThickFunction offset=8
// CHECK-32-NEXT: (single_payload_enum size=8 alignment=4 stride=8 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (field name=some offset=0
// CHECK-32-NEXT: (case name=some index=0 offset=0
// CHECK-32-NEXT: (thick_function size=8 alignment=4 stride=8 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=function offset=0
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))
// CHECK-32-NEXT: (field name=context offset=4
// CHECK-32-NEXT: (reference kind=strong refcounting=native))))))
// CHECK-32-NEXT: (reference kind=strong refcounting=native))))
// CHECK-32-NEXT: (case name=none index=1)))
// CHECK-32-NEXT: (field name=thinFunction offset=16
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))
// CHECK-32-NEXT: (field name=optionalThinFunction offset=20
// CHECK-32-NEXT: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (field name=some offset=0
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))))
// CHECK-32-NEXT: (case name=some index=0 offset=0
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))
// CHECK-32-NEXT: (case name=none index=1)))
// CHECK-32-NEXT: (field name=cFunction offset=24
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))
// CHECK-32-NEXT: (field name=optionalCFunction offset=28
// CHECK-32-NEXT: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (field name=some offset=0
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1)))))
// CHECK-32-NEXT: (case name=some index=0 offset=0
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))
// CHECK-32-NEXT: (case name=none index=1))))
12TypeLowering17ExistentialStructV
// CHECK-64: (struct TypeLowering.ExistentialStruct)
@@ -546,20 +556,22 @@
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1))))
// CHECK-64-NEXT: (field name=optionalAny offset=32
// CHECK-64-NEXT: (single_payload_enum size=32 alignment=8 stride=32 num_extra_inhabitants=[[PTR_XI_SUB_1]] bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (opaque_existential size=32 alignment=8 stride=32 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=metadata offset=24
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1))))))
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1))))
// CHECK-64-NEXT: (case name=none index=1)))
// CHECK-64-NEXT: (field name=anyObject offset=64
// CHECK-64-NEXT: (class_existential size=8 alignment=8 stride=8
// CHECK-64-NEXT: (field name=object offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=unknown))))
// CHECK-64-NEXT: (field name=optionalAnyObject offset=72
// CHECK-64-NEXT: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI_SUB_1]] bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (class_existential size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=object offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=unknown))))))
// CHECK-64-NEXT: (reference kind=strong refcounting=unknown))))
// CHECK-64-NEXT: (case name=none index=1)))
// CHECK-64-NEXT: (field name=anyProto offset=80
// CHECK-64-NEXT: (opaque_existential size=40 alignment=8 stride=40 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=metadata offset=24
@@ -568,12 +580,13 @@
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-64-NEXT: (field name=optionalAnyProto offset=120
// CHECK-64-NEXT: (single_payload_enum size=40 alignment=8 stride=40 num_extra_inhabitants=[[PTR_XI_SUB_1]] bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (opaque_existential size=40 alignment=8 stride=40 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=metadata offset=24
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1))
// CHECK-64-NEXT: (field name=wtable offset=32
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))))
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-64-NEXT: (case name=none index=1)))
// CHECK-64-NEXT: (field name=anyProtoComposition offset=160
// CHECK-64-NEXT: (opaque_existential size=48 alignment=8 stride=48 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=metadata offset=24
@@ -584,14 +597,15 @@
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-64-NEXT: (field name=optionalAnyProtoComposition offset=208
// CHECK-64-NEXT: (single_payload_enum size=48 alignment=8 stride=48 num_extra_inhabitants=[[PTR_XI_SUB_1]] bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (opaque_existential size=48 alignment=8 stride=48 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=metadata offset=24
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1))
// CHECK-64-NEXT: (field name=wtable offset=32
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))
// CHECK-64-NEXT: (field name=wtable offset=40
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))))
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-64-NEXT: (case name=none index=1)))
// CHECK-64-NEXT: (field name=anyClassBoundProto1 offset=256
// CHECK-64-NEXT: (class_existential size=16 alignment=8 stride=16 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=object offset=0
@@ -600,12 +614,13 @@
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-64-NEXT: (field name=optionalAnyClassBoundProto1 offset=272
// CHECK-64-NEXT: (single_payload_enum size=16 alignment=8 stride=16 num_extra_inhabitants=[[PTR_XI_SUB_1]] bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (class_existential size=16 alignment=8 stride=16 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=object offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=unknown))
// CHECK-64-NEXT: (field name=wtable offset=8
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))))
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-64-NEXT: (case name=none index=1)))
// CHECK-64-NEXT: (field name=anyClassBoundProto2 offset=288
// CHECK-64-NEXT: (class_existential size=16 alignment=8 stride=16 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=object offset=0
@@ -614,12 +629,13 @@
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-64-NEXT: (field name=optionalAnyClassBoundProto2 offset=304
// CHECK-64-NEXT: (single_payload_enum size=16 alignment=8 stride=16 num_extra_inhabitants=[[PTR_XI_SUB_1]] bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (class_existential size=16 alignment=8 stride=16 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=object offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=unknown))
// CHECK-64-NEXT: (field name=wtable offset=8
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))))
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-64-NEXT: (case name=none index=1)))
// CHECK-64-NEXT: (field name=anyClassBoundProtoComposition1 offset=320
// CHECK-64-NEXT: (class_existential size=16 alignment=8 stride=16 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=object offset=0
@@ -628,12 +644,13 @@
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-64-NEXT: (field name=optionalAnyClassBoundProtoComposition1 offset=336
// CHECK-64-NEXT: (single_payload_enum size=16 alignment=8 stride=16 num_extra_inhabitants=[[PTR_XI_SUB_1]] bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (class_existential size=16 alignment=8 stride=16 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=object offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=unknown))
// CHECK-64-NEXT: (field name=wtable offset=8
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))))
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-64-NEXT: (case name=none index=1)))
// CHECK-64-NEXT: (field name=anyClassBoundProtoComposition2 offset=352
// CHECK-64-NEXT: (class_existential size=24 alignment=8 stride=24 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=object offset=0
@@ -644,14 +661,15 @@
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-64-NEXT: (field name=optionalAnyClassBoundProtoComposition2 offset=376
// CHECK-64-NEXT: (single_payload_enum size=24 alignment=8 stride=24 num_extra_inhabitants=[[PTR_XI_SUB_1]] bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (class_existential size=24 alignment=8 stride=24 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=object offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=unknown))
// CHECK-64-NEXT: (field name=wtable offset=8
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))
// CHECK-64-NEXT: (field name=wtable offset=16
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))))
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-64-NEXT: (case name=none index=1)))
// CHECK-64-NEXT: (field name=classConstrainedP1 offset=400
// CHECK-64-NEXT: (class_existential size=16 alignment=8 stride=16 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=object offset=0
@@ -667,20 +685,22 @@
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))))
// CHECK-32-NEXT: (field name=optionalAny offset=16
// CHECK-32-NEXT: (single_payload_enum size=16 alignment=4 stride=16 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (field name=some offset=0
// CHECK-32-NEXT: (case name=some index=0 offset=0
// CHECK-32-NEXT: (opaque_existential size=16 alignment=4 stride=16 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=metadata offset=12
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))))))
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))))
// CHECK-32-NEXT: (case name=none index=1)))
// CHECK-32-NEXT: (field name=anyObject offset=32
// CHECK-32-NEXT: (class_existential size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=object offset=0
// CHECK-32-NEXT: (reference kind=strong refcounting=unknown))))
// CHECK-32-NEXT: (field name=optionalAnyObject offset=36
// CHECK-32-NEXT: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (field name=some offset=0
// CHECK-32-NEXT: (case name=some index=0 offset=0
// CHECK-32-NEXT: (class_existential size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=object offset=0
// CHECK-32-NEXT: (reference kind=strong refcounting=unknown))))))
// CHECK-32-NEXT: (reference kind=strong refcounting=unknown))))
// CHECK-32-NEXT: (case name=none index=1)))
// CHECK-32-NEXT: (field name=anyProto offset=40
// CHECK-32-NEXT: (opaque_existential size=20 alignment=4 stride=20 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=metadata offset=12
@@ -689,12 +709,13 @@
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-32-NEXT: (field name=optionalAnyProto offset=60
// CHECK-32-NEXT: (single_payload_enum size=20 alignment=4 stride=20 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (field name=some offset=0
// CHECK-32-NEXT: (case name=some index=0 offset=0
// CHECK-32-NEXT: (opaque_existential size=20 alignment=4 stride=20 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=metadata offset=12
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))
// CHECK-32-NEXT: (field name=wtable offset=16
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))))
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-32-NEXT: (case name=none index=1)))
// CHECK-32-NEXT: (field name=anyProtoComposition offset=80
// CHECK-32-NEXT: (opaque_existential size=24 alignment=4 stride=24 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=metadata offset=12
@@ -705,14 +726,15 @@
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-32-NEXT: (field name=optionalAnyProtoComposition offset=104
// CHECK-32-NEXT: (single_payload_enum size=24 alignment=4 stride=24 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (field name=some offset=0
// CHECK-32-NEXT: (case name=some index=0 offset=0
// CHECK-32-NEXT: (opaque_existential size=24 alignment=4 stride=24 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=metadata offset=12
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))
// CHECK-32-NEXT: (field name=wtable offset=16
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))
// CHECK-32-NEXT: (field name=wtable offset=20
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))))
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-32-NEXT: (case name=none index=1)))
// CHECK-32-NEXT: (field name=anyClassBoundProto1 offset=128
// CHECK-32-NEXT: (class_existential size=8 alignment=4 stride=8 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=object offset=0
@@ -721,12 +743,13 @@
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-32-NEXT: (field name=optionalAnyClassBoundProto1 offset=136
// CHECK-32-NEXT: (single_payload_enum size=8 alignment=4 stride=8 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (field name=some offset=0
// CHECK-32-NEXT: (case name=some index=0 offset=0
// CHECK-32-NEXT: (class_existential size=8 alignment=4 stride=8 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=object offset=0
// CHECK-32-NEXT: (reference kind=strong refcounting=unknown))
// CHECK-32-NEXT: (field name=wtable offset=4
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))))
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-32-NEXT: (case name=none index=1)))
// CHECK-32-NEXT: (field name=anyClassBoundProto2 offset=144
// CHECK-32-NEXT: (class_existential size=8 alignment=4 stride=8 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=object offset=0
@@ -735,12 +758,13 @@
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-32-NEXT: (field name=optionalAnyClassBoundProto2 offset=152
// CHECK-32-NEXT: (single_payload_enum size=8 alignment=4 stride=8 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (field name=some offset=0
// CHECK-32-NEXT: (case name=some index=0 offset=0
// CHECK-32-NEXT: (class_existential size=8 alignment=4 stride=8 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=object offset=0
// CHECK-32-NEXT: (reference kind=strong refcounting=unknown))
// CHECK-32-NEXT: (field name=wtable offset=4
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))))
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-32-NEXT: (case name=none index=1)))
// CHECK-32-NEXT: (field name=anyClassBoundProtoComposition1 offset=160
// CHECK-32-NEXT: (class_existential size=8 alignment=4 stride=8 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=object offset=0
@@ -749,12 +773,13 @@
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-32-NEXT: (field name=optionalAnyClassBoundProtoComposition1 offset=168
// CHECK-32-NEXT: (single_payload_enum size=8 alignment=4 stride=8 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (field name=some offset=0
// CHECK-32-NEXT: (case name=some index=0 offset=0
// CHECK-32-NEXT: (class_existential size=8 alignment=4 stride=8 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=object offset=0
// CHECK-32-NEXT: (reference kind=strong refcounting=unknown))
// CHECK-32-NEXT: (field name=wtable offset=4
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))))
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-32-NEXT: (case name=none index=1)))
// CHECK-32-NEXT: (field name=anyClassBoundProtoComposition2 offset=176
// CHECK-32-NEXT: (class_existential size=12 alignment=4 stride=12 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=object offset=0
@@ -765,14 +790,15 @@
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-32-NEXT: (field name=optionalAnyClassBoundProtoComposition2 offset=188
// CHECK-32-NEXT: (single_payload_enum size=12 alignment=4 stride=12 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (field name=some offset=0
// CHECK-32-NEXT: (case name=some index=0 offset=0
// CHECK-32-NEXT: (class_existential size=12 alignment=4 stride=12 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=object offset=0
// CHECK-32-NEXT: (reference kind=strong refcounting=unknown))
// CHECK-32-NEXT: (field name=wtable offset=4
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))
// CHECK-32-NEXT: (field name=wtable offset=8
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))))
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-32-NEXT: (case name=none index=1)))
// CHECK-32-NEXT: (field name=classConstrainedP1 offset=200
// CHECK-32-NEXT: (class_existential size=8 alignment=4 stride=8 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=object offset=0
@@ -895,20 +921,22 @@
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1))))
// CHECK-64-NEXT: (field name=optionalAny offset=8
// CHECK-64-NEXT: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI_SUB_1]] bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (existential_metatype size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=metadata offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1))))))
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1))))
// CHECK-64-NEXT: (case name=none index=1)))
// CHECK-64-NEXT: (field name=anyObject offset=16
// CHECK-64-NEXT: (existential_metatype size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=metadata offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1))))
// CHECK-64-NEXT: (field name=optionalAnyObject offset=24
// CHECK-64-NEXT: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI_SUB_1]] bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (existential_metatype size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=metadata offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1))))))
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1))))
// CHECK-64-NEXT: (case name=none index=1)))
// CHECK-64-NEXT: (field name=anyProto offset=32
// CHECK-64-NEXT: (existential_metatype size=16 alignment=8 stride=16 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=metadata offset=0
@@ -917,12 +945,13 @@
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-64-NEXT: (field name=optionalAnyProto offset=48
// CHECK-64-NEXT: (single_payload_enum size=16 alignment=8 stride=16 num_extra_inhabitants=[[PTR_XI_SUB_1]] bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (existential_metatype size=16 alignment=8 stride=16 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=metadata offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1))
// CHECK-64-NEXT: (field name=wtable offset=8
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))))
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-64-NEXT: (case name=none index=1)))
// CHECK-64-NEXT: (field name=anyProtoComposition offset=64
// CHECK-64-NEXT: (existential_metatype size=24 alignment=8 stride=24 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=metadata offset=0
@@ -933,26 +962,29 @@
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-64-NEXT: (field name=optionalAnyProtoComposition offset=88
// CHECK-64-NEXT: (single_payload_enum size=24 alignment=8 stride=24 num_extra_inhabitants=[[PTR_XI_SUB_1]] bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (existential_metatype size=24 alignment=8 stride=24 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=metadata offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1))
// CHECK-64-NEXT: (field name=wtable offset=8
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))
// CHECK-64-NEXT: (field name=wtable offset=16
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))))
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-64-NEXT: (case name=none index=1)))
// CHECK-64-NEXT: (field name=structMetatype offset=112
// CHECK-64-NEXT: (builtin size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))
// CHECK-64-NEXT: (field name=optionalStructMetatype offset=112
// CHECK-64-NEXT: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI_SUB_1]] bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1))))
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1))
// CHECK-64-NEXT: (case name=none index=1)))
// CHECK-64-NEXT: (field name=classMetatype offset=120
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1))
// CHECK-64-NEXT: (field name=optionalClassMetatype offset=128
// CHECK-64-NEXT: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI_SUB_1]] bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1))))
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1))
// CHECK-64-NEXT: (case name=none index=1)))
// CHECK-64-NEXT: (field name=abstractMetatype offset=136
// CHECK-64-NEXT: (struct size=16 alignment=8 stride=16 num_extra_inhabitants=[[PTR_XI]] bitwise_takable=1
// CHECK-64-NEXT: (field name=t offset=0
@@ -968,20 +1000,22 @@
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))))
// CHECK-32-NEXT: (field name=optionalAny offset=4
// CHECK-32-NEXT: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (field name=some offset=0
// CHECK-32-NEXT: (case name=some index=0 offset=0
// CHECK-32-NEXT: (existential_metatype size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=metadata offset=0
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))))))
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))))
// CHECK-32-NEXT: (case name=none index=1)))
// CHECK-32-NEXT: (field name=anyObject offset=8
// CHECK-32-NEXT: (existential_metatype size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=metadata offset=0
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))))
// CHECK-32-NEXT: (field name=optionalAnyObject offset=12
// CHECK-32-NEXT: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (field name=some offset=0
// CHECK-32-NEXT: (case name=some index=0 offset=0
// CHECK-32-NEXT: (existential_metatype size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=metadata offset=0
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))))))
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))))
// CHECK-32-NEXT: (case name=none index=1)))
// CHECK-32-NEXT: (field name=anyProto offset=16
// CHECK-32-NEXT: (existential_metatype size=8 alignment=4 stride=8 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=metadata offset=0
@@ -990,12 +1024,13 @@
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-32-NEXT: (field name=optionalAnyProto offset=24
// CHECK-32-NEXT: (single_payload_enum size=8 alignment=4 stride=8 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (field name=some offset=0
// CHECK-32-NEXT: (case name=some index=0 offset=0
// CHECK-32-NEXT: (existential_metatype size=8 alignment=4 stride=8 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=metadata offset=0
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))
// CHECK-32-NEXT: (field name=wtable offset=4
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))))
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-32-NEXT: (case name=none index=1)))
// CHECK-32-NEXT: (field name=anyProtoComposition offset=32
// CHECK-32-NEXT: (existential_metatype size=12 alignment=4 stride=12 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=metadata offset=0
@@ -1006,26 +1041,29 @@
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-32-NEXT: (field name=optionalAnyProtoComposition offset=44
// CHECK-32-NEXT: (single_payload_enum size=12 alignment=4 stride=12 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (field name=some offset=0
// CHECK-32-NEXT: (case name=some index=0 offset=0
// CHECK-32-NEXT: (existential_metatype size=12 alignment=4 stride=12 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=metadata offset=0
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))
// CHECK-32-NEXT: (field name=wtable offset=4
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))
// CHECK-32-NEXT: (field name=wtable offset=8
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))))
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-32-NEXT: (case name=none index=1)))
// CHECK-32-NEXT: (field name=structMetatype offset=56
// CHECK-32-NEXT: (builtin size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))
// CHECK-32-NEXT: (field name=optionalStructMetatype offset=56
// CHECK-32-NEXT: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (field name=some offset=0
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))))
// CHECK-32-NEXT: (case name=some index=0 offset=0
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))
// CHECK-32-NEXT: (case name=none index=1)))
// CHECK-32-NEXT: (field name=classMetatype offset=60
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))
// CHECK-32-NEXT: (field name=optionalClassMetatype offset=64
// CHECK-32-NEXT: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (field name=some offset=0
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))))
// CHECK-32-NEXT: (case name=some index=0 offset=0
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1))
// CHECK-32-NEXT: (case name=none index=1)))
// CHECK-32-NEXT: (field name=abstractMetatype offset=68
// CHECK-32-NEXT: (struct size=8 alignment=4 stride=8 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=t offset=0
@@ -1039,76 +1077,96 @@
// CHECK-64-NEXT: (field name=empty offset=0
// CHECK-64-NEXT: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))
// CHECK-64-NEXT: (field name=noPayload offset=0
// CHECK-64-NEXT: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=252 bitwise_takable=1))
// CHECK-64-NEXT: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=252 bitwise_takable=1
// CHECK-64-NEXT: (case name=A index=0)
// CHECK-64-NEXT: (case name=B index=1)
// CHECK-64-NEXT: (case name=C index=2)
// CHECK-64-NEXT: (case name=D index=3)))
// CHECK-64-NEXT: (field name=sillyNoPayload offset=1
// CHECK-64-NEXT: (multi_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=252 bitwise_takable=1
// CHECK-64-NEXT: (field name=A offset=0
// CHECK-64-NEXT: (case name=A index=0 offset=0
// CHECK-64-NEXT: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))
// CHECK-64-NEXT: (field name=B offset=0
// CHECK-64-NEXT: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-64-NEXT: (case name=B index=1 offset=0
// CHECK-64-NEXT: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))
// CHECK-64-NEXT: (case name=C index=2)
// CHECK-64-NEXT: (case name=D index=3)))
// CHECK-64-NEXT: (field name=singleton offset=8
// CHECK-64-NEXT: (reference kind=strong refcounting=native))
// CHECK-64-NEXT: (field name=singlePayload offset=16
// CHECK-64-NEXT: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI_SUB_1]] bitwise_takable=1
// CHECK-64-NEXT: (field name=Indirect offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=native))))
// CHECK-64-NEXT: (case name=Indirect index=0 offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=native))
// CHECK-64-NEXT: (case name=Nothing index=1)))
// CHECK-64-NEXT: (field name=multiPayloadConcrete offset=24
// CHECK-64-NEXT: (multi_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants={{(2045|125)}} bitwise_takable=1
// CHECK-64-NEXT: (field name=Left offset=0
// CHECK-64-NEXT: (case name=Left index=0 offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=native))
// CHECK-64-NEXT: (field name=Right offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=native))))
// CHECK-64-NEXT: (case name=Right index=1 offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=native))
// CHECK-64-NEXT: (case name=Donkey index=2)
// CHECK-64-NEXT: (case name=Mule index=3)
// CHECK-64-NEXT: (case name=Horse index=4)))
// CHECK-64-NEXT: (field name=multiPayloadGenericFixed offset=32
// CHECK-64-NEXT: (multi_payload_enum size=9 alignment=8 stride=16 num_extra_inhabitants=253 bitwise_takable=1
// CHECK-64-NEXT: (field name=Left offset=0
// CHECK-64-NEXT: (case name=Left index=0 offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=native))
// CHECK-64-NEXT: (field name=Right offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=native))))
// CHECK-64-NEXT: (case name=Right index=1 offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=native))
// CHECK-64-NEXT: (case name=Donkey index=2)
// CHECK-64-NEXT: (case name=Mule index=3)
// CHECK-64-NEXT: (case name=Horse index=4)))
// CHECK-64-NEXT: (field name=multiPayloadGenericDynamic offset=48
// CHECK-64-NEXT: (multi_payload_enum size=9 alignment=8 stride=16 num_extra_inhabitants=253 bitwise_takable=1
// CHECK-64-NEXT: (field name=Left offset=0
// CHECK-64-NEXT: (case name=Left index=0 offset=0
// CHECK-64-NEXT: (struct size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field name=_value offset=0
// CHECK-64-NEXT: (builtin size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-64-NEXT: (field name=Right offset=0
// CHECK-64-NEXT: (case name=Right index=1 offset=0
// CHECK-64-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field name=_value offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-64-NEXT: (case name=Donkey index=2)
// CHECK-64-NEXT: (case name=Mule index=3)
// CHECK-64-NEXT: (case name=Horse index=4)))
// CHECK-64-NEXT: (field name=optionalOptionalRef offset=64
// CHECK-64-NEXT: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI_SUB_2:2147483645|2046|4094]] bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=[[PTR_XI_SUB_1]] bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=native))))))
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=native))
// CHECK-64-NEXT: (case name=none index=1)))
// CHECK-64-NEXT: (case name=none index=1)))
// CHECK-64-NEXT: (field name=optionalOptionalPtr offset=72
// CHECK-64-NEXT: (single_payload_enum size=9 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1
// CHECK-64-NEXT: (field name=_rawValue offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1)))))))))
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=1 bitwise_takable=1))))
// CHECK-64-NEXT: (case name=none index=1)))
// CHECK-64-NEXT: (case name=none index=1))))
12TypeLowering23EnumStructWithOwnershipV
// CHECK-64: (struct TypeLowering.EnumStructWithOwnership)
// CHECK-64-NEXT: (struct size=25 alignment=8 stride=32 num_extra_inhabitants=254 bitwise_takable=0
// CHECK-64-NEXT: (field name=multiPayloadConcrete offset=0
// CHECK-64-NEXT: (multi_payload_enum size=9 alignment=8 stride=16 num_extra_inhabitants=254 bitwise_takable=0
// CHECK-64-NEXT: (field name=Left offset=0
// CHECK-64-NEXT: (case name=Left index=0 offset=0
// CHECK-64-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=0
// CHECK-64-NEXT: (field name=weakRef offset=0
// CHECK-64-NEXT: (reference kind=weak refcounting=native))))
// CHECK-64-NEXT: (field name=Right offset=0
// CHECK-64-NEXT: (case name=Right index=1 offset=0
// CHECK-64-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=0
// CHECK-64-NEXT: (field name=weakRef offset=0
// CHECK-64-NEXT: (reference kind=weak refcounting=native))))))
// CHECK-64-NEXT: (field name=multiPayloadGeneric offset=16
// CHECK-64-NEXT: (multi_payload_enum size=9 alignment=8 stride=16 num_extra_inhabitants=254 bitwise_takable=0
// CHECK-64-NEXT: (field name=Left offset=0
// CHECK-64-NEXT: (case name=Left index=0 offset=0
// CHECK-64-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=0
// CHECK-64-NEXT: (field name=weakRef offset=0
// CHECK-64-NEXT: (reference kind=weak refcounting=native))))
// CHECK-64-NEXT: (field name=Right offset=0
// CHECK-64-NEXT: (case name=Right index=1 offset=0
// CHECK-64-NEXT: (struct size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field name=_value offset=0
// CHECK-64-NEXT: (builtin size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1)))))))
@@ -1117,21 +1175,21 @@
// CHECK-32-NEXT: (struct size=13 alignment=4 stride=16 num_extra_inhabitants=254 bitwise_takable=0
// CHECK-32-NEXT: (field name=multiPayloadConcrete offset=0
// CHECK-32-NEXT: (multi_payload_enum size=5 alignment=4 stride=8 num_extra_inhabitants=254 bitwise_takable=0
// CHECK-32-NEXT: (field name=Left offset=0
// CHECK-32-NEXT: (case name=Left index=0 offset=0
// CHECK-32-NEXT: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=0
// CHECK-32-NEXT: (field name=weakRef offset=0
// CHECK-32-NEXT: (reference kind=weak refcounting=native))))
// CHECK-32-NEXT: (field name=Right offset=0
// CHECK-32-NEXT: (case name=Right index=1 offset=0
// CHECK-32-NEXT: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=0
// CHECK-32-NEXT: (field name=weakRef offset=0
// CHECK-32-NEXT: (reference kind=weak refcounting=native))))))
// CHECK-32-NEXT: (field name=multiPayloadGeneric offset=8
// CHECK-32-NEXT: (multi_payload_enum size=5 alignment=4 stride=8 num_extra_inhabitants=254 bitwise_takable=0
// CHECK-32-NEXT: (field name=Left offset=0
// CHECK-32-NEXT: (case name=Left index=0 offset=0
// CHECK-32-NEXT: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=0
// CHECK-32-NEXT: (field name=weakRef offset=0
// CHECK-32-NEXT: (reference kind=weak refcounting=native))))
// CHECK-32-NEXT: (field name=Right offset=0
// CHECK-32-NEXT: (case name=Right index=1 offset=0
// CHECK-32-NEXT: (struct size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field name=_value offset=0
// CHECK-32-NEXT: (builtin size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1)))))))

View File

@@ -23,8 +23,9 @@
// CHECK: (struct size=24 alignment=8 stride=24 num_extra_inhabitants=2147483647 bitwise_takable=1
// CHECK-NEXT: (field name=optionalEnum offset=0
// CHECK-NEXT: (single_payload_enum size=9 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-NEXT: (field name=some offset=0
// CHECK-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-NEXT: (case name=some index=0 offset=0
// CHECK-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))
// CHECK-NEXT: (case name=none index=1)))
// CHECK-NEXT: (field name=reference offset=16
// CHECK-NEXT: (class_existential size=8 alignment=8 stride=8 num_extra_inhabitants=2147483647 bitwise_takable=1
// CHECK-NEXT: (field name=object offset=0

View File

@@ -35,6 +35,10 @@
#include <unistd.h>
#endif
#if defined(__APPLE__) && defined(__MACH__)
#include <TargetConditionals.h>
#endif
#include <algorithm>
#include <csignal>
@@ -426,6 +430,19 @@ public:
bool queryDataLayout(DataLayoutQueryType type, void *inBuffer,
void *outBuffer) override {
auto wordSize = Images.front().TheImage.getBytesInAddress();
// TODO: The following should be set based on inspecting the image.
// This code sets it to match the platform this code was compiled for.
#if defined(__APPLE__) && __APPLE__
auto applePlatform = true;
#else
auto applePlatform = false;
#endif
#if defined(__APPLE__) && __APPLE__ && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_IOS) && TARGET_OS_WATCH) || (defined(TARGET_OS_TV) && TARGET_OS_TV))
auto iosDerivedPlatform = true;
#else
auto iosDerivedPlatform = false;
#endif
switch (type) {
case DLQ_GetPointerSize: {
auto result = static_cast<uint8_t *>(outBuffer);
@@ -437,6 +454,29 @@ public:
*result = wordSize;
return true;
}
case DLQ_GetObjCReservedLowBits: {
auto result = static_cast<uint8_t *>(outBuffer);
if (applePlatform && !iosDerivedPlatform && wordSize == 8) {
// Obj-C reserves low bit on 64-bit macOS only.
// Other Apple platforms don't reserve this bit (even when
// running on x86_64-based simulators).
*result = 1;
} else {
*result = 0;
}
return true;
}
case DLQ_GetLeastValidPointerValue: {
auto result = static_cast<uint64_t *>(outBuffer);
if (applePlatform && wordSize == 8) {
// Swift reserves the first 4GiB on 64-bit Apple platforms
*result = 0x100000000;
} else {
// Swift reserves the first 4KiB everywhere else
*result = 0x1000;
}
return true;
}
}
return false;

View File

@@ -31,6 +31,10 @@
#include <stddef.h>
#include <stdint.h>
#if defined(__APPLE__) && defined(__MACH__)
#include <TargetConditionals.h>
#endif
using namespace llvm::object;
using namespace swift;
@@ -52,6 +56,17 @@ public:
bool queryDataLayout(DataLayoutQueryType type, void *inBuffer,
void *outBuffer) override {
#if defined(__APPLE__) && __APPLE__
auto applePlatform = true;
#else
auto applePlatform = false;
#endif
#if defined(__APPLE__) && __APPLE__ && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_IOS) && TARGET_OS_WATCH) || (defined(TARGET_OS_TV) && TARGET_OS_TV))
auto iosDerivedPlatform = true;
#else
auto iosDerivedPlatform = false;
#endif
switch (type) {
case DLQ_GetPointerSize: {
auto result = static_cast<uint8_t *>(outBuffer);
@@ -63,6 +78,30 @@ public:
*result = sizeof(size_t);
return true;
}
case DLQ_GetObjCReservedLowBits: {
auto result = static_cast<uint8_t *>(outBuffer);
if (applePlatform && !iosDerivedPlatform && (sizeof(void *) == 8)) {
// Obj-C reserves low bit on 64-bit macOS only.
// Other Apple platforms don't reserve this bit (even when
// running on x86_64-based simulators).
*result = 1;
} else {
*result = 0;
}
return true;
}
case DLQ_GetLeastValidPointerValue: {
auto result = static_cast<uint64_t *>(outBuffer);
if (applePlatform && (sizeof(void *) == 8)) {
// Swift reserves the first 4GiB on Apple 64-bit platforms
*result = 0x100000000;
return 1;
} else {
// Swift reserves the first 4KiB everywhere else
*result = 0x1000;
}
return true;
}
}
return false;

View File

@@ -161,19 +161,15 @@ genericWithSources(a: (), b: ((), ()), c: ((), (), ()), gc: GC<(), ((), ()), (()
class CapturingClass {
// CHECK-64: Reflecting an object.
// CHECK-64: Type reference:
// CHECK-64: (class functions.CapturingClass)
// CHECK: Reflecting an object.
// CHECK: Type reference:
// CHECK-NEXT: (class functions.CapturingClass)
// CHECK-64: Type info:
// CHECK-64: (class_instance size=16 alignment=1 stride=16
// CHECK-32: Reflecting an object.
// CHECK-32: Type reference:
// CHECK-32: (class functions.CapturingClass)
// CHECK-64-NEXT: (class_instance size=16 alignment=1 stride=16
// CHECK-32: Type info:
// CHECK-32: (class_instance size=8 alignment=1 stride=8
// CHECK-32-NEXT: (class_instance size=8 alignment=1 stride=8
@_optimize(none)
func arity0Capture1() -> () -> () {
let closure = {
@@ -184,12 +180,12 @@ class CapturingClass {
return closure
}
// CHECK-64: Reflecting an object.
// CHECK-64: Type reference:
// CHECK-64: (builtin Builtin.NativeObject)
// CHECK: Reflecting an object.
// CHECK: Type reference:
// CHECK-NEXT: (builtin Builtin.NativeObject)
// CHECK-64: Type info:
// CHECK-64: (closure_context size=32 alignment=8 stride=32 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (closure_context size=32 alignment=8 stride=32 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field offset=16
// CHECK-64-NEXT: (tuple size=16 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field offset=0
@@ -201,12 +197,8 @@ class CapturingClass {
// CHECK-64-NEXT: (field name=_value offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1)))))))
// CHECK-32: Reflecting an object.
// CHECK-32: Type reference:
// CHECK-32: (builtin Builtin.NativeObject)
// CHECK-32: Type info:
// CHECK-32: (closure_context size=24 alignment=8 stride=24 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (closure_context size=24 alignment=8 stride=24 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field offset=8
// CHECK-32-NEXT: (tuple size=16 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field offset=0
@@ -227,12 +219,12 @@ class CapturingClass {
return closure
}
// CHECK-64: Reflecting an object.
// CHECK-64: Type reference:
// CHECK-64: (builtin Builtin.NativeObject)
// CHECK: Reflecting an object.
// CHECK: Type reference:
// CHECK-NEXT: (builtin Builtin.NativeObject)
// CHECK-64: Type info:
// CHECK-64: (closure_context size=32 alignment=8 stride=32 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (closure_context size=32 alignment=8 stride=32 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field offset=16
// CHECK-64-NEXT: (tuple size=16 alignment=8 stride=16 num_extra_inhabitants=2147483647 bitwise_takable=1
// CHECK-64-NEXT: (field offset=0
@@ -242,12 +234,8 @@ class CapturingClass {
// CHECK-64-NEXT: (field offset=8
// CHECK-64-NEXT: (reference kind=strong refcounting=native)))))
// CHECK-32: Reflecting an object.
// CHECK-32: Type reference:
// CHECK-32: (builtin Builtin.NativeObject)
// CHECK-32: Type info:
// CHECK-32: (closure_context size=16 alignment=4 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (closure_context size=16 alignment=4 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field offset=8
// CHECK-32-NEXT: (tuple size=8 alignment=4 stride=8 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field offset=0
@@ -267,31 +255,29 @@ class CapturingClass {
return closure
}
// CHECK-64: Reflecting an object.
// CHECK-64: Type reference:
// CHECK-64: (builtin Builtin.NativeObject)
// CHECK: Reflecting an object.
// CHECK: Type reference:
// CHECK-NEXT: (builtin Builtin.NativeObject)
// CHECK-64: Type info:
// CHECK-64: (closure_context size=24 alignment=8 stride=24 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (closure_context size=24 alignment=8 stride=24 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field offset=16
// CHECK-64-NEXT: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=2147483646 bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (class_existential size=8 alignment=8 stride=8 num_extra_inhabitants=2147483647 bitwise_takable=1
// CHECK-64-NEXT: (field name=object offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=unknown))))))
// CHECK-64-NEXT: (reference kind=strong refcounting=unknown))))
// CHECK-64-NEXT: (case name=none index=1))))
// CHECK-32: Reflecting an object.
// CHECK-32: Type reference:
// CHECK-32: (builtin Builtin.NativeObject)
// CHECK-32: Type info:
// CHECK-32: (closure_context size=12 alignment=4 stride=12 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (closure_context size=12 alignment=4 stride=12 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field offset=8
// CHECK-32-NEXT: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (field name=some offset=0
// CHECK-32-NEXT: (case name=some index=0 offset=0
// CHECK-32-NEXT: (class_existential size=4 alignment=4 stride=4 num_extra_inhabitants=4096 bitwise_takable=1
// CHECK-32-NEXT: (field name=object offset=0
// CHECK-32-NEXT: (reference kind=strong refcounting=unknown)))))
// CHECK-32-NEXT: (reference kind=strong refcounting=unknown))))
// CHECK-32-NEXT: (case name=none index=1))))
@_optimize(none)
func arity3Capture1() -> (Int, String, AnyObject?) -> () {
let c: AnyObject? = C()
@@ -304,11 +290,12 @@ class CapturingClass {
}
// CHECK-64: Reflecting an object.
// CHECK-64: Type reference:
// CHECK-64: (builtin Builtin.NativeObject)
// CHECK-64: Type info:
// CHECK-64: (closure_context size=40 alignment=8 stride=40 num_extra_inhabitants=0 bitwise_takable=1
// CHECK: Reflecting an object.
// CHECK: Type reference:
// CHECK-NEXT: (builtin Builtin.NativeObject)
// CHECK-64: Type info:
// CHECK-64-NEXT: (closure_context size=40 alignment=8 stride=40 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field offset=16
// CHECK-64-NEXT: (reference kind=strong refcounting=native))
// CHECK-64-NEXT: (field offset=24
@@ -322,12 +309,8 @@ class CapturingClass {
// CHECK-64-NEXT: (field name=_value offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1)))))))
// CHECK-32: Reflecting an object.
// CHECK-32: Type reference:
// CHECK-32: (builtin Builtin.NativeObject)
// CHECK-32: Type info:
// CHECK-32: (closure_context size=32 alignment=8 stride=32 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (closure_context size=32 alignment=8 stride=32 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field offset=8
// CHECK-32-NEXT: (reference kind=strong refcounting=native))
// CHECK-32-NEXT: (field offset=16
@@ -351,29 +334,29 @@ class CapturingClass {
return closure
}
// CHECK-64: Reflecting an object.
// CHECK-64: Type reference:
// CHECK-64: (builtin Builtin.NativeObject)
// CHECK: Reflecting an object.
// CHECK: Type reference:
// CHECK-NEXT: (builtin Builtin.NativeObject)
// CHECK-64: Type info:
// CHECK-64: (closure_context size=32 alignment=8 stride=32 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (closure_context size=32 alignment=8 stride=32 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field offset=16
// CHECK-64-NEXT: (reference kind=strong refcounting=native))
// CHECK-64-NEXT: (field offset=24
// CHECK-64-NEXT: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=2147483646 bitwise_takable=1
// CHECK-64-NEXT: (field name=some offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=native))))
// CHECK-64-NEXT: (case name=some index=0 offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=native))
// CHECK-64-NEXT: (case name=none index=1))))
// CHECK-32: Reflecting an object.
// CHECK-32: Type reference:
// CHECK-32: (builtin Builtin.NativeObject)
// CHECK-32: Type info:
// CHECK-32: (closure_context size=16 alignment=4 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field offset=8
// CHECK-32: (reference kind=strong refcounting=native))
// CHECK-32: (field offset=12
// CHECK-32: (reference kind=strong refcounting=native)))
// CHECK-32-NEXT: (closure_context size=16 alignment=4 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field offset=8
// CHECK-32-NEXT: (reference kind=strong refcounting=native))
// CHECK-32-NEXT: (field offset=12
// CHECK-32-NEXT: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (case name=some index=0 offset=0
// CHECK-32-NEXT: (reference kind=strong refcounting=native))
// CHECK-32-NEXT: (case name=none index=1))))
@_optimize(none)
func arity1Capture2() -> (Int) -> () {
let x: C? = C()
@@ -385,43 +368,39 @@ class CapturingClass {
return closure
}
// CHECK-64: Reflecting an object.
// CHECK-64: Type reference:
// CHECK-64: (builtin Builtin.NativeObject)
// CHECK: Reflecting an object.
// CHECK: Type reference:
// CHECK-NEXT: (builtin Builtin.NativeObject)
// CHECK-64: Type info:
// CHECK-64: (closure_context size=40 alignment=8 stride=40 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field offset=16
// CHECK-64: (reference kind=strong refcounting=native))
// CHECK-64: (field offset=24
// CHECK-64: (tuple size=16 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-64: (field offset=8
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1)))))))
// CHECK-64-NEXT: (closure_context size=40 alignment=8 stride=40 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field offset=16
// CHECK-64-NEXT: (reference kind=strong refcounting=native))
// CHECK-64-NEXT: (field offset=24
// CHECK-64-NEXT: (tuple size=16 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field offset=0
// CHECK-64-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field name=_value offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-64-NEXT: (field offset=8
// CHECK-64-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field name=_value offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1)))))))
// CHECK-32: Reflecting an object.
// CHECK-32: Type reference:
// CHECK-32: (builtin Builtin.NativeObject)
// CHECK-32: Type info:
// CHECK-32: (closure_context size=32 alignment=8 stride=32 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field offset=8
// CHECK-32: (reference kind=strong refcounting=native))
// CHECK-32: (field offset=16
// CHECK-32: (tuple size=16 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-32: (field offset=8
// CHECK-32: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1)))))))
// CHECK-32-NEXT: (closure_context size=32 alignment=8 stride=32 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field offset=8
// CHECK-32-NEXT: (reference kind=strong refcounting=native))
// CHECK-32-NEXT: (field offset=16
// CHECK-32-NEXT: (tuple size=16 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field offset=0
// CHECK-32-NEXT: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field name=_value offset=0
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-32-NEXT: (field offset=8
// CHECK-32-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field name=_value offset=0
// CHECK-32-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1)))))))
@_optimize(none)
func arity2Capture2() -> (Int, String) -> () {
let pair = (999, 1010.2)
@@ -434,43 +413,39 @@ class CapturingClass {
return closure
}
// CHECK-64: Reflecting an object.
// CHECK-64: Type reference:
// CHECK-64: (builtin Builtin.NativeObject)
// CHECK: Reflecting an object.
// CHECK: Type reference:
// CHECK-NEXT: (builtin Builtin.NativeObject)
// CHECK-64: Type info:
// CHECK-64: (closure_context size=40 alignment=8 stride=40 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field offset=16
// CHECK-64: (reference kind=strong refcounting=native))
// CHECK-64: (field offset=24
// CHECK-64: (tuple size=16 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-64: (field offset=8
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1)))))))
// CHECK-64-NEXT: (closure_context size=40 alignment=8 stride=40 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field offset=16
// CHECK-64-NEXT: (reference kind=strong refcounting=native))
// CHECK-64-NEXT: (field offset=24
// CHECK-64-NEXT: (tuple size=16 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field offset=0
// CHECK-64-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field name=_value offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-64-NEXT: (field offset=8
// CHECK-64-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field name=_value offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1)))))))
// CHECK-32: Reflecting an object.
// CHECK-32: Type reference:
// CHECK-32: (builtin Builtin.NativeObject)
// CHECK-32: Type info:
// CHECK-32: (closure_context size=32 alignment=8 stride=32 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field offset=8
// CHECK-32: (reference kind=strong refcounting=native))
// CHECK-32: (field offset=16
// CHECK-32: (tuple size=16 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-32: (field offset=8
// CHECK-32: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1)))))))
// CHECK-32-NEXT: (closure_context size=32 alignment=8 stride=32 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field offset=8
// CHECK-32-NEXT: (reference kind=strong refcounting=native))
// CHECK-32-NEXT: (field offset=16
// CHECK-32-NEXT: (tuple size=16 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field offset=0
// CHECK-32-NEXT: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field name=_value offset=0
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-32-NEXT: (field offset=8
// CHECK-32-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field name=_value offset=0
// CHECK-32-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1)))))))
@_optimize(none)
func arity3Capture2() -> (Int, String, AnyObject?) -> () {
let pair = (999, 1010.2)
@@ -496,44 +471,34 @@ _ = cc.arity2Capture2()
_ = cc.arity3Capture2()
reflect(function: C().captureWeakSelf())
// CHECK-64: Reflecting an object.
// CHECK-64: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-64: Type reference:
// CHECK-64: (builtin Builtin.NativeObject)
// CHECK: Reflecting an object.
// CHECK-NEXT: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-NEXT: Type reference:
// CHECK-NEXT: (builtin Builtin.NativeObject)
// CHECK-64: Type info:
// CHECK-64: (closure_context size=24 alignment=8 stride=24 num_extra_inhabitants=0 bitwise_takable=0
// CHECK-64-NEXT: (closure_context size=24 alignment=8 stride=24 num_extra_inhabitants=0 bitwise_takable=0
// CHECK-64-NEXT: (field offset=16
// CHECK-64-NEXT: (reference kind=weak refcounting=native)))
// CHECK-32: Reflecting an object.
// CHECK-32: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-32: Type reference:
// CHECK-32: (builtin Builtin.NativeObject)
// CHECK-32: Type info:
// CHECK-32: (closure_context size=12 alignment=4 stride=12 num_extra_inhabitants=0 bitwise_takable=0
// CHECK-32-NEXT: (closure_context size=12 alignment=4 stride=12 num_extra_inhabitants=0 bitwise_takable=0
// CHECK-32-NEXT: (field offset=8
// CHECK-32-NEXT: (reference kind=weak refcounting=native)))
reflect(function: C().captureUnownedSelf())
// CHECK-64: Reflecting an object.
// CHECK-64: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-64: Type reference:
// CHECK-64: (builtin Builtin.NativeObject)
// CHECK: Reflecting an object.
// CHECK-NEXT: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-NEXT: Type reference:
// CHECK-NEXT: (builtin Builtin.NativeObject)
// CHECK-64: Type info:
// CHECK-64: (closure_context size=24 alignment=8 stride=24 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (closure_context size=24 alignment=8 stride=24 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field offset=16
// CHECK-64-NEXT: (reference kind=unowned refcounting=native)))
// CHECK-32: Reflecting an object.
// CHECK-32: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-32: Type reference:
// CHECK-32: (builtin Builtin.NativeObject)
// CHECK-32: Type info:
// CHECK-32: (closure_context size=12 alignment=4 stride=12 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (closure_context size=12 alignment=4 stride=12 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field offset=8
// CHECK-32-NEXT: (reference kind=unowned refcounting=native)))

File diff suppressed because it is too large Load Diff

View File

@@ -31,44 +31,59 @@ reflect(object: ClassWithNoCaseEnum())
// CHECK-64: (class_instance size=31 alignment=1 stride=31 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=e1 offset=16
// CHECK-64: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=e2 offset=17
// CHECK-64: (single_payload_enum size=2 alignment=1 stride=2 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=e3 offset=19
// CHECK-64: (single_payload_enum size=3 alignment=1 stride=3 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=2 alignment=1 stride=2 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))))))))
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=e4 offset=22
// CHECK-64: (single_payload_enum size=4 alignment=1 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=3 alignment=1 stride=3 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=2 alignment=1 stride=2 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))))))))))
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=e5 offset=26
// CHECK-64: (single_payload_enum size=5 alignment=1 stride=5 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=4 alignment=1 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=3 alignment=1 stride=3 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=2 alignment=1 stride=2 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1)))))))))))))
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (case name=none index=1))))
// CHECK-32: Reflecting an object.
// CHECK-32: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
@@ -79,44 +94,58 @@ reflect(object: ClassWithNoCaseEnum())
// CHECK-32: (class_instance size=23 alignment=1 stride=23 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=e1 offset=8
// CHECK-32: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=e2 offset=9
// CHECK-32: (single_payload_enum size=2 alignment=1 stride=2 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=e3 offset=11
// CHECK-32: (single_payload_enum size=3 alignment=1 stride=3 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=2 alignment=1 stride=2 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))))))))
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=e4 offset=14
// CHECK-32: (single_payload_enum size=4 alignment=1 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=3 alignment=1 stride=3 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=2 alignment=1 stride=2 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))))))))))
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=e5 offset=18
// CHECK-32: (single_payload_enum size=5 alignment=1 stride=5 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=4 alignment=1 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=3 alignment=1 stride=3 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=2 alignment=1 stride=2 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1)))))))))))))
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (case name=none index=1))))
doneReflecting()

View File

@@ -0,0 +1,119 @@
// RUN: %empty-directory(%t)
// RUN: %target-build-swift -g -lswiftSwiftReflectionTest %s -o %t/reflect_Enum_SingleCaseIntPayload
// RUN: %target-codesign %t/reflect_Enum_SingleCaseIntPayload
// RUN: %target-run %target-swift-reflection-test %t/reflect_Enum_SingleCaseIntPayload | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
// REQUIRES: objc_interop
// REQUIRES: executable_test
import SwiftReflectionTest
enum SingleCaseIntPayloadEnum {
case only(Int)
}
class ClassWithSingleCaseIntPayloadEnum {
var e1: SingleCaseIntPayloadEnum?
var e2: SingleCaseIntPayloadEnum = .only(1)
var e3: SingleCaseIntPayloadEnum? = .some(.only(2))
var e4: SingleCaseIntPayloadEnum??
}
reflect(object: ClassWithSingleCaseIntPayloadEnum())
// CHECK-64: Reflecting an object.
// CHECK-64: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-64: Type reference:
// CHECK-64: (class reflect_Enum_SingleCaseIntPayload.ClassWithSingleCaseIntPayloadEnum)
// CHECK-64: Type info:
// CHECK-64: (class_instance size=66 alignment=8 stride=72 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=e1 offset=16
// CHECK-64: (single_payload_enum size=9 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=e2 offset=32
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-64: (field name=e3 offset=40
// CHECK-64: (single_payload_enum size=9 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=e4 offset=56
// CHECK-64: (single_payload_enum size=10 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=9 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (case name=none index=1))))
// CHECK-32: Reflecting an object.
// CHECK-32: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-32: Type reference:
// CHECK-32: (class reflect_Enum_SingleCaseIntPayload.ClassWithSingleCaseIntPayloadEnum)
// CHECK-32: Type info:
// CHECK-32: (class_instance size=34 alignment=4 stride=36 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=e1 offset=8
// CHECK-32: (single_payload_enum size=5 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=e2 offset=16
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-32: (field name=e3 offset=20
// CHECK-32: (single_payload_enum size=5 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=e4 offset=28
// CHECK-32: (single_payload_enum size=6 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=5 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-32: (case name=none index=1))
// CHECK-32: (case name=none index=1))))
reflect(enum: SingleCaseIntPayloadEnum.only(77))
// CHECK-64: Reflecting an enum.
// CHECK-64: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-64: Type reference:
// CHECK-64: (enum reflect_Enum_SingleCaseIntPayload.SingleCaseIntPayloadEnum)
// CHECK-64: Type info:
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1)))
// CHECK-64: Enum value:
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1)))
doneReflecting()
// CHECK-64: Done.
// CHECK-32: Done.

View File

@@ -37,18 +37,25 @@ reflect(object: ClassWithSingleCaseNoPayloadEnum())
// CHECK-64: (class_instance size=32 alignment=8 stride=32 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=e1 offset=16
// CHECK-64: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (case name=default index=0)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=e2 offset=17
// CHECK-64: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))
// CHECK-64: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (case name=default index=0)))
// CHECK-64: (field name=e3 offset=17
// CHECK-64: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (case name=default index=0)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=e4 offset=18
// CHECK-64: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (case name=default index=0)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=marker offset=24
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=value offset=0
@@ -65,20 +72,28 @@ reflect(object: ClassWithSingleCaseNoPayloadEnum())
// CHECK-32: (class_instance size=16 alignment=4 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=e1 offset=8
// CHECK-32: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (case name=default index=0)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=e2 offset=9
// CHECK-32: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))
// CHECK-32: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (case name=default index=0)))
// CHECK-32: (field name=e3 offset=9
// CHECK-32: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))))
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (case name=default index=0)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=e4 offset=10
// CHECK-32: (single_payload_enum size=2 alignment=1 stride=2 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (case name=default index=0)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=marker offset=12
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=value offset=0
@@ -86,6 +101,32 @@ reflect(object: ClassWithSingleCaseNoPayloadEnum())
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1)))))))
reflect(enum: SingleCaseNoPayloadEnum.`default`)
// CHECK-64: Reflecting an enum.
// CHECK-64: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-64: Type reference:
// CHECK-64: (enum reflect_Enum_SingleCaseNoPayload.SingleCaseNoPayloadEnum)
// CHECK-64: Type info:
// CHECK-64: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (case name=default index=0))
// CHECK-64: Enum value:
// CHECK-64: (enum_value name=default index=0)
// CHECK-32: Reflecting an enum.
// CHECK-32: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-32: Type reference:
// CHECK-32: (enum reflect_Enum_SingleCaseNoPayload.SingleCaseNoPayloadEnum)
// CHECK-32: Type info:
// CHECK-32: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (case name=default index=0))
// CHECK-32: Enum value:
// CHECK-32: (enum_value name=default index=0)
doneReflecting()
// CHECK-64: Done.

View File

@@ -35,20 +35,24 @@ reflect(object: ClassWithSingleCasePointerPayloadEnum())
// CHECK-64: (class_instance size=48 alignment=8 stride=48 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=e1 offset=16
// CHECK-64: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=2147483646 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (reference kind=strong refcounting=native))))
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (reference kind=strong refcounting=native))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=e2 offset=24
// CHECK-64: (reference kind=strong refcounting=native))
// CHECK-64: (field name=e3 offset=32
// CHECK-64: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=2147483646 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (reference kind=strong refcounting=native))))
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (reference kind=strong refcounting=native))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=e4 offset=40
// CHECK-64: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=2147483645 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=2147483646 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (reference kind=strong refcounting=native)))))))
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (reference kind=strong refcounting=native))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (case name=none index=1))))
// CHECK-32: Reflecting an object.
// CHECK-32: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
@@ -59,20 +63,50 @@ reflect(object: ClassWithSingleCasePointerPayloadEnum())
// CHECK-32: (class_instance size=24 alignment=4 stride=24 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=e1 offset=8
// CHECK-32: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (reference kind=strong refcounting=native))))
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (reference kind=strong refcounting=native))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=e2 offset=12
// CHECK-32: (reference kind=strong refcounting=native))
// CHECK-32: (field name=e3 offset=16
// CHECK-32: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (reference kind=strong refcounting=native))))
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (reference kind=strong refcounting=native))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=e4 offset=20
// CHECK-32: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4094 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (reference kind=strong refcounting=native)))))))
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (reference kind=strong refcounting=native))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (case name=none index=1))))
reflect(enum: SingleCasePointerPayloadEnum.only(Marker()))
// CHECK-64: Reflecting an enum.
// CHECK-64: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-64: Type reference:
// CHECK-64: (enum reflect_Enum_SingleCasePointerPayload.SingleCasePointerPayloadEnum)
// CHECK-64: Type info:
// CHECK-64: (reference kind=strong refcounting=native)
// CHECK-64: Enum value:
// CHECK-64: (reference kind=strong refcounting=native)
// CHECK-32: Reflecting an enum.
// CHECK-32: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-32: Type reference:
// CHECK-32: (enum reflect_Enum_SingleCasePointerPayload.SingleCasePointerPayloadEnum)
// CHECK-32: Type info:
// CHECK-32: (reference kind=strong refcounting=native)
// CHECK-32: Enum value:
// CHECK-32: (reference kind=strong refcounting=native)
doneReflecting()

View File

@@ -40,20 +40,33 @@ reflect(object: ClassWithTwoCaseNoPayloadEnum())
// CHECK-64: (class_instance size=32 alignment=8 stride=32 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=e1 offset=16
// CHECK-64: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=253 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1))))
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-64: (case name=preferred index=0)
// CHECK-64: (case name=other index=1)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=e2 offset=17
// CHECK-64: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1))
// CHECK-64: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-64: (case name=preferred index=0)
// CHECK-64: (case name=other index=1)))
// CHECK-64: (field name=e3 offset=18
// CHECK-64: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1))
// CHECK-64: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-64: (case name=preferred index=0)
// CHECK-64: (case name=other index=1)))
// CHECK-64: (field name=e4 offset=19
// CHECK-64: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=253 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1))))
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-64: (case name=preferred index=0)
// CHECK-64: (case name=other index=1)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=e5 offset=20
// CHECK-64: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=253 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1))))
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-64: (case name=preferred index=0)
// CHECK-64: (case name=other index=1)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=marker offset=24
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=value offset=0
@@ -70,20 +83,33 @@ reflect(object: ClassWithTwoCaseNoPayloadEnum())
// CHECK-32: (class_instance size=20 alignment=4 stride=20 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=e1 offset=8
// CHECK-32: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=253 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1))))
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-32: (case name=preferred index=0)
// CHECK-32: (case name=other index=1)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=e2 offset=9
// CHECK-32: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1))
// CHECK-32: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-32: (case name=preferred index=0)
// CHECK-32: (case name=other index=1)))
// CHECK-32: (field name=e3 offset=10
// CHECK-32: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1))
// CHECK-32: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-32: (case name=preferred index=0)
// CHECK-32: (case name=other index=1)))
// CHECK-32: (field name=e4 offset=11
// CHECK-32: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=253 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1))))
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-32: (case name=preferred index=0)
// CHECK-32: (case name=other index=1)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=e5 offset=12
// CHECK-32: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=253 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1))))
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-32: (case name=preferred index=0)
// CHECK-32: (case name=other index=1)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=marker offset=16
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=value offset=0
@@ -91,6 +117,138 @@ reflect(object: ClassWithTwoCaseNoPayloadEnum())
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1)))))))
reflect(enum: TwoCaseNoPayloadEnum.preferred)
// CHECK-64: Reflecting an enum.
// CHECK-64: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-64: Type reference:
// CHECK-64: (enum reflect_Enum_TwoCaseNoPayload.TwoCaseNoPayloadEnum)
// CHECK-64: Type info:
// CHECK-64: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-64: (case name=preferred index=0)
// CHECK-64: (case name=other index=1))
// CHECK-64: Enum value:
// CHECK-64: (enum_value name=preferred index=0)
// CHECK-32: Reflecting an enum.
// CHECK-32: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-32: Type reference:
// CHECK-32: (enum reflect_Enum_TwoCaseNoPayload.TwoCaseNoPayloadEnum)
// CHECK-32: Type info:
// CHECK-32: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-32: (case name=preferred index=0)
// CHECK-32: (case name=other index=1))
// CHECK-32: Enum value:
// CHECK-32: (enum_value name=preferred index=0)
reflect(enum: TwoCaseNoPayloadEnum.other)
// CHECK-64: Reflecting an enum.
// CHECK-64: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-64: Type reference:
// CHECK-64: (enum reflect_Enum_TwoCaseNoPayload.TwoCaseNoPayloadEnum)
// CHECK-64: Type info:
// CHECK-64: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-64: (case name=preferred index=0)
// CHECK-64: (case name=other index=1))
// CHECK-64: Enum value:
// CHECK-64: (enum_value name=other index=1)
// CHECK-32: Reflecting an enum.
// CHECK-32: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-32: Type reference:
// CHECK-32: (enum reflect_Enum_TwoCaseNoPayload.TwoCaseNoPayloadEnum)
// CHECK-32: Type info:
// CHECK-32: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-32: (case name=preferred index=0)
// CHECK-32: (case name=other index=1))
// CHECK-32: Enum value:
// CHECK-32: (enum_value name=other index=1)
reflect(enum: Optional<TwoCaseNoPayloadEnum>.some(.other))
// CHECK-64: Reflecting an enum.
// CHECK-64: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-64: Type reference:
// CHECK-64: (bound_generic_enum Swift.Optional
// CHECK-64: (enum reflect_Enum_TwoCaseNoPayload.TwoCaseNoPayloadEnum))
// CHECK-64: Type info:
// CHECK-64: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=253 bitwise_takable=1
// CHECK-64: (case name=some index=0
// CHECK-64: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-64: (case name=preferred index=0)
// CHECK-64: (case name=other index=1)))
// CHECK-64: (case name=none index=1))
// CHECK-64: Enum value:
// CHECK-64: (enum_value name=some index=0
// CHECK-64: (enum reflect_Enum_TwoCaseNoPayload.TwoCaseNoPayloadEnum)
// CHECK-64: )
// CHECK-32: Reflecting an enum.
// CHECK-32: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-32: Type reference:
// CHECK-32: (bound_generic_enum Swift.Optional
// CHECK-32: (enum reflect_Enum_TwoCaseNoPayload.TwoCaseNoPayloadEnum))
// CHECK-32: Type info:
// CHECK-32: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=253 bitwise_takable=1
// CHECK-32: (case name=some index=0
// CHECK-32: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-32: (case name=preferred index=0)
// CHECK-32: (case name=other index=1)))
// CHECK-32: (case name=none index=1))
// CHECK-32: Enum value:
// CHECK-32: (enum_value name=some index=0
// CHECK-32: (enum reflect_Enum_TwoCaseNoPayload.TwoCaseNoPayloadEnum)
// CHECK-32: )
reflect(enum: Optional<TwoCaseNoPayloadEnum>.none)
// CHECK-64: Reflecting an enum.
// CHECK-64: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-64: Type reference:
// CHECK-64: (bound_generic_enum Swift.Optional
// CHECK-64: (enum reflect_Enum_TwoCaseNoPayload.TwoCaseNoPayloadEnum))
// CHECK-64: Type info:
// CHECK-64: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=253 bitwise_takable=1
// CHECK-64: (case name=some index=0
// CHECK-64: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-64: (case name=preferred index=0)
// CHECK-64: (case name=other index=1)))
// CHECK-64: (case name=none index=1))
// CHECK-64: Enum value:
// CHECK-64: (enum_value name=none index=1)
// CHECK-32: Reflecting an enum.
// CHECK-32: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-32: Type reference:
// CHECK-32: (bound_generic_enum Swift.Optional
// CHECK-32: (enum reflect_Enum_TwoCaseNoPayload.TwoCaseNoPayloadEnum))
// CHECK-32: Type info:
// CHECK-32: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=253 bitwise_takable=1
// CHECK-32: (case name=some index=0
// CHECK-32: (no_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-32: (case name=preferred index=0)
// CHECK-32: (case name=other index=1)))
// CHECK-32: (case name=none index=1))
// CHECK-32: Enum value:
// CHECK-32: (enum_value name=none index=1)
doneReflecting()
// CHECK-64: Done.

View File

@@ -0,0 +1,209 @@
// RUN: %empty-directory(%t)
// RUN: %target-build-swift -g -lswiftSwiftReflectionTest %s -o %t/reflect_Enum_TwoCaseOnePointerPayload
// RUN: %target-codesign %t/reflect_Enum_TwoCaseOnePointerPayload
// RUN: %target-run %target-swift-reflection-test %t/reflect_Enum_TwoCaseOnePointerPayload | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
// REQUIRES: objc_interop
// REQUIRES: executable_test
import SwiftReflectionTest
class Marker {
let value = 1
}
// Note: Reference/pointer types have extra inhabitants, so
// the enum can use those. As a result, this enum should
// be the same size as a pointer.
enum TwoCaseOnePointerPayloadEnum {
case valid(Marker)
case invalid
}
class ClassWithTwoCaseOnePointerPayloadEnum {
var e1: TwoCaseOnePointerPayloadEnum?
var e2: TwoCaseOnePointerPayloadEnum = .valid(Marker())
var e3: TwoCaseOnePointerPayloadEnum = .invalid
var e4: TwoCaseOnePointerPayloadEnum? = .valid(Marker())
var e5: TwoCaseOnePointerPayloadEnum? = .invalid
var e6: TwoCaseOnePointerPayloadEnum??
}
reflect(object: ClassWithTwoCaseOnePointerPayloadEnum())
// CHECK-64: Reflecting an object.
// CHECK-64: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-64: Type reference:
// CHECK-64: (class reflect_Enum_TwoCaseOnePointerPayload.ClassWithTwoCaseOnePointerPayloadEnum)
// CHECK-64: Type info:
// CHECK-64: (class_instance size=64 alignment=8 stride=64 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=e1 offset=16
// CHECK-64: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=2147483645 bitwise_takable=1
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=2147483646 bitwise_takable=1
// CHECK-64: (case name=valid index=0 offset=0
// CHECK-64: (reference kind=strong refcounting=native))
// CHECK-64: (case name=invalid index=1)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=e2 offset=24
// CHECK-64: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=2147483646 bitwise_takable=1
// CHECK-64: (case name=valid index=0 offset=0
// CHECK-64: (reference kind=strong refcounting=native))
// CHECK-64: (case name=invalid index=1)))
// CHECK-64: (field name=e3 offset=32
// CHECK-64: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=2147483646 bitwise_takable=1
// CHECK-64: (case name=valid index=0 offset=0
// CHECK-64: (reference kind=strong refcounting=native))
// CHECK-64: (case name=invalid index=1)))
// CHECK-64: (field name=e4 offset=40
// CHECK-64: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=2147483645 bitwise_takable=1
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=2147483646 bitwise_takable=1
// CHECK-64: (case name=valid index=0 offset=0
// CHECK-64: (reference kind=strong refcounting=native))
// CHECK-64: (case name=invalid index=1)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=e5 offset=48
// CHECK-64: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=2147483645 bitwise_takable=1
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=2147483646 bitwise_takable=1
// CHECK-64: (case name=valid index=0 offset=0
// CHECK-64: (reference kind=strong refcounting=native))
// CHECK-64: (case name=invalid index=1)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=e6 offset=56
// CHECK-64: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=2147483644 bitwise_takable=1
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=2147483645 bitwise_takable=1
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=2147483646 bitwise_takable=1
// CHECK-64: (case name=valid index=0 offset=0
// CHECK-64: (reference kind=strong refcounting=native))
// CHECK-64: (case name=invalid index=1)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (case name=none index=1))))
// CHECK-32: Reflecting an object.
// CHECK-32: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-32: Type reference:
// CHECK-32: (class reflect_Enum_TwoCaseOnePointerPayload.ClassWithTwoCaseOnePointerPayloadEnum)
// CHECK-32: Type info:
// CHECK-32: (class_instance size=32 alignment=4 stride=32 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=e1 offset=8
// CHECK-32: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4094 bitwise_takable=1
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32: (case name=valid index=0 offset=0
// CHECK-32: (reference kind=strong refcounting=native))
// CHECK-32: (case name=invalid index=1)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=e2 offset=12
// CHECK-32: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32: (case name=valid index=0 offset=0
// CHECK-32: (reference kind=strong refcounting=native))
// CHECK-32: (case name=invalid index=1)))
// CHECK-32: (field name=e3 offset=16
// CHECK-32: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32: (case name=valid index=0 offset=0
// CHECK-32: (reference kind=strong refcounting=native))
// CHECK-32: (case name=invalid index=1)
// CHECK-32: (field name=e4 offset=20
// CHECK-32: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4094 bitwise_takable=1
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32: (case name=valid index=0 offset=0
// CHECK-32: (reference kind=strong refcounting=native))
// CHECK-32: (case name=invalid index=1)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=e5 offset=24
// CHECK-32: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4094 bitwise_takable=1
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32: (case name=valid index=0 offset=0
// CHECK-32: (reference kind=strong refcounting=native))
// CHECK-32: (case name=invalid index=1)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=e6 offset=28
// CHECK-32: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4093 bitwise_takable=1
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4094 bitwise_takable=1
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32: (case name=valid index=0 offset=0
// CHECK-32: (reference kind=strong refcounting=native))
// CHECK-32: (case name=invalid index=1)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (case name=none index=1))))
reflect(enum: TwoCaseOnePointerPayloadEnum.valid(Marker()))
// CHECK-64: Reflecting an enum.
// CHECK-64-NEXT: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-64-NEXT: Type reference:
// CHECK-64-NEXT: (enum reflect_Enum_TwoCaseOnePointerPayload.TwoCaseOnePointerPayloadEnum)
// CHECK-64: Type info:
// CHECK-64-NEXT: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=2147483646 bitwise_takable=1
// CHECK-64-NEXT: (case name=valid index=0 offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=native))
// CHECK-64-NEXT: (case name=invalid index=1))
// CHECK-64: Enum value:
// CHECK-64-NEXT: (enum_value name=valid index=0
// CHECK-64-NEXT: (class reflect_Enum_TwoCaseOnePointerPayload.Marker)
// CHECK-64-NEXT: )
// CHECK-32: Reflecting an enum.
// CHECK-32-NEXT: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-32-NEXT: Type reference:
// CHECK-32-NEXT: (enum reflect_Enum_TwoCaseOnePointerPayload.TwoCaseOnePointerPayloadEnum)
// CHECK-32: Type info:
// CHECK-32-NEXT: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (case name=valid index=0 offset=0
// CHECK-32-NEXT: (reference kind=strong refcounting=native))
// CHECK-32-NEXT: (case name=invalid index=1))
// CHECK-32: Enum value:
// CHECK-32-NEXT: (enum_value name=valid index=0
// CHECK-32-NEXT: (class reflect_Enum_TwoCaseOnePointerPayload.Marker)
// CHECK-32-NEXT: )
reflect(enum: TwoCaseOnePointerPayloadEnum.invalid)
// CHECK-64: Reflecting an enum.
// CHECK-64-NEXT: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-64-NEXT: Type reference:
// CHECK-64-NEXT: (enum reflect_Enum_TwoCaseOnePointerPayload.TwoCaseOnePointerPayloadEnum)
// CHECK-64: Type info:
// CHECK-64-NEXT: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=2147483646 bitwise_takable=1
// CHECK-64-NEXT: (case name=valid index=0 offset=0
// CHECK-64-NEXT: (reference kind=strong refcounting=native))
// CHECK-64-NEXT: (case name=invalid index=1))
// CHECK-64: Enum value:
// CHECK-64-NEXT: (enum_value name=invalid index=1)
// CHECK-32: Reflecting an enum.
// CHECK-32-NEXT: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-32-NEXT: Type reference:
// CHECK-32-NEXT: (enum reflect_Enum_TwoCaseOnePointerPayload.TwoCaseOnePointerPayloadEnum)
// CHECK-32: Type info:
// CHECK-32-NEXT: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4095 bitwise_takable=1
// CHECK-32-NEXT: (case name=valid index=0 offset=0
// CHECK-32-NEXT: (reference kind=strong refcounting=native))
// CHECK-32-NEXT: (case name=invalid index=1))
// CHECK-32: Enum value:
// CHECK-32-NEXT: (enum_value name=invalid index=1)
doneReflecting()
// CHECK-64: Done.
// CHECK-32: Done.

View File

@@ -1,168 +1,249 @@
// RUN: %empty-directory(%t)
// RUN: %target-build-swift -g -lswiftSwiftReflectionTest %s -o %t/reflect_Enum_TwoCaseOnePayload
// RUN: %target-codesign %t/reflect_Enum_TwoCaseOnePayload
// RUN: %target-build-swift -g -lswiftSwiftReflectionTest %s -o %t/reflect_Enum_TwoCaseOneStructPayload
// RUN: %target-codesign %t/reflect_Enum_TwoCaseOneStructPayload
// RUN: %target-run %target-swift-reflection-test %t/reflect_Enum_TwoCaseOnePayload | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
// RUN: %target-run %target-swift-reflection-test %t/reflect_Enum_TwoCaseOneStructPayload | %FileCheck %s --check-prefix=CHECK-%target-ptrsize --check-prefix=CHECK-ALL
// REQUIRES: objc_interop
// REQUIRES: executable_test
import SwiftReflectionTest
// Note: struct Marker has no extra inhabitants, so the enum will use a separate tag
struct Marker {
let value = 1
}
enum TwoCaseOnePayloadEnum {
enum TwoCaseOneStructPayloadEnum {
case valid(Marker)
case invalid
}
class ClassWithTwoCaseOnePayloadEnum {
var e1: TwoCaseOnePayloadEnum?
var e2: TwoCaseOnePayloadEnum = .valid(Marker())
var e3: TwoCaseOnePayloadEnum = .invalid
var e4: TwoCaseOnePayloadEnum? = .valid(Marker())
var e5: TwoCaseOnePayloadEnum? = .invalid
var e6: TwoCaseOnePayloadEnum??
class ClassWithTwoCaseOneStructPayloadEnum {
var e1: TwoCaseOneStructPayloadEnum?
var e2: TwoCaseOneStructPayloadEnum = .valid(Marker())
var e3: TwoCaseOneStructPayloadEnum = .invalid
var e4: TwoCaseOneStructPayloadEnum? = .valid(Marker())
var e5: TwoCaseOneStructPayloadEnum? = .invalid
var e6: TwoCaseOneStructPayloadEnum??
}
reflect(object: ClassWithTwoCaseOnePayloadEnum())
reflect(object: ClassWithTwoCaseOneStructPayloadEnum())
// CHECK-64: Reflecting an object.
// CHECK-64: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-64: Type reference:
// CHECK-64: (class reflect_Enum_TwoCaseOnePayload.ClassWithTwoCaseOnePayloadEnum)
// CHECK-64: (class reflect_Enum_TwoCaseOneStructPayload.ClassWithTwoCaseOneStructPayloadEnum)
// CHECK-64: Type info:
// CHECK-64: (class_instance size=107 alignment=8 stride=112 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=e1 offset=16
// CHECK-64: (single_payload_enum size=10 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=9 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=valid offset=0
// CHECK-64: (case name=valid index=0 offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=value offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))))))
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-64: (case name=invalid index=1)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=e2 offset=32
// CHECK-64: (single_payload_enum size=9 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=valid offset=0
// CHECK-64: (case name=valid index=0 offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=value offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))))
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-64: (case name=invalid index=1)))
// CHECK-64: (field name=e3 offset=48
// CHECK-64: (single_payload_enum size=9 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=valid offset=0
// CHECK-64: (case name=valid index=0 offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=value offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))))
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-64: (case name=invalid index=1)))
// CHECK-64: (field name=e4 offset=64
// CHECK-64: (single_payload_enum size=10 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=9 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=valid offset=0
// CHECK-64: (case name=valid index=0 offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=value offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))))))
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-64: (case name=invalid index=1)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=e5 offset=80
// CHECK-64: (single_payload_enum size=10 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=9 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=valid offset=0
// CHECK-64: (case name=valid index=0 offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=value offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))))))
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-64: (case name=invalid index=1)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=e6 offset=96
// CHECK-64: (single_payload_enum size=11 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=10 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=9 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=valid offset=0
// CHECK-64: (case name=valid index=0 offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=value offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1)))))))))))))
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-64: (case name=invalid index=1)))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (case name=none index=1))))
// CHECK-32: Reflecting an object.
// CHECK-32: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-32: Type reference:
// CHECK-32: (class reflect_Enum_TwoCaseOnePayload.ClassWithTwoCaseOnePayloadEnum)
// CHECK-32: (class reflect_Enum_TwoCaseOneStructPayload.ClassWithTwoCaseOneStructPayloadEnum)
// CHECK-32: Type info:
// CHECK-32: (class_instance size=55 alignment=4 stride=56 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=e1 offset=8
// CHECK-32: (single_payload_enum size=6 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=5 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=valid offset=0
// CHECK-32: (case name=valid index=0 offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=value offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))))))
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-32: (case name=invalid index=1)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=e2 offset=16
// CHECK-32: (single_payload_enum size=5 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=valid offset=0
// CHECK-32: (case name=valid index=0 offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=value offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))))
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-32: (case name=invalid index=1)))
// CHECK-32: (field name=e3 offset=24
// CHECK-32: (single_payload_enum size=5 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=valid offset=0
// CHECK-32: (case name=valid index=0 offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=value offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))))
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-32: (case name=invalid index=1)))
// CHECK-32: (field name=e4 offset=32
// CHECK-32: (single_payload_enum size=6 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=5 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=valid offset=0
// CHECK-32: (case name=valid index=0 offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=value offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))))))
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-32: (case name=invalid index=1)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=e5 offset=40
// CHECK-32: (single_payload_enum size=6 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=5 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=valid offset=0
// CHECK-32: (case name=valid index=0 offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=value offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))))))
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-32: (case name=invalid index=1)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=e6 offset=48
// CHECK-32: (single_payload_enum size=7 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=6 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=5 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=valid offset=0
// CHECK-32: (case name=valid index=0 offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=value offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1)))))))))))))
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-32: (case name=invalid index=1)))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (case name=none index=1))))
reflect(enum: TwoCaseOneStructPayloadEnum.valid(Marker()))
// CHECK-ALL: Reflecting an enum.
// CHECK-ALL-NEXT: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-ALL-NEXT: Type reference:
// CHECK-ALL-NEXT: (enum reflect_Enum_TwoCaseOneStructPayload.TwoCaseOneStructPayloadEnum)
// CHECK-ALL: Type info:
// CHECK-64-NEXT: (single_payload_enum size=9 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (case name=valid index=0 offset=0
// CHECK-64-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field name=value offset=0
// CHECK-64-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field name=_value offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-64-NEXT: (case name=invalid index=1))
// CHECK-32-NEXT: (single_payload_enum size=5 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (case name=valid index=0 offset=0
// CHECK-32-NEXT: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field name=value offset=0
// CHECK-32-NEXT: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field name=_value offset=0
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-32-NEXT: (case name=invalid index=1))
// CHECK-ALL: Enum value:
// CHECK-ALL-NEXT: (enum_value name=valid index=0
// CHECK-ALL-NEXT: (struct reflect_Enum_TwoCaseOneStructPayload.Marker)
// CHECK-ALL-NEXT: )
reflect(enum: TwoCaseOneStructPayloadEnum.invalid)
// CHECK-ALL: Reflecting an enum.
// CHECK-ALL-NEXT: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-ALL-NEXT: Type reference:
// CHECK-ALL-NEXT: (enum reflect_Enum_TwoCaseOneStructPayload.TwoCaseOneStructPayloadEnum)
// CHECK-ALL: Type info:
// CHECK-64-NEXT: (single_payload_enum size=9 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (case name=valid index=0 offset=0
// CHECK-64-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field name=value offset=0
// CHECK-64-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64-NEXT: (field name=_value offset=0
// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-64-NEXT: (case name=invalid index=1))
// CHECK-32-NEXT: (single_payload_enum size=5 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (case name=valid index=0 offset=0
// CHECK-32-NEXT: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field name=value offset=0
// CHECK-32-NEXT: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field name=_value offset=0
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-32-NEXT: (case name=invalid index=1))
// CHECK-ALL: Enum value:
// CHECK-ALL-NEXT: (enum_value name=invalid index=1)
doneReflecting()
// CHECK-64: Done.
// CHECK-32: Done.
// CHECK-ALL: Done.

View File

@@ -39,9 +39,9 @@ reflect(object: ClassWithTwoCaseTwoPayloadsEnum())
// CHECK-64: (class_instance size=153 alignment=8 stride=160 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=e1 offset=16
// CHECK-64: (single_payload_enum size=17 alignment=8 stride=24 num_extra_inhabitants=253 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (multi_payload_enum size=17 alignment=8 stride=24 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-64: (field name=valid offset=0
// CHECK-64: (case name=valid index=0 offset=0
// CHECK-64: (struct size=16 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=value offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
@@ -51,13 +51,14 @@ reflect(object: ClassWithTwoCaseTwoPayloadsEnum())
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-64: (field name=invalid offset=0
// CHECK-64: (case name=invalid index=1 offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))))
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=e2 offset=40
// CHECK-64: (multi_payload_enum size=17 alignment=8 stride=24 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-64: (field name=valid offset=0
// CHECK-64: (case name=valid index=0 offset=0
// CHECK-64: (struct size=16 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=value offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
@@ -67,13 +68,13 @@ reflect(object: ClassWithTwoCaseTwoPayloadsEnum())
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-64: (field name=invalid offset=0
// CHECK-64: (case name=invalid index=1 offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-64: (field name=e3 offset=64
// CHECK-64: (multi_payload_enum size=17 alignment=8 stride=24 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-64: (field name=valid offset=0
// CHECK-64: (case name=valid index=0 offset=0
// CHECK-64: (struct size=16 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=value offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
@@ -83,15 +84,15 @@ reflect(object: ClassWithTwoCaseTwoPayloadsEnum())
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-64: (field name=invalid offset=0
// CHECK-64: (case name=invalid index=1 offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-64: (field name=e4 offset=88
// CHECK-64: (single_payload_enum size=17 alignment=8 stride=24 num_extra_inhabitants=253 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (multi_payload_enum size=17 alignment=8 stride=24 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-64: (field name=valid offset=0
// CHECK-64: (case name=valid index=0 offset=0
// CHECK-64: (struct size=16 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=value offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
@@ -101,15 +102,16 @@ reflect(object: ClassWithTwoCaseTwoPayloadsEnum())
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-64: (field name=invalid offset=0
// CHECK-64: (case name=invalid index=1 offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))))
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=e5 offset=112
// CHECK-64: (single_payload_enum size=17 alignment=8 stride=24 num_extra_inhabitants=253 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (multi_payload_enum size=17 alignment=8 stride=24 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-64: (field name=valid offset=0
// CHECK-64: (case name=valid index=0 offset=0
// CHECK-64: (struct size=16 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=value offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
@@ -119,17 +121,18 @@ reflect(object: ClassWithTwoCaseTwoPayloadsEnum())
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-64: (field name=invalid offset=0
// CHECK-64: (case name=invalid index=1 offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))))
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (field name=e6 offset=136
// CHECK-64: (single_payload_enum size=17 alignment=8 stride=24 num_extra_inhabitants=252 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (single_payload_enum size=17 alignment=8 stride=24 num_extra_inhabitants=253 bitwise_takable=1
// CHECK-64: (field name=some offset=0
// CHECK-64: (case name=some index=0 offset=0
// CHECK-64: (multi_payload_enum size=17 alignment=8 stride=24 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-64: (field name=valid offset=0
// CHECK-64: (case name=valid index=0 offset=0
// CHECK-64: (struct size=16 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=value offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
@@ -139,10 +142,12 @@ reflect(object: ClassWithTwoCaseTwoPayloadsEnum())
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-64: (field name=invalid offset=0
// CHECK-64: (case name=invalid index=1 offset=0
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1)))))))))))
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-64: (case name=none index=1)))
// CHECK-64: (case name=none index=1))))
// CHECK-32: Reflecting an object.
// CHECK-32: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
@@ -153,9 +158,9 @@ reflect(object: ClassWithTwoCaseTwoPayloadsEnum())
// CHECK-32: (class_instance size=77 alignment=4 stride=80 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=e1 offset=8
// CHECK-32: (single_payload_enum size=9 alignment=4 stride=12 num_extra_inhabitants=253 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (multi_payload_enum size=9 alignment=4 stride=12 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-32: (field name=valid offset=0
// CHECK-32: (case name=valid index=0 offset=0
// CHECK-32: (struct size=8 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=value offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
@@ -165,13 +170,14 @@ reflect(object: ClassWithTwoCaseTwoPayloadsEnum())
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-32: (field name=invalid offset=0
// CHECK-32: (case name=invalid index=1 offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))))
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=e2 offset=20
// CHECK-32: (multi_payload_enum size=9 alignment=4 stride=12 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-32: (field name=valid offset=0
// CHECK-32: (case name=valid index=0 offset=0
// CHECK-32: (struct size=8 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=value offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
@@ -181,13 +187,13 @@ reflect(object: ClassWithTwoCaseTwoPayloadsEnum())
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-32: (field name=invalid offset=0
// CHECK-32: (case name=invalid index=1 offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-32: (field name=e3 offset=32
// CHECK-32: (multi_payload_enum size=9 alignment=4 stride=12 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-32: (field name=valid offset=0
// CHECK-32: (case name=valid index=0 offset=0
// CHECK-32: (struct size=8 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=value offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
@@ -197,15 +203,15 @@ reflect(object: ClassWithTwoCaseTwoPayloadsEnum())
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-32: (field name=invalid offset=0
// CHECK-32: (case name=invalid index=1 offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-32: (field name=e4 offset=44
// CHECK-32: (single_payload_enum size=9 alignment=4 stride=12 num_extra_inhabitants=253 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (multi_payload_enum size=9 alignment=4 stride=12 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-32: (field name=valid offset=0
// CHECK-32: (case name=valid index=0 offset=0
// CHECK-32: (struct size=8 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=value offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
@@ -215,15 +221,16 @@ reflect(object: ClassWithTwoCaseTwoPayloadsEnum())
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-32: (field name=invalid offset=0
// CHECK-32: (case name=invalid index=1 offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))))
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=e5 offset=56
// CHECK-32: (single_payload_enum size=9 alignment=4 stride=12 num_extra_inhabitants=253 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (multi_payload_enum size=9 alignment=4 stride=12 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-32: (field name=valid offset=0
// CHECK-32: (case name=valid index=0 offset=0
// CHECK-32: (struct size=8 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=value offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
@@ -233,17 +240,18 @@ reflect(object: ClassWithTwoCaseTwoPayloadsEnum())
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-32: (field name=invalid offset=0
// CHECK-32: (case name=invalid index=1 offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))))
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (field name=e6 offset=68
// CHECK-32: (single_payload_enum size=9 alignment=4 stride=12 num_extra_inhabitants=252 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (single_payload_enum size=9 alignment=4 stride=12 num_extra_inhabitants=253 bitwise_takable=1
// CHECK-32: (field name=some offset=0
// CHECK-32: (case name=some index=0 offset=0
// CHECK-32: (multi_payload_enum size=9 alignment=4 stride=12 num_extra_inhabitants=254 bitwise_takable=1
// CHECK-32: (field name=valid offset=0
// CHECK-32: (case name=valid index=0 offset=0
// CHECK-32: (struct size=8 alignment=4 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=value offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
@@ -253,10 +261,12 @@ reflect(object: ClassWithTwoCaseTwoPayloadsEnum())
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-32: (field name=invalid offset=0
// CHECK-32: (case name=invalid index=1 offset=0
// CHECK-32: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: (field name=_value offset=0
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1)))))))))))
// CHECK-32: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1))))))
// CHECK-32: (case name=none index=1)))
// CHECK-32: (case name=none index=1))))
doneReflecting()

View File

@@ -0,0 +1,253 @@
// RUN: %empty-directory(%t)
// RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_Enum_value
// RUN: %target-codesign %t/reflect_Enum_value
// RUN: %target-run %target-swift-reflection-test %t/reflect_Enum_value | tee /dev/stderr | %FileCheck %s --check-prefix=CHECK --check-prefix=X%target-ptrsize --dump-input=fail
// REQUIRES: objc_interop
// REQUIRES: executable_test
import Foundation
import SwiftReflectionTest
enum OneCaseNoPayload {
case only
}
reflect(enum: OneCaseNoPayload.only)
// CHECK: Reflecting an enum.
// CHECK-NEXT: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-NEXT: Type reference:
// CHECK-NEXT: (enum reflect_Enum_value.OneCaseNoPayload)
// CHECK: Type info:
// CHECK-NEXT: (no_payload_enum size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-NEXT: (case name=only index=0))
// CHECK: Enum value:
// CHECK-NEXT: (enum_value name=only index=0)
reflect(enumValue: Optional<OneCaseNoPayload>.some(.only))
// CHECK: Reflecting an enum value.
// CHECK-NEXT: Type reference:
// CHECK-NEXT: (bound_generic_enum Swift.Optional
// CHECK-NEXT: (enum reflect_Enum_value.OneCaseNoPayload))
// CHECK-NEXT: Value: .some(.only)
reflect(enumValue: Optional<Optional<OneCaseNoPayload>>.some(.some(.only)))
// CHECK: Reflecting an enum value.
// CHECK-NEXT: Type reference:
// CHECK-NEXT: (bound_generic_enum Swift.Optional
// CHECK-NEXT: (bound_generic_enum Swift.Optional
// CHECK-NEXT: (enum reflect_Enum_value.OneCaseNoPayload)))
// CHECK-NEXT: Value: .some(.some(.only))
reflect(enumValue: Optional<Optional<OneCaseNoPayload>>.some(.none))
// CHECK: Reflecting an enum value.
// CHECK-NEXT: Type reference:
// CHECK-NEXT: (bound_generic_enum Swift.Optional
// CHECK-NEXT: (bound_generic_enum Swift.Optional
// CHECK-NEXT: (enum reflect_Enum_value.OneCaseNoPayload)))
// CHECK-NEXT: Value: .some(.none)
struct StructInt {
var a: Int
}
enum OneStructPayload {
case payloadA(StructInt)
case otherA
case otherB
}
reflect(enumValue: OneStructPayload.payloadA(StructInt(a: 0)))
// CHECK: Reflecting an enum value.
// CHECK-NEXT: Type reference:
// CHECK-NEXT: (enum reflect_Enum_value.OneStructPayload)
// CHECK-NEXT: Value: .payloadA(_)
reflect(enumValue: OneStructPayload.otherA)
// CHECK: Reflecting an enum value.
// CHECK-NEXT: Type reference:
// CHECK-NEXT: (enum reflect_Enum_value.OneStructPayload)
// CHECK-NEXT: Value: .otherA
@objc class ObjCClass : NSObject {
var a: Int = 0
}
enum OneObjCPayload {
case payloadA(ObjCClass)
case otherA
case otherB
case otherC
case otherD
case otherE
}
reflect(enumValue: OneObjCPayload.payloadA(ObjCClass()))
// CHECK: Reflecting an enum value.
// CHECK-NEXT: Type reference:
// CHECK-NEXT: (enum reflect_Enum_value.OneObjCPayload)
// CHECK-NEXT: Value: .payloadA(_)
reflect(enumValue: OneObjCPayload.otherC)
// CHECK: Reflecting an enum value.
// CHECK-NEXT: Type reference:
// CHECK-NEXT: (enum reflect_Enum_value.OneObjCPayload)
// CHECK-NEXT: Value: .otherC
class SwiftClass {
var a: Int = 0
}
enum OneSwiftClassPayload {
case payloadA(SwiftClass)
case otherA
case otherB
case otherC
case otherD
case otherE
}
reflect(enumValue: OneSwiftClassPayload.payloadA(SwiftClass()))
// CHECK: Reflecting an enum value.
// CHECK-NEXT: Type reference:
// CHECK-NEXT: (enum reflect_Enum_value.OneSwiftClassPayload)
// CHECK-NEXT: Value: .payloadA(_)
reflect(enum: OneSwiftClassPayload.otherC)
// CHECK: Reflecting an enum.
// CHECK-NEXT: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
// CHECK-NEXT: Type reference:
// CHECK-NEXT: (enum reflect_Enum_value.OneSwiftClassPayload)
// CHECK: Type info:
// X64-NEXT: (single_payload_enum size=8 alignment=8 stride=8 num_extra_inhabitants=2147483642 bitwise_takable=1
// X32-NEXT: (single_payload_enum size=4 alignment=4 stride=4 num_extra_inhabitants=4091 bitwise_takable=1
// CHECK-NEXT: (case name=payloadA index=0 offset=0
// CHECK-NEXT: (reference kind=strong refcounting=native))
// CHECK-NEXT: (case name=otherA index=1)
// CHECK-NEXT: (case name=otherB index=2)
// CHECK-NEXT: (case name=otherC index=3)
// CHECK-NEXT: (case name=otherD index=4)
// CHECK-NEXT: (case name=otherE index=5))
// CHECK: Enum value:
// CHECK-NEXT: (enum_value name=otherC index=3)
reflect(enumValue: Optional<OneSwiftClassPayload>.none)
// CHECK: Reflecting an enum value.
// CHECK-NEXT: Type reference:
// CHECK-NEXT: (bound_generic_enum Swift.Optional
// CHECK-NEXT: (enum reflect_Enum_value.OneSwiftClassPayload))
// CHECK-NEXT: Value: .none
reflect(enumValue: Optional<Optional<OneSwiftClassPayload>>.none)
// CHECK: Reflecting an enum value.
// CHECK-NEXT: Type reference:
// CHECK-NEXT: (bound_generic_enum Swift.Optional
// CHECK-NEXT: (bound_generic_enum Swift.Optional
// CHECK-NEXT: (enum reflect_Enum_value.OneSwiftClassPayload)))
// CHECK-NEXT: Value: .none
reflect(enumValue: Optional<Optional<OneSwiftClassPayload>>.some(.none))
// CHECK: Reflecting an enum value.
// CHECK-NEXT: Type reference:
// CHECK-NEXT: (bound_generic_enum Swift.Optional
// CHECK-NEXT: (bound_generic_enum Swift.Optional
// CHECK-NEXT: (enum reflect_Enum_value.OneSwiftClassPayload)))
// CHECK-NEXT: Value: .some(.none)
reflect(enumValue: Optional<Optional<OneSwiftClassPayload>>.some(.some(.otherA)))
// CHECK: Reflecting an enum value.
// CHECK-NEXT: Type reference:
// CHECK-NEXT: (bound_generic_enum Swift.Optional
// CHECK-NEXT: (bound_generic_enum Swift.Optional
// CHECK-NEXT: (enum reflect_Enum_value.OneSwiftClassPayload)))
// CHECK-NEXT: Value: .some(.some(.otherA))
reflect(enumValue: Optional<Optional<OneSwiftClassPayload>>.some(.some(.otherE)))
// CHECK: Reflecting an enum value.
// CHECK-NEXT: Type reference:
// CHECK-NEXT: (bound_generic_enum Swift.Optional
// CHECK-NEXT: (bound_generic_enum Swift.Optional
// CHECK-NEXT: (enum reflect_Enum_value.OneSwiftClassPayload)))
// CHECK-NEXT: Value: .some(.some(.otherE))
reflect(enumValue: Optional<Optional<OneSwiftClassPayload>>.some(.some(.payloadA(SwiftClass()))))
// CHECK: Reflecting an enum value.
// CHECK-NEXT: Type reference:
// CHECK-NEXT: (bound_generic_enum Swift.Optional
// CHECK-NEXT: (bound_generic_enum Swift.Optional
// CHECK-NEXT: (enum reflect_Enum_value.OneSwiftClassPayload)))
// CHECK-NEXT: Value: .some(.some(.payloadA(_)))
struct MixedStruct {
var a = Int(0)
var b = SwiftClass()
}
enum OneMixedStructPayload {
case otherA
case otherB
case payloadA(MixedStruct)
}
reflect(enumValue: OneMixedStructPayload.otherA)
// CHECK: Reflecting an enum value.
// CHECK-NEXT: Type reference:
// CHECK-NEXT: (enum reflect_Enum_value.OneMixedStructPayload)
// CHECK-NEXT: Value: .otherA
reflect(enumValue: OneMixedStructPayload.payloadA(MixedStruct()))
// CHECK: Reflecting an enum value.
// CHECK-NEXT: Type reference:
// CHECK-NEXT: (enum reflect_Enum_value.OneMixedStructPayload)
// CHECK-NEXT: Value: .payloadA(_)
reflect(enumValue: Optional<OneMixedStructPayload>.none)
// CHECK: Reflecting an enum value.
// CHECK-NEXT: Type reference:
// CHECK-NEXT: (bound_generic_enum Swift.Optional
// CHECK-NEXT: (enum reflect_Enum_value.OneMixedStructPayload))
// CHECK-NEXT: Value: .none
enum OneNestedPayload {
case cargoA(OneMixedStructPayload)
case alternateA
case alternateB
case alternateC
}
reflect(enumValue: OneNestedPayload.alternateB)
// CHECK: Reflecting an enum value.
// CHECK-NEXT: Type reference:
// CHECK-NEXT: (enum reflect_Enum_value.OneNestedPayload)
// CHECK-NEXT: Value: .alternateB
// XXX TODO: enum with tuple payload, enum with optional payload, indirect enum, enum with closure/function payload XXX
doneReflecting()
// CHECK: Done.

File diff suppressed because it is too large Load Diff