Skip to content

Commit afd00a4

Browse files
committed
Minor cleanup
1 parent c3d378b commit afd00a4

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

stdlib/tools/swift-reflection-test/swift-reflection-test.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -648,24 +648,26 @@ int reflectEnumValue(SwiftReflectionContextRef RC,
648648
{
649649
// Get the pointer value from the target
650650
void *outFreeContext = NULL;
651-
const void *rawPtr = PipeMemoryReader_readBytes((void *)&Pipe, EnumInstance, 8, &outFreeContext);
651+
const void *rawPtr
652+
= PipeMemoryReader_readBytes((void *)&Pipe, EnumInstance, 8, &outFreeContext);
652653
uintptr_t instance = *(uintptr_t *)rawPtr;
654+
PipeMemoryReader_freeBytes((void *)&Pipe, rawPtr, outFreeContext);
653655

654656
// Indirect enum is stored as the first field of a closure context...
655657
swift_typeinfo_t TI = swift_reflection_infoForInstance(RC, instance);
656658
if (TI.Kind == SWIFT_CLOSURE_CONTEXT) {
657659
swift_childinfo_t CaseInfo
658660
= swift_reflection_childOfInstance(RC, instance, 0);
659-
if (CaseInfo.TR != 0) {
660-
if (CaseInfo.Kind == SWIFT_NO_PAYLOAD_ENUM
661-
|| CaseInfo.Kind == SWIFT_SINGLE_PAYLOAD_ENUM
662-
|| CaseInfo.Kind == SWIFT_MULTI_PAYLOAD_ENUM) {
663-
EnumTypeRef = CaseInfo.TR;
664-
EnumInstance = instance + CaseInfo.Offset;
665-
break;
666-
}
661+
if (CaseInfo.Kind == SWIFT_NO_PAYLOAD_ENUM
662+
|| CaseInfo.Kind == SWIFT_SINGLE_PAYLOAD_ENUM
663+
|| CaseInfo.Kind == SWIFT_MULTI_PAYLOAD_ENUM) {
664+
// Found the indirect enum storage, loop to print it out.
665+
EnumTypeRef = CaseInfo.TR;
666+
EnumInstance = instance + CaseInfo.Offset;
667+
break;
667668
}
668669
}
670+
// Not an indirect enum, fall through...
669671
__attribute__((fallthrough));
670672
}
671673
default:
@@ -679,7 +681,6 @@ int reflectEnumValue(SwiftReflectionContextRef RC,
679681
break;
680682
}
681683
}
682-
683684
}
684685
for (int i = 0; i < parens; ++i) {
685686
printf(")");

0 commit comments

Comments
 (0)