Commit Graph

15 Commits

Author SHA1 Message Date
Egor Zhdan
eb7adc794d [cxx-interop] Do not import arithmetic operators with rvalue reference parameters
Currently those operators are imported with a `consuming:` label, which isn't valid in Swift.

We could just remove the label from these parameters, but that introduces a source breakage due to name lookup ambiguity.

So, to avoid ambiguity, let's not import such operators into Swift.

rdar://149020099
2025-04-11 17:07:37 +01:00
susmonteiro
b7c5a47898 [cxx-interop] Fix crash when operator doesn't name parameter in header 2025-01-28 16:26:27 +00:00
Egor Zhdan
954e74001c [cxx-interop] Drop return values of +=, -=, *=, /=
These operators return `Void` in Swift, let's drop the return type of these operators when importing them from C++.

This is needed for the upcoming `UnsafeCxxRandomAccessIterator` protocol: if a protocol declares `func +=` returning `Void`, but the implementation non-`Void`, that causes a typechecker error.
2022-10-11 17:59:22 +01:00
zoecarver
da2791eb45 [cxx-interop] Add plus-equal, minus-equal, star-equal, slash-equal operators. 2022-09-23 10:56:43 -07:00
Ehud Adler
e7fe6f0fe7 Fix tests and re-enable support for CXX operators 2022-05-21 21:28:03 -04:00
zoecarver
839839f924 [cxx-interop] Rename enable-cxx-interop -> enable-experimental-cxx-interop.
Also removes the driver flag, this will now also always be guarded on `-Xfrontend`.
2022-04-07 19:15:25 -07:00
zoecarver
f652361af3 [cxx-interop] Remove 'support' for importing C++ operators.
This does not include subscript operators.

Before this is re-enabled operators need to be re-implemented. Right now they are the source of a lot of bugs. They cause frequent crashes and mis compiles. Also, templated operators insert a lot of names into global lookup which causes problems.

They also don't work on Windows.
2022-03-30 15:39:35 -07:00
Egor Zhdan
b506057fc7 C++ Interop: import caret operators
This change makes it possible to call `operator^` from Swift. It works exactly the same way as all the other arithmetic operators.
2021-09-04 16:26:15 +03:00
Egor Zhdan
6d5eba92b9 C++ Interop: cleanup operator tests (NFC) 2021-02-25 01:16:49 +03: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
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