Commit Graph

127 Commits

Author SHA1 Message Date
Zoe Carver
b527bb5d3f Merge pull request #34730 from zoecarver/cxx/fix/nested-structs
[cxx-interop] Support nested C++ record types.
2020-11-14 12:41:08 -08:00
zoecarver
222d2fe709 [cxx-interop] Support nested C++ record types.
Simply returns "None" for C++ records in "getSpecialManglingContext"
(same logic as namespaces) to prevent an assertion.
2020-11-13 14:22:22 -08:00
zoecarver
bcf8733c2b [cxx-interop] Don't import C++ objects that we can't destroy.
Don't import C++ objects unless they have a public destructor that is not deleted.
2020-11-13 13:18:12 -08:00
zoecarver
08e7160cec [cxx-interop] Support templated C++ constructors. 2020-11-11 09:38:10 -08:00
zoecarver
d843279ea7 [cxx-interop] Bail instead of crashing If we cannot find a constructor decl in importNameImpl.
It's possible to have a "UnresolvedUsingValueDecl" with a "CXXConstructorName". If that's the case (or if there's any other unkown decl) bail instead of crashing.
2020-10-25 14:00:42 -07:00
zoecarver
d9acaf353e [cxx-interop] Merge synthesized initializer tests into "constructors-silgen".
We no longer synthesize initializers for C++ types so this name no longer makes sense.
2020-10-15 13:10:55 -07:00
zoecarver
2713edb19e [cxx-interop] Fix missing APIs and tests after rebase.
* Update tests that relied on old behavior.
 * Use mangleCXXName instead of mangleCXXCtor.
 * Call VisitCXXRecordDecl not VisitRecordDecl from
 VisitClassTemplateSpecializationDecl. This allows template constructors
 to be imported and called correctly.
2020-10-09 10:42:53 -07:00
Martin Boehme
faca489c6f Add a test that Objective-C types passed to a C++ constructor are
bridged correctly.
2020-10-09 10:42:52 -07:00
Martin Boehme
bed2603944 Various changes after merging master:
- Adapt tests to changes that have happened in the meantime (e.g.
  `HasVirtualBase` is rightly no longer considered loadable)
- Don't import copy or move constructors (noticed this because
  references are now imported correctly, so copy and move constructors
  suddenly started showing up in the SIL test)
- Don't try to define an implicitly-deleted default constructor (this
  previously broke loadable-types-silgen.swift)
2020-10-09 10:42:49 -07:00
Martin Boehme
3066e16c37 Remove redundant "cxx" from test names. 2020-10-09 10:42:48 -07:00
Martin Boehme
b2c5a3eeed Add a constructor thunk if required to add additional constructor
arguments.

Also add more IR tests and make various other changes.
2020-10-09 10:42:48 -07:00
Martin Boehme
fd00bc1f01 Move tests from CXXInterop to Interop/Cxx.
This is the canonical location that we've agreed on.
2020-10-09 10:42:47 -07:00
Zoe Carver
63875e9e8f [cxx-interop] [IRGen] TypeInfo for address-only types. (#32973)
The current "ClangRecordTypeInfo" derives from "LoadableTypeInfo" and is
only meant for loadable types. While we have not yet run into problems,
this may cause issues in the future and as more logic is needed around
copying, moving, and destroying C++ objects, this needs to be fixed.
2020-08-10 10:41:21 -07:00
zoecarver
5c3ccf5050 [cxx-interop] Temporarily disable emitting debug info for C++ types.
When we try to emit debug info from C++ types we crash because we can't deserialize them. This is a temporary fix to circumnavigate the crash before a real fix can be created.
2020-07-23 12:10:06 -07:00
zoecarver
13632d4c9c [cxx-interop] Mark types with a destructor a non-trivial.
Any C++ type that isn't trivially copyable is now also not a trivial type. This will preserve the destructor (among other things).
2020-07-10 08:51:30 -07:00
zoecarver
4b14487345 [NFC] [cxx-interop] Add SILGen tests for synthesized initializers.
Adds a basic test that the synthesized C++ constructor was generated correctly.
2020-07-02 15:07:42 -07:00
Martin Boehme
1607ecfb0a Fix warnings in loadable-types.h.
The copy and move assignment operators weren't returning anything and
were hence producing "non-void function does not return a value"
warnings.

As the test doesn't actually need a definition for these operators, I've
removed the definition and simply declared them.
2020-05-20 08:08:51 +02:00
Michael Forster
e69abeba53 Classify C++ structs as loadable or address-only (#31707)
* Classify C++ structs as loadable or address-only

C++ structs are only loadable if they are trivially copyable.

Resolves SR-12472.
2020-05-13 17:16:47 +02:00
Michael Forster
07c9fdd9e6 Synthesize memberwise initializers despite member functions
Previously unimportable member functions inhibited the synthesis of
memberwise initializers.
2020-05-08 14:26:21 +02:00
Dmitri Gribenko
e355430927 Merge pull request #31619 from MForster/m/memberwise-initializer
Synthesize memberwise initializers despite AccessSpecDecl
2020-05-08 01:07:49 +02:00
Dmitri Gribenko
53055fa73c Merge pull request #31617 from martinboehme/cxx-protocol-conformance
Add a test that imported C++ classes can conform to protocols
2020-05-07 19:46:26 +02:00
Michael Forster
d611b4c4f5 Synthesize memberwise initializers despite AccessSpecDecl
Previously the mere presence of `public:` or `private:` inhibited the
synthesis of memberwise initializers.
2020-05-07 17:44:41 +02:00
Martin Boehme
6224909d37 Add a test that imported C++ classes can conform to protocols.
Currently, trying to do this causes an assertion failure in SILGen, so the
corresponding line in the SILGen test is commented out.

See https://bugs.swift.org/browse/SR-12750
2020-05-07 14:43:21 +02:00
Marcel Hlopko
2fbcf184ed Add header guards to test/Interop 2020-04-30 16:13:33 +02:00
Marcel Hlopko
6c9ccbc59b Add header guards for test input headers 2020-04-30 15:49:20 +02:00
Michael Forster
f609a7cbb4 Unify layout for C++ interop tests
This was discussed here:
https://forums.swift.org/t/reorganize-swift-compiler-tests-for-c-objc-c-interop/34411

Resolves: [SR-12475](https://bugs.swift.org/browse/SR-12475)
2020-04-06 09:38:18 +02:00
Michael Forster
98bbb81f82 [C++] Make const member variables read-only
This imports const members of C++ structs/classes stored properties with
an inaccessible setter.

Note that in C++ there are ways to change the values of const members,
so we don't use `WriteImplKind::Immutable` storage.

Resolves: [SR-12463](https://bugs.swift.org/browse/SR-12463)
2020-04-03 13:15:33 +02:00