Commit Graph

1871 Commits

Author SHA1 Message Date
Egor Zhdan
109d44c541 [cxx-interop] Emit LValue type in a base subscript assignment expression
This fixes an assertion that tripped when running `member-inline.swift` test with an unrelated patch:
```
type is not an l-value in LHS of assignment: Int32
...
3.	While walking into body of setter for subscript(_:) (in module 'MemberInline')
```
2022-08-12 16:22:48 +01:00
swift-ci
41366ebccd Merge remote-tracking branch 'origin/main' into rebranch 2022-08-12 03:54:16 -07:00
Egor Zhdan
51a1176d90 [cxx-interop] Clang member lookup should not look into Swift extensions
Calling `NominalTypeDecl::lookupDirect` triggers deserialization of Swift extensions for the type. `ClangRecordMemberLookup` shouldn't assume it is allowed to deserialize Swift extensions for the given C++ type: there might be extensions which reference the module that is currently being imported, which causes circular request dependency errors.
2022-08-08 17:05:25 +01:00
Hamish Knight
6b9bcf3935 [AST] Change DotSyntaxCallExpr to take an Argument base
This allows us to more easily propagate inout
information to it, which will become a necessity
once InOutExpr is removed.
2022-08-08 15:11:00 +01:00
Hamish Knight
ee49794d0f [AST] Introduce Argument::implicitInOut
This will allow us to abstract away the creation
of InOutExpr for bits of code synthesis.
2022-08-08 15:10:51 +01:00
swift-ci
4e2838d9f1 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-23 20:53:19 -07:00
Zoe Carver
bd003bcd7f Merge pull request #59509 from zoecarver/frt-with-ref-counting
[cxx-interop] Add support for reference counting operations on foreign reference types.
2022-07-23 20:51:39 -07:00
zoecarver
a18abb7a49 [cxx-interop] Move definition of debug functions to be accessable in AST. 2022-07-22 10:24:12 -04:00
Arnold Schwaighofer
2c682ae698 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-21 15:15:40 -07:00
zoecarver
13b0a5bc37 [nfc] Clang format changes. 2022-07-21 17:34:36 -04:00
zoecarver
446b2c38ab [cxx-interop] Add source locations to diagnostics for un-importable APIs. 2022-07-21 14:59:27 -04:00
zoecarver
74d76e2888 [cxx-interop] Add diagnostics and validation for retain/release function; require all foreign reference types to provide retain release functions or be immortal. 2022-07-21 12:25:21 -04:00
swift-ci
81f8371ef5 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-21 07:13:25 -07:00
Zoe Carver
0654bca2e7 Merge pull request #60149 from zoecarver/disable-eager-import
[cxx-interop] Add back 'import_as_ref' attr for libswift hosttools.
2022-07-21 10:06:16 -04:00
swift-ci
a5e7bd7dd3 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-20 07:53:55 -07:00
zoecarver
721fc6945d [cxx-interop] Add back 'import_as_ref' attr for libswift hosttools. 2022-07-20 10:12:32 -04:00
Egor Zhdan
d85d2e9e75 [cxx-interop] Synthesize conformances to UnsafeCxxInputIterator
This teaches ClangImporter to synthesize conformances of C++ iterator types to `UnsafeCxxInputIterator` protocol from the `Cxx` module.

We consider a C++ type to be an iterator if it defines a subtype (usually a typedef or a using decl) called `iterator_category` that inherits from `std::input_iterator_tag`.

rdar://96235368
2022-07-20 11:44:25 +01:00
swift-ci
9de631f94f Merge remote-tracking branch 'origin/main' into rebranch 2022-07-19 17:35:57 -07:00
zoecarver
ba7e6e44aa [cxx-interop] Fix predicate to find copy assignment operators. 2022-07-19 16:38:57 -04:00
zoecarver
09384be097 [cxx-interop] Simplify logic in IsSafeUseOfCxxDecl; fix bug for pointer types.
Previously types containing pointers would mark all C++ methods as unsafe.
2022-07-18 17:15:16 -04:00
zoecarver
3498ff9765 [cxx-interop] Remove UnsafeLifetimeOperation record semantic kind.
This makes "owned" the default kind for records that have custom copy constructors and no pointer-members.
2022-07-18 17:15:15 -04:00
zoecarver
ca5fa9aa9b [nfc] Clang format changes. 2022-07-18 17:15:15 -04:00
zoecarver
9d1d03124b [nfc][cxx-interop] Add diagnostics when something cannot be imported. 2022-07-18 17:15:15 -04:00
zoecarver
6acffbbee6 [cxx-interop] Flip the switch: only import safe APIs. 2022-07-18 17:15:15 -04:00
swift-ci
968e43db49 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-08 07:34:44 -07:00
Egor Zhdan
59cc7c49e3 [cxx-interop] NFC: fix bad merge
`getModuleMapFilePath` and related logic was moved to `ClangIncludePaths.cpp` recently, but got resurrected in `ClangImporter.cpp` by accident.
2022-07-08 12:41:46 +01:00
swift-ci
d4005d615f Merge remote-tracking branch 'origin/main' into rebranch 2022-07-06 09:55:20 -07:00
zoecarver
3805828ad0 [cxx-interop] Add CxxShim library; move __swift_interopStaticCast into it. 2022-07-05 15:52:51 -07:00
swift-ci
02522806f2 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-04 03:13:20 -07:00
Egor Zhdan
cf3354222d [Glibc] Use VFS to inject modulemap into Glibc include path
This will fix modularization issues caused by the presence of Glibc and libstdc++ in a single context.

Some Glibc headers were getting hijacked by the libstdc++ module, and the decls in them were incorrectly determined to be a part of libstdc++. This caused compiler errors when trying to use those decls.

After this change, we will be able to reference Glibc headers directly from the module map, without using an additional header (`SwiftGlibc.h`).
2022-07-01 23:49:12 +01:00
swift-ci
4107d01ef9 Merge remote-tracking branch 'origin/main' into rebranch 2022-06-30 11:34:11 -07:00
Egor Zhdan
a2fb2d0b78 [ClangImporter] NFC: extract Clang include path mapping logic into a separate file
This logic is going to be extended to inject the modulemap and the header of Glibc in addition to libstdc++. It doesn't depend on the rest of ClangImporter, so let's extract it to a separate file to make incremental builds and IDE features faster.
2022-06-30 15:50:33 +01:00
swift-ci
a12ece4179 Merge remote-tracking branch 'origin/main' into rebranch 2022-06-24 20:54:07 -07:00
Holly Borla
429488f6c9 [Sema] Use ExistentialType for Any and AnyObject. 2022-06-17 18:29:15 -07:00
swift-ci
55000f53be Merge remote-tracking branch 'origin/main' into rebranch 2022-06-17 10:15:14 -07:00
Becca Royal-Gordon
9b5f89963b [NFC] Serialize ObjC selectors for protocols
The ObjCMethodLookupTable for protocols was not being serialized and rebuilt on load, so NominalTypeDecl::lookupDirect() on selectors was not working correctly for deserialized types. Correct this oversight.
2022-06-16 14:07:49 -07:00
swift-ci
0c44504e3a Merge remote-tracking branch 'origin/main' into rebranch 2022-06-15 02:34:04 -07:00
Egor Zhdan
81b18d211d [cxx-interop] Pass --gcc-toolchain to Clang driver when determining include paths 2022-06-15 01:45:52 +01:00
swift-ci
40c801f236 Merge remote-tracking branch 'origin/main' into rebranch 2022-06-09 13:52:42 -07:00
Egor Zhdan
31381a352a [cxx-interop] Fix assertion failure when looking up C++ operators
Previously when looking up a C++ operator (e.g. `==`), `ClangImporter::Implementation::lookupValue` returned a Swift function with a generated name (e.g. `func __operatorEqualEqual`), while the caller expected the result to be a Swift operator (e.g. `func ==`).

This change makes sure that we're returning a synthesized Swift operator when looking for a C++ operator.

This fixes an assertion failure in the typechecker:
```
swift-frontend: /home/build-user/swift/lib/Sema/ConstraintSystem.cpp:1454: std::pair<Type, Type> swift::constraints::ConstraintSystem::getTypeOfReference(swift::ValueDecl *, swift::FunctionRefKind, swift::constraints::ConstraintLocatorBuilder, swift::DeclContext *): Assertion `func->isOperator() && "Lookup should only find operators"' failed.
```
2022-06-09 19:24:13 +01:00
swift-ci
604953d20a Merge remote-tracking branch 'origin/main' into rebranch 2022-06-02 12:14:21 -07:00
Ben Barham
65ed78d3e7 Merge branch 'main' into manually-merge-main 2022-06-02 10:14:57 -07:00
Ehud Adler
0d7a0416e7 Removed extra string include 2022-06-02 13:00:22 -04:00
Zoe Carver
4967cd58a1 Merge pull request #58910 from Huddie/update-cxx-operator-impl 2022-06-01 20:31:18 -07:00
Ehud Adler
54ed81c427 Format 2022-06-01 14:54:07 -04:00
Ehud Adler
1d1df27d4a Fix switch error + format 2022-06-01 14:40:27 -04:00
swift-ci
e46b2c3efe Merge remote-tracking branch 'origin/main' into rebranch 2022-06-01 08:13:51 -07:00
Zoe Carver
d48c5fbbb1 Merge pull request #59022 from skrtks/cxx_inherited_attributes 2022-06-01 08:08:23 -07:00
swift-ci
57042b20d7 Merge remote-tracking branch 'origin/main' into rebranch 2022-05-31 11:54:15 -07:00
Egor Zhdan
c70d8fdd9b Merge pull request #59050 from apple/egorzhdan/libstdcxx-sysroot
[cxx-interop] Pass sysroot to the Clang driver when detecting libstdc++ path
2022-05-31 19:40:39 +01:00