Commit a50350e
committed
[lldb] Change the representation of Swift enums
(Payload-carrying) Swift enums are a challenging datastructure to
support in LLDB; this patch makes an attempt to clean up a problem
with the previous implementation, namely the dynamic nature of the
children of an enum, which has, in the past, lead to caching bugs when
displaying the children of enums. The new scheme is as follows:
- The static value of an enum is its discriminator (its case).
- An enum has no static children.
- The synthtic value of an enum is its projected case's payload.
- A synthetic child provider for all Swift enums provides synthetic
children, which are the children of the projected case's payload.
For example:
```
enum E {
case a
case b(Int, (Int, Int))
}
let a : E= .a
let b : E= .b(1, (2, 3))
```
The value of `a` is `.a`.
The value of `b` is `.b`.
The synthtic value of `b` is (1, (2, 3)).
The synthetic child 0 of `b` is 1.
The synthetic child 1 of `b` is (2, 3).
The number of (non-synthetic) children of `b` is 0.
The Swift Optional formatter behaves similarly.
Known Issues:
- SwiftRuntimeTypeVisitor does currently not visit the children of
Objective-C types; this also needs to get fixed, and is surfaced by
the new synthtic child providers in 1 test.
Implementation Notes:
This removes a lot of enum-handling code from SwiftLanguageRuntime;
simplifying the type visitor and dynamic type resolution, adn moves it
into the Enum/Optional synthetic frontends.1 parent cf4a54e commit a50350e
File tree
34 files changed
+703
-509
lines changed- lldb
- source/Plugins
- LanguageRuntime/Swift
- Language/Swift
- TypeSystem/Swift
- test
- API/lang/swift
- array_enum
- c_type_ivar
- clangimporter
- objc_runtime_ivars
- objc/dynamic-swift-type
- enums
- extension
- indirect
- expression/class_constrained_protocol
- external_provider_extra_inhabitants
- multilang_category
- optionset
- unknown_self
- variables
- bulky_enums
- generic_enums
- generics
- indirect_enums
- variadic_generics
- Shell/SwiftREPL
34 files changed
+703
-509
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
745 | 745 | | |
746 | 746 | | |
747 | 747 | | |
748 | | - | |
749 | | - | |
750 | | - | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
751 | 751 | | |
752 | 752 | | |
753 | 753 | | |
| |||
1511 | 1511 | | |
1512 | 1512 | | |
1513 | 1513 | | |
1514 | | - | |
1515 | | - | |
| 1514 | + | |
1516 | 1515 | | |
1517 | 1516 | | |
1518 | 1517 | | |
1519 | 1518 | | |
1520 | 1519 | | |
1521 | 1520 | | |
1522 | | - | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
1523 | 1524 | | |
1524 | 1525 | | |
1525 | 1526 | | |
1526 | 1527 | | |
1527 | 1528 | | |
1528 | | - | |
1529 | | - | |
1530 | | - | |
1531 | | - | |
1532 | | - | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
1533 | 1542 | | |
1534 | 1543 | | |
1535 | 1544 | | |
1536 | 1545 | | |
1537 | | - | |
1538 | | - | |
1539 | | - | |
1540 | | - | |
1541 | | - | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
1542 | 1576 | | |
1543 | 1577 | | |
1544 | 1578 | | |
1545 | 1579 | | |
1546 | 1580 | | |
1547 | | - | |
| 1581 | + | |
1548 | 1582 | | |
1549 | 1583 | | |
1550 | 1584 | | |
1551 | 1585 | | |
1552 | 1586 | | |
1553 | | - | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
1554 | 1591 | | |
1555 | 1592 | | |
1556 | 1593 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
522 | 522 | | |
523 | 523 | | |
524 | 524 | | |
525 | | - | |
526 | | - | |
527 | | - | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
528 | 528 | | |
529 | 529 | | |
530 | 530 | | |
| |||
968 | 968 | | |
969 | 969 | | |
970 | 970 | | |
971 | | - | |
972 | | - | |
973 | | - | |
974 | | - | |
975 | 971 | | |
976 | 972 | | |
977 | 973 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | 202 | | |
206 | 203 | | |
207 | 204 | | |
208 | 205 | | |
209 | 206 | | |
210 | | - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
211 | 212 | | |
212 | 213 | | |
213 | 214 | | |
| |||
0 commit comments