Skip to content

Commit

Permalink
[TypeReconstruction] Fix a crash when reconstructing protocols.
Browse files Browse the repository at this point in the history
<rdar://problem/38849279>
  • Loading branch information
Davide Italiano committed Mar 26, 2018
1 parent 869b6bf commit 5587b39
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/IDE/TypeReconstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2156,6 +2156,26 @@ static void VisitAllChildNodes(
}
}

static void VisitNodeGlobal(ASTContext *ast, Demangle::NodePointer cur_node,
VisitNodeResult &result) {
assert(result._error.empty());

Demangle::Node::iterator child_end = cur_node->end();
for (Demangle::Node::iterator child_pos = cur_node->begin();
child_pos != child_end; ++child_pos) {
auto child = *child_pos;
const Demangle::Node::Kind childKind = child->getKind();

switch (childKind) {
case Demangle::Node::Kind::Identifier:
break;
default:
VisitNode(ast, *child_pos, result);
break;
}
}
}

static void VisitNode(
ASTContext *ast,
Demangle::NodePointer node, VisitNodeResult &result) {
Expand Down Expand Up @@ -2203,6 +2223,9 @@ static void VisitNode(
break;

case Demangle::Node::Kind::Global:
VisitNodeGlobal(ast, node, result);
break;

case Demangle::Node::Kind::Static:
case Demangle::Node::Kind::Type:
case Demangle::Node::Kind::TypeMangling:
Expand Down
8 changes: 8 additions & 0 deletions test/DebugInfo/DumpTypeFromMangledName.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@
func main() {
struct Patatino {}
}

extension Collection where Element: Equatable {
func split<C: Collection>(separatedBy separator: C) -> [SubSequence]
where C.Element == Element {
var results = [SubSequence]()
return results
}
}
1 change: 1 addition & 0 deletions test/DebugInfo/Inputs/type-reconstr-names.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ $S4blah4mainyyF ---> () -> ()
$SytD ---> ()
$Ss5Int32VD ---> Int32
$S4blah4mainyyF8PatatinoL_VMa ---> Can't resolve type of $S4blah4mainyyF8PatatinoL_VMa
$Ss10CollectionP7Element ---> Collection

0 comments on commit 5587b39

Please sign in to comment.