@@ -83,24 +83,26 @@ static bool IsSwiftAsyncFunctionSymbol(swift::Demangle::NodePointer node) {
83
83
return false ;
84
84
if (hasChild (node, Node::Kind::AsyncSuspendResumePartialFunction))
85
85
return false ;
86
-
87
- // Peel off layers over top of Function nodes.
88
- switch (node->getFirstChild ()->getKind ()) {
89
- case Node::Kind::Static:
90
- case Node::Kind::ExplicitClosure:
86
+ // Peel off a Static node. If it exists, there will be a single instance and a
87
+ // top level node.
88
+ if (node->getFirstChild ()->getKind () == Node::Kind::Static)
91
89
node = node->getFirstChild ();
92
- break ;
93
- default :
94
- break ;
95
- }
96
90
97
- return childAtPath (node,
98
- {Node::Kind::Function, Node::Kind::Type,
99
- Node::Kind::FunctionType, Node::Kind::AsyncAnnotation}) ||
100
- childAtPath (node,
101
- {Node::Kind::Function, Node::Kind::Type,
102
- Node::Kind::DependentGenericType, Node::Kind::Type,
103
- Node::Kind::FunctionType, Node::Kind::AsyncAnnotation});
91
+ // Get the ExplicitClosure or Function node.
92
+ // For nested closures in Swift, the demangle tree is inverted: the
93
+ // inner-most closure is the top-most ExplicitClosure node.
94
+ NodePointer func_node = [&] {
95
+ if (NodePointer func = childAtPath (node, Node::Kind::Function))
96
+ return func;
97
+ return childAtPath (node, Node::Kind::ExplicitClosure);
98
+ }();
99
+
100
+ return childAtPath (func_node, {Node::Kind::Type, Node::Kind::FunctionType,
101
+ Node::Kind::AsyncAnnotation}) ||
102
+ childAtPath (func_node,
103
+ {Node::Kind::Type, Node::Kind::DependentGenericType,
104
+ Node::Kind::Type, Node::Kind::FunctionType,
105
+ Node::Kind::AsyncAnnotation});
104
106
}
105
107
106
108
bool SwiftLanguageRuntime::IsSwiftAsyncFunctionSymbol (StringRef name) {
0 commit comments