Commit Graph

1921 Commits

Author SHA1 Message Date
Allan Shortlidge
d002da0ef2 AST: Add a IgnoreMissingImports option to name lookup.
Control enforcement of member import visibility requirements via a new option,
instead of piggy-backing on the existing IgnoreAccessControl option. Adopt the
option when doing fallback lookups for unviable members so that the compiler
can diagnose the reason that a member is inaccessible more reliably.
Previously, with MemberImportVisibility enabled decls with the package access
level could be mis-diagnosed as inaccessible due to their access level when
really they were inaccessible due to a missing import.

Resolves rdar://131501862.
2024-07-10 22:57:15 -07:00
Ben Barham
2715d0e9d6 Merge branch 'main' into 20240710-main-to-rebranch
Conflicts:
  - `test/Interop/Cxx/class/method/methods-this-and-indirect-return-irgen-itanium.swift`
    previously fixed on rebranch, now fixed on main (slightly differently).
2024-07-10 20:42:09 -07:00
Steven Wu
a32dd9539b [Modules] Avoid false swift module sharing
When the swiftmodule is built with different clang importer arguments,
they can have the same module hash, causing them to be wrongly re-used even
they contains different interfaces. Add ReducedExtraArgs to the module hash to
disambiguate them.

However, some Xcc arguments, most commonly `-D` options do not affect the
swiftmodule being generated. Do not pass `-Xcc -DARGS` to swift
interface compilation to reduce the amount of module variants in the
build.

rdar://131408266
2024-07-10 14:48:12 -07:00
Saleem Abdulrasool
c8bec5b12f Driver: introduce -sysroot option for non-Darwin targets
This introduces a secondary flag `-sysroot` for the non-Darwin targets,
primarily Unicies. The intention here is to support a split `-sdk`,
`-sysroot` model where the `-sdk` parameter provides the Swift "SDK"
which augments the native platform's C sysroot which is indicated as
`-sysroot`. For the case of Android, this would allow us to provide a
path to the NDK sysroot and the Swift SDK allowing us to cross-compile
Android binaries from Windows.
2024-07-10 11:03:18 -07:00
Egor Zhdan
76578ee708 [cxx-interop] Minor refactoring: remove a redundant check
`cast<CustomAttr>` never returns nullptr, it either returns a non-null `CustomAttr*` or traps. This if condition was triggering a clang-tidy warning, since it is redundant.
2024-07-09 13:12:44 +01:00
Egor Zhdan
b50955144e [cxx-interop] Clone all of the attributes from base method correctly
If a C++ `struct Base` declares a method with a Clang attribute that Swift is able to import, and `struct Derived` inherits from `Base`, the method should get cloned from `Base` to `Derived` with its attributes.

Previously we were only cloning one attribute at most due to a bug in `cloneImportedAttributes`. DeclAttributes is an intrusively linked list, and it was being made invalid while iterating over it: `otherDecl->getAttrs().add(attrs)` iterates over the list and calls `otherDecl->add(eachElement)`, which invalidates the iterator after the first iteration.
2024-07-08 15:48:20 +01:00
swift-ci
b7921a8232 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-06 14:34:09 -07:00
Slava Pestov
fae01d9776 AST: Remove ModuleDecl parameter from more places 2024-07-06 12:05:46 -04:00
Ben Barham
4c5284fd40 Merge pull request #74851 from bnbarham/rebranch-build-after-branch
[rebranch] Various changes to get rebranch compiling after taking new clang branch
2024-07-02 22:01:17 -07:00
Ben Barham
22cc33a098 [ClangImporter] Handle pair to actual struct change
Use `FeatureName` rather than `first`.
2024-07-02 16:13:49 -07:00
Ben Barham
b429c70a24 [ClangImporter] Handle split sema
`Sema` was split up in LLVM upstream 31a203fa8af47a8b2e8e357857b114cf90638b2eq.
2024-07-02 16:13:49 -07:00
Ben Barham
226ba82525 [ClangImporter] Add various const
`getSelector` now takes a `const clang::IdentifierInfo *` `ArrayRef`.
Sprinkle a bunch of `const`s in.
2024-07-02 16:13:49 -07:00
swift-ci
2201e05fb8 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-02 14:15:46 -07:00
Michael Gottesman
34195ff213 Merge pull request #74610 from gottesmm/pr-324fd70c13e87a329334341aae4667f2d1be152c
[sending] Remove transferring.
2024-07-02 14:02:18 -07:00
Ben Barham
b7954411ec Merge remote-tracking branch 'origin/main' into manually-merge-main-to-rebranch
Conflicts:
  - `include/swift/AST/PluginRegistry.h`
2024-06-27 14:56:11 -07:00
Steven Wu
eacb045393 [ExplicitModule] Fix codegen target when using direct cc1 mode
When using direct-cc1 scanning mode, `-clang-target` is passed to
swift-frontend as `-Xcc` option, thus it causes swift IRGen to use
clang-target, instead of `-target` option of swift invocation. Teach
clang importer to restore target triple from swift for codegen option.

rdar://130547690
2024-06-26 14:46:35 -07:00
Michael Gottesman
112071e57d [sending] Remove transferring.
Out of an abundance of caution, we:

1. Left in parsing support for transferring but internally made it rely on the
internals of sending.

2. Added a warning to tell people that transferring was going to
be removed very soon.

Now that we have given people some time, remove support for parsing
transferring.

rdar://130253724
2024-06-21 16:03:21 -07:00
Xi Ge
736ccef626 Merge remote-tracking branch 'apple/main' into rebranch 2024-06-20 15:16:55 -07:00
Tim Kientzle
1098054291 Merge branch 'main' into tbkka-assertions2 2024-06-18 17:52:00 -07:00
swift-ci
08c89c3ee6 Merge remote-tracking branch 'origin/main' into rebranch 2024-06-18 09:14:51 -07:00
Steven Wu
7d85aa423d [ScanDependencies] Make sure canImport resolution agrees with import
Fix the problem that when the only module can be found is an
invalid/out-of-date swift binary module, canImport and import statement
can have different view for if the module can be imported or not.

Now canImport will evaluate to false if the only module can be found for
name is an invalid swiftmodule, with a warning with the path to the
module so users will not be surprised by such behavior.

rdar://128876895
2024-06-17 14:14:48 -07:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
swift-ci
f196fa91ec Merge remote-tracking branch 'origin/main' into rebranch 2024-06-03 14:35:06 -07:00
Steven Wu
48237b86f1 Merge pull request #74012 from cachemeifyoucan/eng/PR-128873665
[ScanDependency] Handle `-Xcc` options that affects module generation
2024-06-03 14:33:56 -07:00
swift-ci
563c233c0e Merge remote-tracking branch 'origin/main' into rebranch 2024-06-03 11:15:43 -07:00
Steven Wu
42732c0073 [ScanDependency] Handle -Xcc options that affects module generation
Make sure the `-Xcc` options to the scanner are correctly considered
when creating ClangImporterCC1 arguments for constructed swift interface
compilation job. Under directcc1 mode, `-Xcc` options should be used to
constructed sub-invocation but should not be added to GenericArgs for
constructing interface compilation jobs.

rdar://128873665
2024-06-03 09:57:10 -07:00
Steven Wu
026fcd24fe [ScanDependency][canImport] Improve canImport handling in explicit build
Teach dependency scanner to report all the module canImport check result
to swift-frontend, so swift-frontend doesn't need to parse swiftmodule
or parse TBD file to determine the versions. This ensures dependency
scanner and swift-frontend will have the same resolution for all
canImport checks.

This also fixes two related issues:
* Previously, in order to get consistant results between scanner and
  frontend, scanner will request building the module in canImport check
  even it is not imported later. This slightly alters the definition of
  the canImport to only succeed when the module can be found AND be
  built. This also can affect the auto-link in such cases.
* For caching build, the location of the clang module is abstracted away
  so swift-frontend cannot locate the TBD file to resolve
  underlyingVersion.

rdar://128067152
2024-05-31 15:36:55 -07:00
swift-ci
efcbe900f9 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-21 10:33:14 -07:00
Becca Royal-Gordon
d9912009b0 Merge pull request #73309 from beccadax/objcimpl-category-on-objc 2024-05-21 10:19:14 -07:00
swift-ci
1d0abfc691 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-20 17:34:38 -07:00
Artem Chikin
eb1c0e71d8 [Dependency Scanning] Add required additional C++ interop overlay module queries 2024-05-20 10:23:10 -07:00
swift-ci
b20fedebc6 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-18 02:54:31 -07:00
Becca Royal-Gordon
9db14c36ad Require @objc to be used with @implementation
…for extensions. This change also removes @implementation(CategoryName); you should attach the category name to the @objc attribute instead. And there are small changes to how much checking the compiler will do on an @objc @implementation after the decl checker has discovered a problem with it.
2024-05-17 14:57:32 -07:00
Michael Gottesman
b780ff6696 [sending] Begin parsing 'sending' while still accepting 'transferring'.
A few things:

1. Internally except for in the parser and the clang importer, we only represent
'sending'. This means that it will be easy to remove 'transferring' once enough
time has passed.

2. I included a warning that suggested to the user to change 'transferring' ->
'sending'.

3. I duplicated the parsing diagnostics for 'sending' so both will still get
different sets of diagnostics for parsing issues... but anywhere below parsing,
I have just changed 'transferring' to 'sending' since transferring isn't
represented at those lower levels.

4. Since SendingArgsAndResults is always enabled when TransferringArgsAndResults
is enabled (NOTE not vis-a-versa), we know that we can always parse sending. So
we import "transferring" as "sending". This means that even if one marks a
function with "transferring", the compiler will guard it behind a
SendingArgsAndResults -D flag and in the imported header print out sending.

rdar://128216574
2024-05-16 21:43:50 -07:00
Becca Royal-Gordon
07b9fe9ce6 Support @objc(CustomName) on extensions
This now specifies a category name that’s used in TBDGen, IRGen, and PrintAsClang. There are also now category name conflict diagnostics; these subsume some @implementation diagnostics.

(It turns out there was already a check for @objc(CustomName) to make sure it wasn’t a selector!)
2024-05-16 13:40:13 -07:00
Becca Royal-Gordon
4ba2f6e95c [NFC] Fix objcImpl request cache
Several offsetting bugs both broke the caching of `ObjCInterfaceAndImplementationRequest` and caused it to usually miss. Fix this whole painful mess. Also has collateral improvements to simple_display().
2024-05-16 13:34:55 -07:00
swift-ci
38df85afd6 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-15 08:16:25 -07:00
Kavon Farvardin
5ae2f6bd25 CxxInterop: use Unsafe*Pointer for move-only 2024-05-14 17:44:22 -07:00
Kavon Farvardin
21d147d3d0 Revert "CxxInterop: use workaround unconditionally"
This reverts commit 1036031d06.
2024-05-14 16:43:05 -07:00
swift-ci
004f0e9666 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-13 16:33:55 -07:00
Kavon Farvardin
1036031d06 CxxInterop: use workaround unconditionally
We haven't yet solved the underlying issue in rdar://128013193 and the
workaround to make it conditionally use the better importing strategy of
Unsafe{Mutable}Pointer no longer will apply, since NoncopyableGenerics
is here.
2024-05-13 13:08:25 -07:00
Kavon Farvardin
7a83af6925 Revert "CxxInterop: remove checks for NoncopyableGenerics"
This reverts commit b04be89dce.
2024-05-13 10:46:30 -07:00
swift-ci
ac90898851 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-08 16:34:07 -07:00
Kavon Farvardin
21b303ffb0 Merge pull request #73501 from kavon/ncgeneric-not-experimental
NCGenerics: it's not experimental
2024-05-08 16:29:03 -07:00
swift-ci
b22852fce7 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-08 15:14:02 -07:00
Alex Hoppen
743d29ced3 Merge pull request #73473 from ahoppen/import-extern-c-from-bridging-header
[ClangImporter] Import `extern "C"` declarations from the bridging header
2024-05-08 15:06:30 -07:00
Alex Hoppen
9fdbb86cbd [ClangImporter] Import extern "C" declarations from the bridging header
We do iterate into extern C declarations when building the Swift lookup table during PCH generation.

0fad799f51/lib/ClangImporter/SwiftLookupTable.cpp (L2140-L2146)

However, we don’t import `extern "C"` declarations while parsing the bridging header (eg. when no `-pch-output-dir` is specified during code completion). This caused us to miss functions annotated as `extern "C"` in code completion.

rdar://127512985
2024-05-08 11:01:21 -07:00
Kavon Farvardin
b04be89dce CxxInterop: remove checks for NoncopyableGenerics
It will always evaluate to true now; it's not experimental. This change
effectively reverts the following:
 - 6140ba1079
 - 78eee32467
2024-05-08 10:49:12 -07:00
swift-ci
d4e8274d83 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-07 12:33:55 -07:00
Alastair Houghton
a25cd37750 Add support to the compiler for musl and the LINUX_STATIC SDK.
This is really just about setting appropriate defaults (such as
making sure that the static Linux triple causes us to use lld).

rdar://123506306
2024-05-07 16:48:52 +01:00