@@ -40,8 +40,8 @@ struct SwiftReflectionContext {
40
40
NativeReflectionContext *nativeContext;
41
41
std::vector<std::function<void ()>> freeFuncs;
42
42
std::vector<std::tuple<swift_addr_t , swift_addr_t >> dataSegments;
43
- std::string lastError ;
44
-
43
+ std::string lastString ;
44
+
45
45
SwiftReflectionContext (MemoryReaderImpl impl) {
46
46
auto Reader = std::make_shared<CMemoryReader>(impl);
47
47
nativeContext = new NativeReflectionContext (Reader);
@@ -423,11 +423,11 @@ static swift_childinfo_t convertChild(const TypeInfo *TI, unsigned Index) {
423
423
};
424
424
}
425
425
426
- static const char *convertError (SwiftReflectionContextRef ContextRef,
427
- llvm::Optional<std::string> Error ) {
428
- if (Error ) {
429
- ContextRef->lastError = *Error ;
430
- return ContextRef->lastError .c_str ();
426
+ static const char *returnableCString (SwiftReflectionContextRef ContextRef,
427
+ llvm::Optional<std::string> String ) {
428
+ if (String ) {
429
+ ContextRef->lastString = *String ;
430
+ return ContextRef->lastString .c_str ();
431
431
}
432
432
return nullptr ;
433
433
}
@@ -605,7 +605,7 @@ const char *swift_reflection_iterateConformanceCache(
605
605
auto Error = Context->iterateConformances ([&](auto Type, auto Proto) {
606
606
Call (Type, Proto, ContextPtr);
607
607
});
608
- return convertError (ContextRef, Error);
608
+ return returnableCString (ContextRef, Error);
609
609
}
610
610
611
611
const char *swift_reflection_iterateMetadataAllocations (
@@ -621,10 +621,9 @@ const char *swift_reflection_iterateMetadataAllocations(
621
621
CAllocation.Size = Allocation.Size ;
622
622
Call (CAllocation, ContextPtr);
623
623
});
624
- return convertError (ContextRef, Error);
624
+ return returnableCString (ContextRef, Error);
625
625
}
626
626
627
- SWIFT_REMOTE_MIRROR_LINKAGE
628
627
swift_reflection_ptr_t swift_reflection_allocationMetadataPointer (
629
628
SwiftReflectionContextRef ContextRef,
630
629
swift_metadata_allocation_t Allocation) {
@@ -636,9 +635,16 @@ swift_reflection_ptr_t swift_reflection_allocationMetadataPointer(
636
635
return Context->allocationMetadataPointer (NativeAllocation);
637
636
}
638
637
638
+ const char *swift_reflection_metadataAllocationTagName (
639
+ SwiftReflectionContextRef ContextRef, swift_metadata_allocation_tag_t Tag) {
640
+ auto Context = ContextRef->nativeContext ;
641
+ auto Result = Context->metadataAllocationTagName (Tag);
642
+ return returnableCString (ContextRef, Result);
643
+ }
644
+
639
645
const char *swift_reflection_iterateMetadataAllocationBacktraces (
640
- SwiftReflectionContextRef ContextRef, swift_metadataAllocationIterator Call,
641
- void *ContextPtr) {
646
+ SwiftReflectionContextRef ContextRef,
647
+ swift_metadataAllocationBacktraceIterator Call, void *ContextPtr) {
642
648
auto Context = ContextRef->nativeContext ;
643
649
auto Error = Context->iterateMetadataAllocationBacktraces (
644
650
[&](auto AllocationPtr, auto Count, auto Ptrs) {
@@ -651,5 +657,5 @@ const char *swift_reflection_iterateMetadataAllocationBacktraces(
651
657
&Ptrs[Count]};
652
658
Call (AllocationPtr, Count, ConvertedPtrs.data (), ContextPtr);
653
659
});
654
- return convertError (ContextRef, Error);
660
+ return returnableCString (ContextRef, Error);
655
661
}
0 commit comments