Commit Graph

5139 Commits

Author SHA1 Message Date
zoecarver
e05daed3b4 [cxx-interop] Disable rvalue references. We don't support them correctly (leading to lifetime issues). We are missing a consuming. 2023-05-01 23:13:33 -07:00
Alex Lorenz
60fd510744 [interop] lookup FRT retain/release functions in top level module
Lookups in submodules do not work and are explicitly ignored in the clang importer
2023-05-01 18:58:39 -07:00
Alex Lorenz
bde105cbf0 Merge pull request #65543 from hyp/eng/revert-c81325461afdc602b0901fa06f9d6f988381622b
Revert "[cxx-interop] Treat un-instantiated templated types as unsafe"
2023-05-01 16:44:01 -07:00
Alex Lorenz
89b1c6391f Revert "[cxx-interop] Treat un-instantiated templated types as unsafe"
This reverts commit c81325461a.

This caused https://github.com/apple/swift/issues/65446
2023-05-01 10:25:47 -07:00
Alex Hoppen
053d215d55 Merge pull request #65427 from ahoppen/ahoppen/macro-attribute-completions
[CodeCompletion] Support completion for macro roles and the 'names:' argument label
2023-04-28 17:20:24 -07:00
Alex Lorenz
3282fb7bc1 Merge pull request #65437 from hyp/eng/nomathinthiscompiler
[interop] avoid importing math functions from the C++ standard library
2023-04-28 07:21:13 -07:00
Alex Hoppen
186b854721 [Parser] Pass code completion status from attribute parsing to decl parsing
This is needed to be able to perform code completion inside `@freestanding` and `@attached`.
2023-04-27 18:13:16 -07:00
Alex Lorenz
8e7766bf18 [interop] avoid importing math functions from the C++ standard library
They cause ambiguities with math functions from platform's libc
2023-04-27 10:25:51 -07:00
Alex Lorenz
4ccacd72dd Merge pull request #65447 from hyp/eng/template-param-type-logic-upgrade
[interop] Ensure an FRT or a pointer to struct/class gets a Swift typ…
2023-04-27 10:19:28 -07:00
Alex Lorenz
0fff76915b [interop] Ensure an FRT or a pointer to struct/class gets a Swift type name for a C++ template parameter
In the follow-up, I should also expand this to cover pointers to builtin types too, but for now lets go with a miminal fix here
2023-04-26 14:48:21 -07:00
Artem Chikin
9d4e831ad3 [Dependency Scanner] Ensure the Clang dependency scanner working directory matches the invocation when querying bridging header dependencies
The Swift compiler does not have a concept of a working directory. It is instead handled by the Swift driver by resolving relative paths according to the driver's working directory argument. On the other hand, Clang does have a concept working directory which may be specified on this Clang invocation with '-working-directory'. If so, it is crucial that we use this directory as an argument to the Clang scanner API. Otherwiswe, we risk having a mismatch between the working directory specified on the scanner's Clang invocation and the one use from the scanner API entry-points, which leads to downstream inconsistencies and errors.

This was originally fixed for the main by-name module dependencies query in https://github.com/apple/swift/pull/61025 (03136e06aa), but the Bridging Header dependencies code has continued to incorrectly expect the Swift ASTContext to both have the working directory set *and* be consistent with that of the Clang scanner instance.

Resolves rdar://108464467
2023-04-26 10:55:01 -07:00
Artem Chikin
6fcd8be072 [Dependency Scanning] Pull optional dependencies from the adjacent binary module for direct interface dependencies
For a `@Testable` import in program source, if a Swift interface dependency is discovered, and has an adjacent binary `.swiftmodule`, open up the module, and pull in its optional dependencies. If an optional dependency cannot be resolved on the filesystem, fail silently without raising a diagnostic.
2023-04-17 14:47:46 -07:00
Dave Lee
39bb7bfe44 [AST] Convert ASTContext::getSwiftName to a free function
The only state `getSwiftName` uses is its argument, and can be made a free function. Of
note the inverse operation, `getKnownFoundationEntity`, is also a free function. This
removes the requirement that callers have an `ASTContext` instance.

(cherry-picked from commit fb524c0b86)
2023-04-14 11:43:13 -06:00
Alex Lorenz
f45d9f7662 Merge pull request #65056 from hyp/eng/no-never-ever
[interop] do not import functions whose return type is not imported
2023-04-12 08:20:04 -07:00
Alex Lorenz
380f9a7008 [interop] add availability for foreign reference types
Such types have runtime support only SwiftStdlib 5.8 and above
2023-04-11 15:28:22 -07:00
Alex Lorenz
8e0c17b274 [interop] do not import functions whose return type is not imported 2023-04-11 08:27:45 -07:00
Alex Lorenz
c2315060b6 [interop] mark C++ virtual functions as unavailable in Swift
They're not yet supported
2023-04-10 11:51:38 -07:00
zoecarver
5a20d72880 [cxx-interop] Allow specific getters/setters to be imported as computed properties.
Adds `SWIFT_COMPUTED_PROPERTY`. Refs `-cxx-interop-getters-setters-as-properties`.
2023-04-07 10:30:30 -07:00
Alex Lorenz
612eefffd4 Merge pull request #64911 from hyp/eng/grand-macro-rename
[interop] update names and add docs for the interop C++ helper macros
2023-04-06 17:17:52 -07:00
Alex Lorenz
64a4b3159c [interop] add SWIFT_ prefix to the C++ interop annotations 2023-04-06 12:11:25 -07:00
Alex Lorenz
7720d8219c add a module map for swift/bridging header 2023-04-05 14:35:16 -07:00
Artem Chikin
0f7e909a28 Always specify -gmodules on built-in Clang invocations
This is currently always done when instantiating `ClangImporter` by manually setting the option on the Clang invocation with:
```
Invocation->getCodeGenOpts().DebugTypeExtRefs = true
```
Now also add it to `importer::addCommonInvocationArguments` so that the dependency scanner always generates command-lines with the required for Swift Clang flags.

Resolves rdar://107570568
2023-04-05 09:42:47 -07:00
Steven Wu
09b8af86fb Virtualize swift compiler outputs (#63206)
Using a virutal output backend to capture all the outputs from
swift-frontend invocation. This allows redirecting and/or mirroring
compiler outputs to multiple location using different OutputBackend.

As an example usage for the virtual outputs, teach swift compiler to
check its output determinism by running the compiler invocation
twice and compare the hash of all its outputs.

Virtual output will be used to enable caching in the future.
2023-04-05 23:34:37 +08:00
Argyrios Kyrtzidis
8bd3d8c341 Merge pull request #64909 from apple/blangmuir/depscan-update
Update for clang dependency scanning API change
2023-04-05 00:03:17 -07:00
Alex Lorenz
30d0c17bf9 [interop] update names and add docs for the interop C++ helper macros 2023-04-04 15:13:59 -07:00
Ben Langmuir
9f2ab36888 Update for clang dependency scanning API change 2023-04-04 10:47:21 -07:00
Egor Zhdan
c81325461a [cxx-interop] Treat un-instantiated templated types as unsafe
When determining whether a C++ method is safe to be imported, we look at its return type to see if it stores any pointers in its fields.

If the type is templated, we might not have its definition available yet. Unfortunately we cannot instantiate it on the spot, since the Clang AST would be read and written at the same time.

Let's stay on the safe side and treat such methods as unsafe.

rdar://107609381
2023-04-04 15:33:09 +01:00
Doug Gregor
f7e479759d Merge pull request #64854 from DougGregor/top-level-macro-lookup 2023-04-03 06:50:39 -07:00
Doug Gregor
828de17b00 [Macros] Resolve macro names using unqualified lookup that ignores expansions
The macro name resolution in the source lookup cache was only looking at
macros in the current module, meaning that any names introduced by peer
or declaration macros declared in one module but used in another would
not be found by name lookup.

Switch the source lookup cache over to using the same
`forEachPotentialResolvedMacro` API that is used by lookup within
types, so we have consistent name-lookup-level macro resolution in both
places.

... except that would be horribly cyclic, of course, so introduce name
lookup flags to ignore top-level declarations introduced by macro
expansions. This is semantically correct because macro expansions are
not allowed to introduce new macros anyway, because that would have
been a terrible idea.

Fixes rdar://107321469. Peer and declaration macros at module scope
should work a whole lot better now.
2023-04-02 23:15:38 -07:00
Richard Wei
eb8e984b97 [Macros] Private discriminators for outermost-private MacroExpansionDecl (#64813)
Add a private discriminator to the mangling of an outermost-private `MacroExpansionDecl` so that declaration macros in different files won't have colliding macro expansion buffer names.

rdar://107462515
2023-03-31 20:36:29 -07:00
Zoe Carver
54dfc7f84e Merge pull request #64774 from zoecarver/rename-bridging-header
[cxx-interop] Rename `swift-interop-support.h` -> `swift/bridging`.
2023-03-31 10:58:14 -07:00
Alex Lorenz
991d0a720d [interop] emit symbolic interfaces with method signatures with matching parameter count
We do not care about parameter's type in the symbolic method declaration, but we do care about the arity of the method.
2023-03-30 13:16:30 -07:00
zoecarver
75201e884e [cxx-interop] Rename swift-interop-support.h -> swift/bridging.
There are some updates to the contents as well. Those will be a different patch.
2023-03-30 10:31:45 -07:00
Becca Royal-Gordon
e09d02e12f [NFC] Expose extension category name accessor 2023-03-25 14:52:40 -07:00
Zoe Carver
e93e7d1b7a Merge pull request #64513 from zoecarver/revert-75dc69a81da07647bda2d1ccc3b82ce6e68b44a7
Revert 75dc69a81d
2023-03-23 09:58:10 -07:00
Slava Pestov
ac15cdf6ea Merge pull request #64527 from slavapestov/protocol-conformance-cleanup
AST: Rename ProtocolConformance::getSubstitutions() to getSubstitutionMap() and remove ModuleDecl parameter
2023-03-22 20:30:25 -04:00
swift-ci
fd0f148a07 Merge pull request #64518 from artemcm/NoExtraClangPCMSearchPaths
[Dependency Scanning] Do not add extra search paths to the Clang's explicit PCM prebuild commands
2023-03-22 11:51:46 -07:00
Artem Chikin
4ed874c276 [Dependency Scanning] Do not add extra search paths to the Clang's explicit PCM prebuild commands
Clang dependency scanner's output will be complete here w.r.t. the required search paths.

Resolves rdar://107018240
2023-03-22 09:36:17 -07:00
zoecarver
4c73369366 Revert "[cxx-interop] Add debug dump when we hit The Flakey Issue™."
This reverts commit 75dc69a81d.
2023-03-21 13:27:17 -07:00
zoecarver
00dc5406fb Revert "[nfc] Fix a few warnings I introduced."
This reverts commit 077d3cb8b3.
2023-03-21 13:27:11 -07:00
Slava Pestov
a355c38a34 AST: Rename ProtocolConformance::getSubstitutions() to getSubstitutionMap() and remove ModuleDecl parameter 2023-03-21 16:16:34 -04:00
Alexis Laferrière
201c4b6205 Merge pull request #64486 from xymus/import-filter-refactor
[Sema] Intro common sets of import filters to simplify calls to `getImportedModules`
2023-03-21 11:10:50 -07:00
Ben Barham
8090366ff6 Merge pull request #64491 from bnbarham/probe-precompiled
[ClangImporter] Probe for a PCH when the header is missing
2023-03-21 11:01:46 -07:00
Zoe Carver
b90f789df3 Merge pull request #64438 from zoecarver/fixits-for-clang-types-swiftpm-2 2023-03-21 08:28:34 -07:00
zoecarver
ba8e00d7f2 [cxx-interop] Add fix-it for foreign reference types. 2023-03-20 16:14:42 -07:00
zoecarver
ebc492a368 [cxx-interop] Add fix-its to apply 'safe_to_import' and 'self_contained'. 2023-03-20 16:14:42 -07:00
Ben Barham
9b8f7c30d1 [ClangImporter] Probe for a PCH when the header is missing
The default for `ProbePrecompiled` was changed in rebranch. Set it back
to `true` to avoid breaking existing clients.

Resolves rdar://106966024.
2023-03-20 15:49:13 -07:00
zoecarver
9d5d624d10 [cxx-interop] Let through decls (mainly class templates) that do not have required lifetime operations when printing a module interface. 2023-03-20 15:47:23 -07:00
zoecarver
1e43ba0514 [cxx-interp] Don't select the move contstructor if it hasn't been defined. 2023-03-20 15:47:23 -07:00
zoecarver
9d5e06cad7 [cxx-interop] Revert hasCopyTypeOperations to the old behavior to get Swift Compiler Sources building. 2023-03-20 15:47:23 -07:00