Commit 128064f
committed
[cxx-interop] Enable virtual function calling from Swift to C++
This is a forward-interop feature that wires up existing functionality for
synthesizing base class function calling to enable virtual function calling.
The general idea is to sythesize the pattern:
```
// C++ class:
struct S { virtual auto f() -> int { return 42; } };
// Swift User:
var s = S()
print("42: \(s.f())")
// Synthetized Swift Code:
extension S { func f() -> CInt { __synthesizedVirtualCall_f() } }
// Synthetized C/C++ Code:
auto __cxxVirtualCall_f(S *s) -> int { return s->f(); }
```
The idea here is to allow for the synthetized C++ bits from the Clang side to
handle the complexity of virtual function calling.1 parent 520e124 commit 128064f
File tree
7 files changed
+84
-12
lines changed- lib/ClangImporter
- test/Interop/Cxx/class/inheritance
- Inputs
7 files changed
+84
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4785 | 4785 | | |
4786 | 4786 | | |
4787 | 4787 | | |
4788 | | - | |
| 4788 | + | |
| 4789 | + | |
4789 | 4790 | | |
4790 | 4791 | | |
4791 | 4792 | | |
| |||
4794 | 4795 | | |
4795 | 4796 | | |
4796 | 4797 | | |
4797 | | - | |
| 4798 | + | |
| 4799 | + | |
| 4800 | + | |
4798 | 4801 | | |
4799 | 4802 | | |
4800 | 4803 | | |
4801 | 4804 | | |
4802 | 4805 | | |
4803 | | - | |
| 4806 | + | |
| 4807 | + | |
4804 | 4808 | | |
4805 | 4809 | | |
4806 | 4810 | | |
4807 | | - | |
| 4811 | + | |
| 4812 | + | |
4808 | 4813 | | |
4809 | 4814 | | |
4810 | 4815 | | |
| |||
4930 | 4935 | | |
4931 | 4936 | | |
4932 | 4937 | | |
| 4938 | + | |
| 4939 | + | |
| 4940 | + | |
| 4941 | + | |
| 4942 | + | |
| 4943 | + | |
| 4944 | + | |
| 4945 | + | |
| 4946 | + | |
| 4947 | + | |
4933 | 4948 | | |
4934 | 4949 | | |
4935 | 4950 | | |
| |||
6555 | 6570 | | |
6556 | 6571 | | |
6557 | 6572 | | |
6558 | | - | |
| 6573 | + | |
6559 | 6574 | | |
6560 | 6575 | | |
6561 | 6576 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3711 | 3711 | | |
3712 | 3712 | | |
3713 | 3713 | | |
| 3714 | + | |
| 3715 | + | |
| 3716 | + | |
| 3717 | + | |
| 3718 | + | |
| 3719 | + | |
| 3720 | + | |
| 3721 | + | |
| 3722 | + | |
| 3723 | + | |
| 3724 | + | |
| 3725 | + | |
| 3726 | + | |
| 3727 | + | |
| 3728 | + | |
| 3729 | + | |
| 3730 | + | |
| 3731 | + | |
| 3732 | + | |
| 3733 | + | |
| 3734 | + | |
3714 | 3735 | | |
3715 | 3736 | | |
3716 | | - | |
| 3737 | + | |
| 3738 | + | |
| 3739 | + | |
3717 | 3740 | | |
3718 | 3741 | | |
3719 | 3742 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1988 | 1988 | | |
1989 | 1989 | | |
1990 | 1990 | | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
1991 | 2001 | | |
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
11 | 17 | | |
12 | 18 | | |
13 | 19 | | |
| |||
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
11 | 29 | | |
12 | 30 | | |
13 | 31 | | |
| |||
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
| 9 | + | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
| 14 | + | |
| 15 | + | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
0 commit comments