Commit Graph

1877 Commits

Author SHA1 Message Date
Jan Svoboda
7f344cbf25 [ClangImporter] Pass SourceLocation to lookupModule 2021-10-21 14:24:11 +02:00
zoecarver
b8e52a7ad2 [cxx-interop] Lazily import members of Clang namespaces and records via requests.
Also adds a ClangImporter request zone and move some requests into it.
2021-10-20 14:52:43 -07:00
Ellie Shin
6f34844b49 Merge pull request #39705 from apple/es-module-alias-serialize
[Module aliasing] Serialize SIL and binaries with module real names for referenced or imported modules. Resolves rdar://83632529
2021-10-18 21:55:45 -07:00
zoecarver
0ca8dd364f [nfc][cxx-interop] Add three requests ClangDirectLookupRequest, CXXNamespaceMemberLookup, and ClangRecordMemberLookup.
None of these requests are used, so this is a non-functional change.
2021-10-13 16:31:09 -07:00
Zoe Carver
40422f021b Merge pull request #39664 from zoecarver/lazy-pt9-use-lookup-table
[cxx-interop] Add members to the LookupTable where possible.
2021-10-13 15:29:31 -07:00
zoecarver
eeeb27d66e [cxx-interop] Add members to the LookupTable where possible.
If possible, add imported members to the StructDecl's LookupTable rather than adding them directly as members. This will fix the issues with ordering that #39436 poorly attempted to solve during IRGen.

This also allows us to break out most of the test changes from #39436.
2021-10-13 11:53:58 -07:00
Daniel Rodríguez Troitiño
0392181c23 Merge pull request #39653 from NuriAmari/auto
NFC: Remove Decl* declarations made using auto
2021-10-12 18:11:35 -07:00
elsh
adf33e0bb9 Add doc comments
Rename test
2021-10-12 15:03:30 -07:00
elsh
96fb3d6112 [Module aliasing] Serialize binary with module real name
Resolves rdar://83632529
2021-10-12 13:59:34 -07:00
Mishal Shah
c2fd49cebb Merge pull request #39473 from apple/rebranch
Update swift:main to support llvm-project:stable/20210726 changes (Rebranch merge)
2021-10-11 09:00:51 -07:00
Zoe Carver
f189992189 Merge pull request #39431 from zoecarver/lazy-pt3-print-objc-module
[cxx-interop] Print decls in the __ObjC module.
2021-10-07 17:50:59 -07:00
Nuri Amari
03d4d11216 Remove Decl* declarations made using auto
A non functional change replacing auto with
Decl* for some declarations using ClangImporter::Implementation::importDecl.
Increases clarity and makes subsequent planned changes easier.
2021-10-07 11:15:07 -04:00
swift-ci
3f8fea8508 Merge remote-tracking branch 'origin/main' into rebranch 2021-10-06 10:17:29 -07:00
Artem Chikin
ae727e1348 Merge pull request #39509 from artemcm/FixExplicitPCMWarnings
Fix `'linker' input unused` warnings in Explicit Module Builds
2021-10-01 13:03:49 -07:00
Artem Chikin
aa31794049 [Clang Importer] Pass in clang executable argument even if -only-use-extra-clang-opts is specified.
Instead of *just* passing in `ExtraArgs`, we need to make sure to still form a command-line according to Clang's expectation.
2021-09-30 15:29:13 -07:00
swift-ci
c51550f30e Merge remote-tracking branch 'origin/main' into rebranch 2021-09-30 15:11:41 -07:00
Xi Ge
a4b4b1fa65 ClangImporter: don't import clang SPI attributes by default 2021-09-28 10:46:27 -07:00
swift-ci
3b702bf6e4 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-24 11:54:10 -07:00
Egor Zhdan
e1c4ea50c8 Merge pull request #37806 from egorzhdan/clang-executable-path-reapply
ClangImporter: run Clang with a proper executable path (pt 2)
2021-09-24 21:46:03 +03:00
swift-ci
588a179e3d Merge remote-tracking branch 'origin/main' into rebranch 2021-09-24 10:13:18 -07:00
Zoe Carver
6467d0ec1a Merge pull request #39429 from zoecarver/lazy-pt1-clang-module-loader
[nfc][cxx-interop] Add three utilities to the `ClangModuleLoader`.
2021-09-24 13:04:03 -04:00
zoecarver
d13f43c31b [cxx-interop] Add three utilities to the ClangModuleLoader.
This adds `importDeclDirectly`, `findLookupTable`, `importName`, and `getEffectiveClangContext`. These are all needed for #38675.
2021-09-23 16:51:03 -07:00
zoecarver
3454f903bf [cxx-interop] Print decls in the __ObjC module.
This is one change from #38675.
2021-09-23 15:27:32 -07:00
Karoy Lorentey
e767873ea7 [ClangImporter] Explicitly enable cx16 on every platform 2021-09-22 21:00:18 -07:00
Karoy Lorentey
aa0aa5b12b [ClangImporter] Pass -mcx16 to Clang invocation for x86_64 Linux targets
The Swift runtime and the concurrency module both use -mcx16, so there seems to be little point in not enabling it for Swift code in general.

This allows packages like swift-atomics to rely on double wide atomics always being available.

https://bugs.swift.org/browse/SR-13781
2021-09-22 18:42:08 -07:00
swift-ci
a8dc9f7d6f Merge remote-tracking branch 'origin/main' into rebranch 2021-09-09 08:53:29 -07:00
zoecarver
6e9bf50996 [cxx-interop] Lazily load the result of imported functions.
Note: we only lazily load the result if it's a record, because otherwise it's trivial to load when importing the function. Also, we still eagerly import operator's results types.
2021-09-08 17:48:39 -07:00
swift-ci
e25cb8a958 Merge remote-tracking branch 'origin/main' into rebranch 2021-07-28 12:17:04 -07:00
Egor Zhdan
a8f126f7cd C++ Interop: import const methods as non-mutating
This change makes ClangImporter import some C++ member functions as non-mutating, given that they satisfy two requirements:
* the function itself is marked as `const`
* the parent struct doesn't contain any `mutable` members

`get` accessors of subscript operators are now also imported as non-mutating if the C++ `operator[]` satisfies the requirements above.

Fixes SR-12795.
2021-07-25 15:18:33 +03:00
swift-ci
67017f7f6d Merge remote-tracking branch 'origin/main' into rebranch 2021-07-24 03:53:49 -07:00
Egor Zhdan
cfc9483f1a C++ Interop: import namespaces redecls as separate extensions
Previously a namespace declaration was imported along with all of its redeclarations, and their members were added to a single Swift extension. This was problematic when a single namespace is declared in multiple modules – the extension belonged to only one of them.
For an example of this, try printing a module interface for `std.string`/`std.iosfwd` – it will be empty, even though the declarations from those modules are actually imported into Swift correctly.

This change makes sure that when we're importing different redeclarations of the same namespace, we're adding them as separate extensions to appropriate modules.
2021-07-23 23:38:46 +03:00
Evan Wilde
569e66c518 Fix TargetInfo::adjust call
Adjust now takes the diagnostic engine and the language options.
Actually pass those in now too.
2021-07-09 13:19:39 -07:00
Ben Barham
28bb2505b0 [ClangImporter] Respect -working-directory in the created VFS
Pass a wrapped VFS down into `clang::createInvocationFromCommandLine` so
that the working directory is set and then used in the underlying Clang
`CompilerInstance`.

Fixes the possibility of differing modules hashes when the same
arguments are used in Clang directly vs from the importer.

Resolves rdar://79376364
2021-06-24 11:07:40 +10:00
Egor Zhdan
64113270df ClangImporter: run Clang with a proper executable path (pt 2)
This change re-applies https://github.com/apple/swift/pull/36749 after it has been reverted in https://github.com/apple/swift/pull/37805 because of a broken standalone stdlib build.
2021-06-22 22:28:55 +03:00
Xi Ge
2dcb33bb00 Frontend: allow specifying a different target triple for internal clang instance to use
Before this change, we always use the Swift target triple to instantiate the internal
Clang instance. When loading a Swift module from the textual interface, we may pick up
a lower target triple to use to build the Swift module because the target is hard-coded
in the textual interface file. This implies we may end up building multiple versions of the
same Clang module, one for each target triple of the loading Swift module.

This change adds a new frontend flag -clang-target to allow clients to specify a
consistent clang target to use across the Swift module boundaries. This value won't change
because it's not part of .swiftinterface files.

swift-driver should pass down -clang-target for each frontend invocation, and its value should be
identical to -target.

Related to: rdar://72480261
2021-06-06 07:58:21 -07:00
Argyrios Kyrtzidis
c417464359 Merge pull request #37252 from ahoppen/pr/missing-module-map
[ClangImporter] Load the stdlib even if there is a `-fmodule-map-file` argument pointing to a missing file
2021-05-06 09:02:22 -07:00
Alex Hoppen
aef9d5147f [ClangImporter] Load the stdlib even if there is a -fmodule-map-file argument pointing to a missing file
If there is a `-fmodule-map-file` argument whose file doesn’t exist and SwiftShims is not in the module cache, we fail to build it, because clang throws an error about the missing module map. This causes SourceKit to drop all semantic functionality, even if the missing module map isn’t required.

To work around this, drop all `-fmodule-map-file` arguments with missing files from the clang importer’s arguments, reporting the eror that `clang` would throw manually.

Fixes rdar://77449671
2021-05-06 10:23:58 +02:00
Xi Ge
a40f22eb94 ClangImporter: check version specified in canImport with the project version specified in .tbd files
Project versions are embedded in the .tbd files of Clang frameworks. This patch teaches the compiler
to check the desired version specified in `canImport` against the project version in .tbd file. The
condition returns true if the Clang module on disk has a version number greater or equal to the one from `canImport`
condition; it returns false otherwise.

Part of rdar://73992299
2021-05-04 12:23:28 -07:00
Xi Ge
bbe5b83de9 Parser: teach canImport to take an additional parameter indicating the minimum module version
canImport should be able to take an additional parameter labeled by either version or
underlyingVersion. We need underlyingVersion for clang modules with Swift overlays because they
have separate version numbers. The library users are usually interested in checking the importability
of the underlying clang module instead of its Swift overlay.

Part of rdar://73992299
2021-05-02 17:47:44 -07:00
Robert Widmann
b65777eabe Merge pull request #36963 from CodaFi/arm64_32
Add arm64_32 support for Swift
2021-04-20 17:42:56 -07:00
Robert Widmann
0149ccd0ca Add arm64_32 support for Swift
Commit the platform definition and build script work necessary to
cross-compile for arm64_32.

arm64_32 is a variant of AARCH64 that supports an ILP32 architecture.
2021-04-20 14:59:04 -07:00
Egor Zhdan
c01de639e4 ClangImporter: fix lookup of C++ namespaces
Sometimes when we're looking for a Swift enum, we actually want a C++ namespace.
2021-04-13 12:14:18 +03:00
Robert Widmann
d6d9db3ef6 Merge pull request #34871 from compnerd/noiam
Importer: remove `ImportAsMember` inference support
2021-03-22 17:45:08 -07:00
Saleem Abdulrasool
714eaefc78 Importer: remove ImportAsMember support
This functionality is not actively in use and the last usage of this has
been removed.  Remove the infrastructure that is no longer in need.
2021-03-22 08:53:56 -07:00
Doug Gregor
e316a8ef90 [Importer] While pretty-printing decls for diagnostics, don't emit diagnostics.
The diagnostics system doesn't allow a diagnostic to be emitted while
another diagnostic is in flight. Doing so will cause an assertion in
the diagnostics machinery.

There's a longstanding cycle here when diagnostics emission
pretty-prints declarations that are imported from a Clang module, and
the Clang Importer emits a diagnostic. Squash this cycle forcefully,
dropping the diagnostic that the Clang importer would emit.
2021-03-19 09:33:55 -07:00
Becca (née Brent) Royal-Gordon
0f6925020b Merge pull request #36198 from beccadax/a-swift-by-any-other-name-would-warn-as-bleat
Fix rebranch SwiftNameAttr warning regression
2021-03-01 22:06:38 -08:00
Becca Royal-Gordon
4e0905ae3f Fix rebranch SwiftNameAttr warning regression
A change in the new clang branch seems to have caused it to start applying SwiftNameAttrs to forward declarations. We have apparently always tried to add these forward declarations to the lookup tables in PCH files, but never diagnosed the resulting failures because they did not have SwiftNameAttrs. Now they do, so we started emitting incorrect warnings.

We *probably* don’t need to process these at all, but there’s a risk of unintended behavior changes from that; instead, this commit takes a conservative approach and simply suppresses the warnings like we always have.

Fixes rdar://74710976.
2021-03-01 15:33:05 -08:00
Doug Gregor
77105a4ee5 Enable SE-0297: Concurrency Interoperability with Objective-C 2021-02-24 14:18:16 -08:00
Doug Gregor
e2893cf138 [Concurrency] Disable async imports for Apple APIs deprecated by ~2018.
Implements rdar://73620586.
2021-02-09 14:43:45 -08:00
Argyrios Kyrtzidis
302f463ce3 Un-comment-out code using API change from clang
This will compile now that the automerger from llvm succeeded.
2021-01-29 09:54:22 -08:00