Commit Graph

1896 Commits

Author SHA1 Message Date
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
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