Commit Graph

1889 Commits

Author SHA1 Message Date
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
Egor Zhdan
07aec92198 [cxx-interop] Pass sysroot to the Clang driver when detecting libstdc++ path
The Swift build scripts pass `-sdk /` to the Swift compiler when building the Swift stdlib and the overlays, and this affects the default include paths of Clang. We need to make sure that libstdc++ path detected by ClangImporter is the same path that will be used by Clang during compilation. To do that, let's pass `--sysroot` to the Clang driver when detecting the libstdc++ path.
2022-05-31 16:22:25 +01:00
swift-ci
fc001b2fcc Merge remote-tracking branch 'origin/main' into rebranch 2022-05-31 03:33:46 -07:00
Egor Zhdan
127e29f365 [cxx-interop] Do not warn about missing libstdc++ on Android
Android uses libc++.

This fixes a few tests on Android.
2022-05-30 23:22:03 +01:00
Ehud Adler
16c1e1defa Format 2022-05-26 21:29:43 -04:00
Ben Barham
92b6dd24c2 Merge branch 'main' into manually-merge-main 2022-05-25 15:55:35 -07:00
swift-ci
645d73f27e Merge pull request #58480 from beccadax/so-i-put-versions-in-your-version-numbers
Update SWIFT_COMPILER_VERSION language features
2022-05-24 17:47:43 -07:00
Sam Kortekaas
e73bb6fd9d [cxx-interop] Import attributes on inherited C++ methods 2022-05-23 13:21:06 +02:00
Ehud Adler
3196ea9b39 Refactor and format 2022-05-21 21:44:07 -04:00
Ehud Adler
e7fe6f0fe7 Fix tests and re-enable support for CXX operators 2022-05-21 21:28:03 -04:00
swift-ci
b83cd2f0a9 Merge remote-tracking branch 'origin/main' into rebranch 2022-05-19 03:33:42 -07:00
Egor Zhdan
abf56bcb33 [cxx-interop] Extract libstdc++ installation path from Clang
To inject a modulemap into the libstdc++ directory, Swift needs to know the path of the libstdc++ installation. Previously it was assumed to be `/usr/include/c++/{version}`, however, this might not be the case. For example, on CentOS the stdlib is located at `/opt/rh/devtoolset-{version}/root/usr/include/c++/{version}`.

This change teaches Swift to extract the libstdc++ include paths from the Clang driver, and fixes C++ stdlib lookup on CentOS.

rdar://93341210
2022-05-18 19:27:29 +01:00
Ehud Adler
11730e8f07 Remap class operator function names (-/+/*....) to imported operator names __operator(Minus, Plus,...) and fix test cases 2022-05-18 10:31:04 -04:00
Ehud Adler
4267958d51 Mapping decl base name to imported name 2022-05-18 10:31:04 -04:00
Ehud Adler
e14e2fbc76 Add changes 2022-05-18 10:31:03 -04:00
swift-ci
ea3d49ce7f Merge remote-tracking branch 'origin/main' into rebranch 2022-05-14 10:13:56 -07:00
Arnold Schwaighofer
9cb25736e0 ClangImporter.cpp: Fix compilation on some linux systems 2022-05-14 08:07:20 -07:00
swift-ci
658f98c851 Merge remote-tracking branch 'origin/main' into rebranch 2022-05-13 16:54:31 -07:00
Egor Zhdan
1ef02efed1 Merge pull request #58843 from apple/egorzhdan/libstdcxx-vfs
[cxx-interop] Use VFS to inject modulemap into libstdc++ installation
2022-05-14 00:40:16 +01:00
Egor Zhdan
f3790def63 [cxx-interop] Use VFS to inject modulemap into libstdc++ installation
Previously the modulemap for the C++ stdlib on Linux was provided via `-fmodule-map-file=` Clang argument pointing to the modulemap file within the Swift toolchain. The modulemap file could not reference the stdlib headers directly, since the exact stdlib include directory varies across Linux versions (it generally looks like `/usr/include/c++/{gcc_version}`). So the modulemap file instead referenced a local header, which `#include <>`-ed the stdlib headers, relying on Clang include resolution.

Unfortunately this did not work properly in the presence of another C++ module which included the stdlib headers: sometimes decls from the stdlib were hijacked by the other module, and were not treated as a part of the stdlib by Clang. This caused compile errors in Swift.

This change uses LLVM VFS to inject the modulemap file into the libstdc++ directory. The modulemap file is now able to reference the stdlib headers directly, which fixes the issue.

Credits to Rintaro Ishizaki for proposing a similar idea for SwiftGlibc back in 2016.
2022-05-13 22:21:40 +01:00
Ben Barham
87ce3bd38f Merge pull request #58774 from bnbarham/more-rebranch-fixes
[next] Disable opaque pointers by default
2022-05-09 18:21:01 -07:00
Ben Barham
edcd53b09f [next] Disable opaque pointers by default
LLVM has enabled opaque pointers by default. Disable while we migrate.
Note that individual tests can have opaque pointers enabled by using
`-Xcc -Xclang -Xcc -opaque-pointers`.
2022-05-09 16:17:55 -07:00
swift-ci
6a45007a08 Merge remote-tracking branch 'origin/main' into rebranch 2022-05-07 11:13:10 -07:00
Robert Widmann
77bf3aff93 Teach the ClangImporter About Mac Catalyst Availability
Add some missing definitions for the mac catalyst platform. This enables the importing of macCatalyst platform availability attributes.
2022-05-06 14:37:24 -07:00
Ben Barham
4e1eb1abe8 Merge pull request #58620 from bnbarham/rebranch-fixes
[rebranch] Various fixes to get macos to a compiling state
2022-05-06 09:59:38 -07:00
Ben Barham
0dff9ac150 [next] Update PPCallbacks::InclusionDirective overrides
`InclusionDirective` was changed in llvm/llvm-project
d79ad2f1dbc2db63121620f55d6cfa915f2733ac to pass an
`Optional<FileEntryRef>` rather than a `FileEntry *`. Update overrides
in Swift to use the new API.
2022-05-05 16:25:10 -07:00
Ben Barham
1531ed7a25 [next] Update ParseTopLevelDecl callers
`ParseTopLevelDecl` was changed in llvm/llvm-project
ab28488efe6de6f8fa856a1dfd8c0320d41d7608 and now takes a
Sema::ModuleImportState output parameter rather than the previous
(defaulted) boolean.
2022-05-05 16:25:10 -07:00
Egor Zhdan
dabaa69024 Merge pull request #58659 from apple/egorzhdan/cxx-namespace-lookup-fix
[cxx-interop] Fix namespace lookup
2022-05-04 18:51:08 +01:00
Egor Zhdan
7042fb5a07 Merge pull request #58637 from apple/egorzhdan/cxx-fix-use-string
[cxx-interop] Fix `test/Interop/Cxx/stdlib/use-std-string.swift`
2022-05-04 14:20:04 +01:00
Egor Zhdan
b3feb9e692 [cxx-interop] Fix namespace lookup
If a namespace has redecls in different modules, Swift sometimes picked a redecl which is not visible from the requested module, and wrongly removed the namespace from lookup results.

This resulted in errors like this:
```
*** DESERIALIZATION FAILURE ***
Could not deserialize type for 'init(cxxString:)'
Caused by: top-level value not found (std)
Cross-reference to module '__ObjC'
... std
```
2022-05-04 13:29:38 +01:00
Egor Zhdan
48208380e3 Merge pull request #58543 from apple/egorzhdan/cxx-template-inst-lookup
[cxx-interop] Fix lookup of class template instantiations
2022-05-03 19:46:25 +01:00
Egor Zhdan
7db3666e43 [cxx-interop] Fix test/Interop/Cxx/stdlib/use-std-string.swift
Temporarily disable the checks for mutable fields in a C++ struct. A better solution would be to use some heuristic to detect if a method mutates a mutable field, and allow the user to adjust mutability with the existing `nonmutating` annotation.

rdar://92621793
2022-05-03 16:36:40 +01:00
Egor Zhdan
c952fc175b [cxx-interop] Fix lookup of class template instantiations
To fix a crash during deserialization, we need to store the mangled names of C++ class template instantiations in the lookup table.

For example, `std::string` will be serialized as `__CxxTemplateInstNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE`, and when another instance of the Swift compiler will later attempt to deserialize a decl referencing this instantiation, it will query the `SwiftLookupTable` for a decl with this name. If this instantiation is not referenced from the module that is currently being compiled, Swift will not instantiate `std::string` during typechecking, and the mangled name will be missing from `SwiftLookupTable`, leading to a deserialization failure. This happens when compiling with cross-module optimization enabled, and the current module does not reference `std::string`, but one of its dependencies does.
2022-04-29 21:55:59 +01:00