Commit Graph

19 Commits

Author SHA1 Message Date
Puyan Lotfi
864b3a47e3 [cxx-interop] Implement operator[] for value return types (SR-14351).
This builds on top of the work of Egor Zhdan. It implements
`T operator[]` and does so largely by taking a path very much like the
`const T &operator[]` path.
2021-04-08 00:18:27 -04:00
Egor Zhdan
586c675286 C++ Interop: import subscript operators
This change adds support for calling `operator[]` from Swift code via a synthesized Swift subscript.

Fixes SR-12598.
2021-03-21 19:25:41 +03:00
Egor Zhdan
7141ae24cf C++ Interop: import call operators
This change adds support for calling `operator()` from Swift code.

As the C++ interop manifesto describes, `operator()` is imported into Swift as `callAsFunction`.
2021-03-02 21:13:57 +03:00
Egor Zhdan
6d5eba92b9 C++ Interop: cleanup operator tests (NFC) 2021-02-25 01:16:49 +03:00
Saleem Abdulrasool
df9d1e815f Interop/Cxx: explicitly require C++ for modules
The C++ interop modules require C++ support.  Explicitly require C++ as
a feature when building these modules.  This has no impact on the
changes as all the tests enable C++ already.
2021-01-06 16:59:42 -08:00
Zoe Carver
1f71144183 [cxx-interop] Don't crash for unkown inline-operator. (#34602)
Skip unkown or unimportable inline operators (such as deleted operator members) instead of crashing.
2020-11-06 17:13:59 -08:00
Zoe Carver
be2f85c102 [cxx-interop] [NFC] Rename MemberInline.IntBox -> LoadableIntWrapper. (#33930) 2020-09-24 20:08:19 -07:00
zoecarver
d647794ac0 [cxx-interop] Replace inline member "operator+" with "operator-".
Adding integers is a commutative operation meaning the old tests would
fail to detect an error if the arguments were passed in the wrong order.
Testing inline member operators using subtraction ensures that arguments
are passed in the correct order.
2020-09-08 21:09:43 -07:00
Michael Forster
d530e36236 Add tests for C++ out-of-line member operators (#32718) 2020-07-07 19:26:23 +02:00
Michael Forster
26358c4588 Import member operator functions as static members (#32293)
This adds support to `ClangImporter` to import C++ member function operators as static methods into Swift, which is part of SR-12748.

The left-hand-side operand, which gets passed as the `this` pointer to the C++ function is represented as an additional first parameter in the Swift method. It gets mapped back in SILGen.

Two of the tests are disabled on Windows because we can't yet call member functions correctly on Windows (SR-13129).
2020-07-03 11:06:22 +02:00
zoecarver
3a23e086d2 [cxx-interop] Re-order operators.
Re-order operator case statements and tests. The order now follows the order defined in `llvm-project/clang/include/clang/Basic/OperatorKinds.def`.

Also, adds operator character(s) in parentheses.
2020-06-17 15:54:09 -07:00
zoecarver
d411f92cdd [cxx-interop] Add support for C++ comparison operators.
Adds support for C++ operators: `<`, `>`, `==`, `!=`, `<=`, and `>=`.
2020-06-17 15:54:09 -07:00
Zoe Carver
71d2c37828 [cxx-interop] Add support for percent, ampersand, and pipe operators. (#32332)
Adds support for three more basic infix operators: `%`, `&`, and `|`.

Co-authored-by: Michael Forster <forster@google.com>
2020-06-12 12:30:33 -07:00
Zoe Carver
1e52852cca [cxx-interop] Add support for C++ shift operators. (#32333)
* [cxx-interop] Add support for C++ shift operators.

Support imported C++ `<<` and `>>` operators in Swift.

* Update test names of existing operators

... to match the new ones.

Co-authored-by: Michael Forster <forster@google.com>
2020-06-12 08:40:25 -07:00
zoecarver
d4431c4883 [cxx-interop] Add support for C++ logical and/or operators.
Support imported C++ `&&` and `||` operators in Swift.
2020-06-11 17:08:12 -07:00
Michael Forster
0838a65e0d Test C++ out-of-line operator functions
Add a test to verify that C++ out-of-line operator functions are imported correctly.
Includes fixes for armv7 and arm64.

This is part of addressing SR-12748.
2020-06-05 12:32:23 +02:00
Michael Forster
e5e34fa3c9 Revert "Test C++ out-of-line operator functions (#32081)" (#32181)
This reverts commit f7473a7432.
2020-06-04 19:10:04 +02:00
Michael Forster
f7473a7432 Test C++ out-of-line operator functions (#32081)
Add tests to verify that C++ out-of-line operator functions are
imported correctly.
2020-06-03 10:37:27 +02:00
Michael Forster
c98c862e7e Start implementing C++ operator interop (#32015)
This imports the four basic arithmetic operators `+`, `-`, `*`, `/`
declared as inline non-member functions.

More to come.
2020-05-28 17:31:36 +02:00