mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge remote-tracking branch 'origin/master' into master-next
This commit is contained in:
@@ -165,10 +165,11 @@ swift::_buildDemanglingForContext(const ContextDescriptor *context,
|
||||
// Override the node kind if this is a Clang-imported type so we give it
|
||||
// a stable mangling.
|
||||
auto typeFlags = type->getTypeContextDescriptorFlags();
|
||||
if (typeFlags.isCTag()) {
|
||||
nodeKind = Node::Kind::Structure;
|
||||
} else if (typeFlags.isCTypedef()) {
|
||||
if (typeFlags.isCTypedef()) {
|
||||
nodeKind = Node::Kind::TypeAlias;
|
||||
} else if (nodeKind != Node::Kind::Structure &&
|
||||
isCImportedTagType(type)) {
|
||||
nodeKind = Node::Kind::Structure;
|
||||
}
|
||||
|
||||
auto typeNode = Dem.createNode(nodeKind);
|
||||
|
||||
@@ -153,6 +153,24 @@ static const TypeContextDescriptor *
|
||||
_findNominalTypeDescriptor(Demangle::NodePointer node,
|
||||
Demangle::Demangler &Dem);
|
||||
|
||||
bool swift::isCImportedTagType(const TypeContextDescriptor *type) {
|
||||
// Tag types are always imported as structs or enums.
|
||||
if (type->getKind() != ContextDescriptorKind::Enum &&
|
||||
type->getKind() != ContextDescriptorKind::Struct)
|
||||
return false;
|
||||
|
||||
// Not a typedef imported as a nominal type.
|
||||
if (type->getTypeContextDescriptorFlags().isCTypedef())
|
||||
return false;
|
||||
|
||||
// Not a related entity.
|
||||
if (type->isSynthesizedRelatedEntity())
|
||||
return false;
|
||||
|
||||
// Imported from C.
|
||||
return type->Parent->isCImportedContext();
|
||||
}
|
||||
|
||||
bool
|
||||
swift::_contextDescriptorMatchesMangling(const ContextDescriptor *context,
|
||||
Demangle::NodePointer node) {
|
||||
@@ -254,8 +272,11 @@ swift::_contextDescriptorMatchesMangling(const ContextDescriptor *context,
|
||||
case Demangle::Node::Kind::OtherNominalType:
|
||||
break;
|
||||
case Demangle::Node::Kind::Structure:
|
||||
if (type->getKind() != ContextDescriptorKind::Struct
|
||||
&& !type->getTypeContextDescriptorFlags().isCTag())
|
||||
// We allow non-structs to match Kind::Structure if they are
|
||||
// imported C tag types. This is necessary because we artificially
|
||||
// make imported C tag types Kind::Structure.
|
||||
if (type->getKind() != ContextDescriptorKind::Struct &&
|
||||
!isCImportedTagType(type))
|
||||
return false;
|
||||
break;
|
||||
case Demangle::Node::Kind::Class:
|
||||
|
||||
@@ -314,6 +314,9 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/// Is the given type imported from a C tag type?
|
||||
bool isCImportedTagType(const TypeContextDescriptor *type);
|
||||
|
||||
/// Check whether a type conforms to a protocol.
|
||||
///
|
||||
/// \param value - can be null, in which case the question should
|
||||
|
||||
Reference in New Issue
Block a user