Merge remote-tracking branch 'origin/master' into master-next

This commit is contained in:
swift-ci
2018-07-30 21:29:25 -07:00
6 changed files with 230 additions and 134 deletions

View File

@@ -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);

View File

@@ -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:

View File

@@ -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