@@ -718,21 +718,61 @@ _findContextDescriptorInCache(TypeMetadataPrivateState &T,
718
718
return iter->getSecond ();
719
719
}
720
720
721
+ #define DESCRIPTOR_MANGLING_SUFFIX_Structure Mn
722
+ #define DESCRIPTOR_MANGLING_SUFFIX_Enum Mn
723
+ #define DESCRIPTOR_MANGLING_SUFFIX_Protocol Mp
724
+
725
+ #define DESCRIPTOR_MANGLING_SUFFIX_ (X ) X
726
+ #define DESCRIPTOR_MANGLING_SUFFIX (KIND ) \
727
+ DESCRIPTOR_MANGLING_SUFFIX_ (DESCRIPTOR_MANGLING_SUFFIX_ ## KIND)
728
+
729
+ #define DESCRIPTOR_MANGLING_ (CHAR, SUFFIX ) \
730
+ $sS ## CHAR ## SUFFIX
731
+ #define DESCRIPTOR_MANGLING (CHAR, SUFFIX ) DESCRIPTOR_MANGLING_(CHAR, SUFFIX)
732
+
733
+ #define STANDARD_TYPE (KIND, MANGLING, TYPENAME ) \
734
+ extern " C" const ContextDescriptor DESCRIPTOR_MANGLING (MANGLING, DESCRIPTOR_MANGLING_SUFFIX(KIND));
735
+
736
+ #if !SWIFT_OBJC_INTEROP
737
+ # define OBJC_INTEROP_STANDARD_TYPE (KIND, MANGLING, TYPENAME )
738
+ #endif
739
+
740
+ #include " swift/Demangling/StandardTypesMangling.def"
741
+
721
742
static const ContextDescriptor *
722
743
_findContextDescriptor (Demangle::NodePointer node,
723
- Demangle::Demangler &Dem) {
724
- const ContextDescriptor *foundContext = nullptr ;
725
- auto &T = TypeMetadataRecords.get ();
726
-
727
- // If we have a symbolic reference to a context, resolve it immediately.
744
+ Demangle::Demangler &Dem) {
728
745
NodePointer symbolicNode = node;
729
746
if (symbolicNode->getKind () == Node::Kind::Type)
730
747
symbolicNode = symbolicNode->getChild (0 );
748
+
749
+ // If we have a symbolic reference to a context, resolve it immediately.
731
750
if (symbolicNode->getKind () == Node::Kind::TypeSymbolicReference) {
732
751
return cast<TypeContextDescriptor>(
733
752
(const ContextDescriptor *)symbolicNode->getIndex ());
734
753
}
735
754
755
+ // Fast-path lookup for standard library type references with short manglings.
756
+ if (symbolicNode->getNumChildren () >= 2
757
+ && symbolicNode->getChild (0 )->getKind () == Node::Kind::Module
758
+ && symbolicNode->getChild (0 )->getText ().equals (" Swift" )
759
+ && symbolicNode->getChild (1 )->getKind () == Node::Kind::Identifier) {
760
+ auto name = symbolicNode->getChild (1 )->getText ();
761
+
762
+ #define STANDARD_TYPE (KIND, MANGLING, TYPENAME ) \
763
+ if (name.equals (#TYPENAME)) { \
764
+ return &DESCRIPTOR_MANGLING (MANGLING, DESCRIPTOR_MANGLING_SUFFIX (KIND)); \
765
+ }
766
+ #if !SWIFT_OBJC_INTEROP
767
+ # define OBJC_INTEROP_STANDARD_TYPE (KIND, MANGLING, TYPENAME )
768
+ #endif
769
+
770
+ #include " swift/Demangling/StandardTypesMangling.def"
771
+ }
772
+
773
+ const ContextDescriptor *foundContext = nullptr ;
774
+ auto &T = TypeMetadataRecords.get ();
775
+
736
776
// Nothing to resolve if have a generic parameter.
737
777
if (symbolicNode->getKind () == Node::Kind::DependentGenericParamType)
738
778
return nullptr ;
0 commit comments