Commit Graph

597 Commits

Author SHA1 Message Date
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
Zoe Carver
dfe92be435 Merge pull request #34424 from zoecarver/cxx/templated-constructors
[cxx-interop] Support templated constructors.
2020-11-11 12:10:38 -08:00
zoecarver
08e7160cec [cxx-interop] Support templated C++ constructors. 2020-11-11 09:38:10 -08:00
Robert Widmann
363b66a7ad Fully Qualify the Parent Type When Diagnosing Missing Member Types
Use the FullyQualified<Type> abstraction from the prior commit plus DescriptiveDeclKind to give a bit more information when issuing a missing member type diagnostic during type resolution.
2020-11-09 17:10:18 -08:00
Artem Chikin
3b545498d0 Merge pull request #34331 from artemcm/NoFoundationOnExplicitImportSoil
[Clang Importer] Do not rely on being able to always import Foundation on-demand
2020-11-02 13:02:15 -08:00
swift-ci
8ec7bdf634 Merge pull request #34429 from zoecarver/cxx/skip-unkown-constructor-names 2020-10-31 20:05:26 -07:00
Artem Chikin
e98dbc88fd Import Foundation in cxx interop tests that explicitly use/bridge its types 2020-10-29 10:37:01 -07:00
zoecarver
b7f656aa0d [cxx-interop] Use regex instead of operand name to fix C++ constructor tests. 2020-10-28 15:36:08 -07:00
Arnold Schwaighofer
6afe07d5f8 Disable two tests
rdar://70772958
2020-10-28 12:22:13 -07: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
1d3b051151 [cxx-interop] Remove logic around applying attributes.
Removes the logic around applying attributes to C++ constructor's
indirect results.

Also fixes some commenting.
2020-10-15 13:10:55 -07:00
zoecarver
b2bb47dee5 [cxx-interop] Fix Windows tests for non-trivial C++ types.
* Replace `??1` with `??0` prefix in SILGen tests.
* Replace `call void <constructor>` with `call {{.*}} <constructor>`
because Windows ABI sometimes returns a pointer from the constructor for
non-trivial types.
* Make `noalias` an optional check.
2020-10-15 13:10:55 -07:00
zoecarver
4364af39ee [cxx-interop] Small fixes and cleanup based on review.
* Check isAggregate instead of hasUserDeclaredConstructor.
 * Rename addEmptyArgNamesForCxxFunc ->  addEmptyArgNamesForClangFunction.
 * Other minor fixes and cleanups.
2020-10-09 10:42:54 -07:00
zoecarver
f04de9f128 [cxx-interop] Skip metatypes when lowering C++ constructor SIL function type.
When lowering a C++ constructor's function type to a SIL function type,
skip over the "self" metatype parameter.
2020-10-09 10:42:54 -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
cc7564ecd1 Rename constructors-sil.swift to constructors-silgen.swift. 2020-10-09 10:42:52 -07:00
Martin Boehme
83b51b95b5 Add SILGen and IRGen tests for passing Objective-C types to C++
constructors.
2020-10-09 10:42:52 -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
7e8ea12070 Respond to review comments. 2020-10-09 10:42:51 -07:00
Martin Boehme
c9405fb7fc Add Windows-name-mangled version of symbol to SIL test. 2020-10-09 10:42:50 -07:00
Martin Boehme
8f6042aa08 Add additional IR tests for a class without a virtual base class. 2020-10-09 10:42:50 -07:00
Martin Boehme
8416ccfa06 Rename constructors-ir.swift to constructors-irgen.swift. 2020-10-09 10:42:50 -07:00
Martin Boehme
beaaa742c3 Don't put an sret attribute on the this argument. 2020-10-09 10:42:49 -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
aa5195aa89 Remove unneeded CHECK in type-classification-non-trivial-irgen. (#33474)
This CHECK line didn't use an alias, so it caused the CI to fail. It turns out the CHECK line isn't actually needed.
2020-08-14 09:28:15 -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
98803ec992 [cxx-interop] [nfc] HasMemberWithDestructor => StructWithSubobjectDestructor in comment.
The type "HasMemberWithDestructor" doesn't exist. It was replaced with
StructWithSubobjectDestructor but the comment wasn't updated.
2020-07-27 19:15:05 -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
Dmitri Gribenko
3de9e5ac77 Rename synthesized initializer test to follow the pattern
And also removed a test that is semantically a duplicate of the
synthesized initializer test.
2020-07-09 12:11:08 +02: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
Marcel Hlopko
883262771b Expose C++ static members as Swift static properties 2020-04-23 15:33:43 +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