Commit Graph

17 Commits

Author SHA1 Message Date
Alex Lorenz
196c717a3d [interop] do not import function template with templated rvalue / perfect forwarding ref
they can cause compiler crashes
2023-05-04 14:41:28 -07:00
Josh Soref
e75e5b5a03 Spelling interop (#42549)
* spelling: different

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: disappear

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: executable

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: instantiate

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: instantiation

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: member

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: parameter

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: section

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: trivia

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: unrelated

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-22 14:13:23 -07: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
Egor Zhdan
7bcd13b899 [cxx-interop] Avoid crashing when importing functions that take pointers to dependent types
Importing `type_traits` from libstdc++ currently causes a crash on Linux:
```
swift-ide-test: tools/clang/include/clang/AST/TypeNodes.inc:33: clang::TypeInfo clang::ASTContext::getTypeInfoImpl(const clang::Type *) const: Assertion `!T->isDependentType() && "should not see dependent types here"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/egorzh/Builds/swift/swift/bin/swift-ide-test -print-module -module-to-print=std -source-filename=x -enable-cxx-interop
1.	/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/type_traits:1110:10: importing 'std::__do_is_implicitly_default_constructible_impl'
2.	/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/type_traits:1116:22: importing 'std::__do_is_implicitly_default_constructible_impl::__test'
```

This change fixes the crash by bailing on such functions.
2022-03-21 20:33:26 +00:00
Alex Lorenz
ebb21d7ec1 [cxx-interop] Import const T& parameters as T.
This change allows Swift code to pass immutable values to const references in C++.
2022-03-03 14:42:27 -08:00
zoecarver
283fc782ec Revert "Revert "[cxx-interop] A few cleanups and fixes for function templates.""
This reverts commit 5de09631ff.
2022-02-15 13:30:10 -08:00
Zoe Carver
5de09631ff Revert "[cxx-interop] A few cleanups and fixes for function templates." 2022-02-13 09:54:39 -08:00
zoecarver
04d4e9dec3 [cxx-interop] Correctly map T& -> inout T.
This is important because the specialized template will be imported as `inout int` (for example) and we must make sure to match the signature.

Updates tests based on this and fixes a few tests that started failing after daceecfc75.
2022-02-04 16:58:31 -08:00
Omar Habra
7802b5f726 Adding Tests. 2021-11-20 14:53:22 -08:00
zoecarver
b8e52a7ad2 [cxx-interop] Lazily import members of Clang namespaces and records via requests.
Also adds a ClangImporter request zone and move some requests into it.
2021-10-20 14:52:43 -07:00
Josh Learn
f433ac2d58 Allow importing templated functions when template args do not appear
in the function signature by adding explicit metatype parameters to
the function signature.
2021-10-06 13:35:12 -07:00
zoecarver
bd96959d14 [cxx-interop] Re-implement namespaces using enums + extensions.
C++ namespaces are module-independent, but enums are owned by their module's in Swift. So, to prevent declaring two enums with the same name, this patch implements a new approach to namespaces: enums with extensions.

Here's an example:
```
// Module A
namespace N { void test1(); }
// Module B
namespace N { void test2(); }
// __ObjC module
enum N { }
// Swift module A
extension N { func test1() }
// Swift module B
extension N { func test1() }
```

Thanks to @gribozavr for the great idea.
2021-02-14 16:54:24 -08:00
zoecarver
c4da4975ed [NFC] Cleanup function templates implementation. Address post-commmit review comments from #33053.
Addresses the post-commit review comments from #33053. Just re-naming,
commenting, and some other small cleanups, nothing functionally
different.
2021-01-19 12:02:15 -08:00
zoecarver
3d6c8a7971 [cxx-interop] Fix assertion to allow variadic members.
Simply fixes an assertion to allow variadic member functions.
2020-11-30 11:55:56 -08:00
zoecarver
9c58a95755 [cxx-interop] Support function templates inside a namespace.
Thread "templateParams" through the call to find the function parameter
types when the function is in a namespace.
2020-11-10 18:49:51 -08:00
Zoe Carver
cb7bb52060 [cxx-interop] Support reference types in function templates. (#34536) 2020-11-06 17:13:41 -08:00
Zoe Carver
f0f2246793 [cxx-interop] Support C++ function templates in Swift. (#33053)
This patch adds rudimentary support for C++ template functions in swift.
2020-10-21 20:42:25 -07:00