Commit b9e473c
committed
[lldb] Fix GetParentIfClosure for async closures inside non-async functions
When computing the name of the parent function of a closure, LLDB takes
the demangled parent function Node and replaces it on the top level
"Global" demangle node. However, this logic was faulty in two ways:
1. A misplaced return made the "replace logic" only look at the fist
child of the Global node.
2. The new Global node was inheriting _all_ children from the original
Global node, which is wrong.
For example, an async closure inside a non-async function would have
this demangle tree:
```
Global
<Async Attributes>
<Explicit Closure>
<Parent Function>
```
By replacing the `Explicit Closure` with `Parent Function`, we were
creating another async function. The solution is to just create the
Global node from scratch, dropping most other nodes it may have had.
This begs the question of which other nodes could be there as a sibling
of the closure in the tree; given how none of the existing tests failed
with this patch, it seems safe to assume any such nodes are not too
important (until proven otherwise).1 parent 4a62991 commit b9e473c
File tree
4 files changed
+54
-6
lines changed- lldb
- source/Plugins
- LanguageRuntime/Swift
- TypeSystem/Swift
- test/API/lang/swift/closures_var_not_captured
4 files changed
+54
-6
lines changedLines changed: 26 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1600 | 1600 | | |
1601 | 1601 | | |
1602 | 1602 | | |
1603 | | - | |
1604 | 1603 | | |
1605 | | - | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
1606 | 1628 | | |
1607 | 1629 | | |
1608 | 1630 | | |
1609 | 1631 | | |
1610 | 1632 | | |
1611 | | - | |
1612 | | - | |
| 1633 | + | |
| 1634 | + | |
1613 | 1635 | | |
1614 | 1636 | | |
1615 | 1637 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
109 | 121 | | |
110 | 122 | | |
111 | 123 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
215 | 227 | | |
216 | 228 | | |
217 | 229 | | |
| |||
227 | 239 | | |
228 | 240 | | |
229 | 241 | | |
| 242 | + | |
0 commit comments