Skip to content

Commit 8f6294a

Browse files
eecksteinjrose-apple
authored andcommitted
runtime: use class_getName instead of NSStringFromClass in _swift_checkClassAndWarnForKeyedArchiving
(cherry picked from commit 1bff67f)
1 parent d747f57 commit 8f6294a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

stdlib/public/SDK/Foundation/CheckClass.mm

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
#import <Foundation/Foundation.h>
22

3+
#include <objc/runtime.h>
4+
35
#include "swift/Runtime/Metadata.h"
46

7+
// Aliases for Objective-C runtime entry points.
8+
static const char *class_getName(const swift::ClassMetadata* type) {
9+
return class_getName(
10+
reinterpret_cast<Class>(const_cast<swift::ClassMetadata*>(type)));
11+
}
12+
513
@interface NSKeyedUnarchiver (SwiftAdditions)
614
+ (int)_swift_checkClassAndWarnForKeyedArchiving:(Class)cls
715
operation:(int)operation
@@ -35,9 +43,8 @@ + (int)_swift_checkClassAndWarnForKeyedArchiving:(Class)cls
3543
if (theClass->getFlags() & swift::ClassFlags::HasCustomObjCName)
3644
return 0;
3745

38-
const char *className = [NSStringFromClass(cls) UTF8String];
39-
4046
// Is it a mangled name?
47+
const char *className = class_getName(theClass);
4148
if (!(className[0] == '_' && className[1] == 'T'))
4249
return 0;
4350
// Is it a name in the form <module>.<class>? Note: the module name could

0 commit comments

Comments
 (0)