Commit Graph

47194 Commits

Author SHA1 Message Date
Kavon Farvardin
61fe8a9b8e introduce @_manualOwnership performance attribute
This attribute forces programmers to acknowledge every
copy that is required to happen in the body of the
function. Only those copies that make sense according
to Swift's ownership rules should be "required".

The way this is implemented as of now is to flag each
non-explicit copy in a function, coming from SILGen, as
an error through PerformanceDiagnostics.
2025-09-17 13:51:57 -07:00
Hamish Knight
aa9aa58cea [Sema] Handle PlaceholderTypes in associated type inference
Avoid attempting to infer an associatedtype as a type that contains
placeholders.
2025-09-17 20:51:06 +01:00
Hamish Knight
8102e39f39 [CS] Record fix when encountering decl reference with placeholder type
We allow placeholder types in interface types in certain cases to allow
better recovery since we can suggest the inferred type as a replacement.
When referencing those decls though we need to make sure we record a fix
since we cannot form a valid solution with them.
2025-09-17 20:51:06 +01:00
Hamish Knight
78ea361257 [AST] Override getLocFromSource for ParamDecl
Ensure we can still produce a source location even if there's no name
loc, which is the case for e.g enum associated types.
2025-09-17 20:41:20 +01:00
Slava Pestov
90bfc1676d Sema: Remove some unreachable code from CSApply
I believe these code paths could only be reached by re-typechecking
invalid code in the old CSDiag implementation.
2025-09-17 16:11:53 +01:00
Hamish Knight
782a5b4332 [CS] Ensure we trap in getOverloadChoice if the overload is missing
Using `*` previously meant we'd invoke undefined behavior.
2025-09-17 16:11:53 +01:00
Henrik G. Olsson
0276febf41 handle libc++ v17-19
libc++ v17-19 was split into multiple top-level modules, while versions
earlier and later had one TLM with submodules.
2025-09-16 21:10:09 -07:00
Henrik G. Olsson
406cc1d1f5 [ImportResolution] Override module imports for macros in namespaces
Contents in namespaces are imported to the bridging header module
`__ObjC`. When macros attached to a decl imported from a namespace are
expanded, they also end up in `__ObjC`. This prevents them from
inheriting imports from the module they originated in. This patch
implements a workaround by adding an alternative constructor to
`ImportResolver` that takes an explicit origin module as input,
overriding which module counts as the "parent" module.
2025-09-16 21:10:08 -07:00
Henrik G. Olsson
369fc18c01 [ClangImporter] Only import explicit submodules to the current module
Non-explicit submodules don't need to be explicitly added to the list of
imports to be visible, since their decls are implicitly exported. Skip
these modules even when present in the list of imports. Explicit
submodules are imported *regardless* of whether another module
imports them however.
2025-09-16 21:10:04 -07:00
Henrik G. Olsson
928cc6c83e [ClangImporter] Deduplicate imports copied from submodule to TLM
The imported top-level module inherits the imports of all its
(transitive) submodules. Since multiple submodules can import the same
modules these need to be deduplicated to avoid redundant work.
2025-09-16 21:10:03 -07:00
Henrik G. Olsson
17c0e564e8 Add hidden --dump-source-file-imports flag
This flag dumps all imports for each SourceFile after it's gone through
import resolution. It is only intended for testing purposes.
There are other ways to print imports, but they don't correspond 1:1 to
the imports actually resolved, which is a bit problematic when testing
implicit clang module imports.
2025-09-16 21:09:59 -07:00
swift-ci
df8f7818a0 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-16 20:26:17 -07:00
Doug Gregor
56f60635b1 Merge pull request #84328 from DougGregor/coroframealloc-backdeploy 2025-09-16 20:15:50 -07:00
swift-ci
b08d731e34 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-16 19:16:11 -07:00
Susana Monteiro
f648dbbbca Merge pull request #84237 from susmonteiro/susmonteiro/cxxrecord-semantics
[cxx-interop] Refactor copyability out of CxxRecordSemantics
2025-09-17 03:05:45 +01:00
swift-ci
efdca7809a Merge remote-tracking branch 'origin/main' into rebranch 2025-09-16 15:42:34 -07:00
Doug Gregor
f7264e327f [IRGen] Only use a stub for swift_coroFrameAlloc when we need it
swift_coroFrameAlloc was introduced in the Swift 6.2 runtime. Give it
the appropriate availability in IRGen, so that it gets weak
availability when needed (per the deployment target). Then, only
create the stub function for calling into swift_coroFrameAlloc or
malloc (when the former isn't available) when we're back-deploying to
a runtime prior to Swift 6.2. This is a small code size/performance
win when allocating coroutine frames on Swift 6.2-or-newer platforms.

This has a side effect of fixing a bug in Embedded Swift, where the
swift_coroFrameAlloc was getting unconditionally set to have weak
external linkage despite behind defined in the same LLVM module
(because it comes from the standard library).

Fixes rdar://149695139 / issue #80947.
2025-09-16 10:51:12 -07:00
susmonteiro
2640c71ec0 [cxx-interop] Refactor copyability out of CxxRecordSemantics 2025-09-16 14:40:16 +01:00
Allan Shortlidge
4841bcffa1 ModuleInterface: Print imports with @preconcurrency in swiftinterface files.
When a module has been imported `@preconcurrency` in source, when it is printed
in a `swiftinterface` file it should be printed along with the attribute to
ensure that type checking of the module's public declarations behaves
consistently.

This fix is a little unsatisfying because it adds another a linear scan over
all imports in the source for each printed import. This should be improved, but
it can be done later.

Resolves rdar://136857313.
2025-09-15 17:33:13 -07:00
swift-ci
374c577cc3 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-15 12:56:24 -07:00
Doug Gregor
01873c996f Merge pull request #84283 from DougGregor/embedded-swift-untyped-throws-restriction
[Embedded] Diagnose untyped throws as an Embedded Swift restriction
2025-09-15 12:55:16 -07:00
swift-ci
0d2c4ca9be Merge remote-tracking branch 'origin/main' into rebranch 2025-09-15 10:29:21 -07:00
Allan Shortlidge
cfe9f90347 Merge pull request #84244 from tshortli/require-swift-version-in-module-interfaces
Frontend: Require `-language-mode` option when emitting swiftinterfaces
2025-09-15 10:08:23 -07:00
Meghana Gupta
c764244df0 Merge pull request #84180 from meg-gupta/borrowandmutatepr
Add preliminary support for borrow accessors
2025-09-15 10:01:15 -07:00
Artem Chikin
926fc78b4c Merge pull request #84191 from artemcm/InMemoryDepScanSerializedDiagnostics
[Dependency Scanning] Configure a serialized diagnostics consumer for in-memory scans
2025-09-15 11:54:44 -04:00
Ryan Mansfield
4d6a37aecd Fix various HelpText typos. 2025-09-15 11:25:25 -04:00
Doug Gregor
865c643cac Suppress Embedded Restriction diagnostics in code that won't be compiled as Embedded
When emitting diagnostics for the Embedded Swift restrictions outside
of Embedded Swift mode, consider `#if $Embedded` and `#if
hasFeature(Embedded)` configurations. If the code where we would emit
the diagnostic would be disabled in Embedded Swift by one of those
checks, don't emit the diagnostic. This helps code that can compile
either with Embedded or regular Swift stay within the restrictions on
Embedded Swift.
2025-09-15 07:10:00 -07:00
swift-ci
09d0324a71 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-15 01:41:51 -07:00
Hamish Knight
411e14d00b Merge pull request #84275 from hamishknight/skippy
[CS] Avoid skipping SingleValueStmtExpr branch with ReturnStmt for completion
2025-09-15 09:33:17 +01:00
Meghana Gupta
a42511e041 [NFC] Replace ApplyInst::getSubstCalleeConv()::hasGuaranteedAddressResult() with ApplyInst::hasGuaranteedAddressResult() 2025-09-14 23:38:07 -07:00
Meghana Gupta
995d6a77d9 Update hasGuaranteedResult and hasGuaranteedAddressResult 2025-09-14 23:38:06 -07:00
Meghana Gupta
6665cd5d46 [NFC] hasGuaranteedAddressResults -> hasGuaranteedAddressResult and hasGuaranteedResults -> hasGuaranteedResult 2025-09-14 23:38:06 -07:00
Doug Gregor
7d21bc332a [Embedded] Diagnose untyped throws as an Embedded Swift restriction
Untyped throws depends on existentials (`any Error`), and is therefore
not available in Embedded Swift. Introduce a diagnostic that diagnoses
any use of untyped throws, suggesting that one use typed throws
instead.

Make this an opt-in diagnostic enabled with `-Wwarning
EmbeddedRestrictions`, whether in Embedded Swift or not, using the
"default ignore" flag on these new warnings. Document this new
diagnostic group, and put the existing Embedded Swift error about
weak/unowned references in it as well.

Part of the general push to have the type checker identify code that
will not compile as Embedded Swift earlier, rdar://133874555.
2025-09-14 21:48:50 -07:00
Hamish Knight
f1ad703430 [CS] Avoid skipping SingleValueStmtExpr branch with ReturnStmt for completion
We still need to solve a branch with a ReturnStmt to avoid leaving
the contextual result type unbound. This isn't currently legal anyway,
so isn't likely to come up often in practice, but make sure we can
still solve.
2025-09-13 19:15:34 +01:00
swift-ci
bf9d79f5c1 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-13 06:17:00 -07:00
Slava Pestov
6bf5213d41 Merge pull request #84251 from slavapestov/fix-rdar151171381
Fix @_opaqueReturnTypeOf module interface syntax for parameter packs
2025-09-13 08:44:44 -04:00
Hamish Knight
8e460d1e6c Merge pull request #84225 from hamishknight/access-noted
Requestify the loading of access notes
2025-09-13 12:06:43 +01:00
Hamish Knight
73255ab7a0 Merge pull request #84265 from hamishknight/tracksuit
[Frontend] Only enable request reference tracking when needed
2025-09-13 10:34:43 +01:00
swift-ci
edf0c5fffd Merge remote-tracking branch 'origin/main' into rebranch 2025-09-12 21:14:20 -07:00
Henrik G. Olsson
8e802be2b8 Merge pull request #81663 from hnrklssn/swiftify-debug-logging
[Swiftify] add debug logs for safe interop
2025-09-12 18:40:55 -07:00
Rintaro Ishizaki
31b5d55f33 Merge pull request #84128 from rintaro/parse-attr-lparen-space-rdar147785544
[Parse] Change whitespace rule between attribute name and '(' in Swift 6
2025-09-12 18:19:53 -07:00
Artem Chikin
50c0dd844f [Dependency Scanning] Refactor 'createScanQueryContext' to directly return an error 2025-09-12 15:50:40 -07:00
Hamish Knight
cdfab780a3 [Evaluator] Ensure dep tracking is enabled in enumerateReferencesInFile
Add an assert to ensure we don't run into cases where we expect
dependency tracking to be enabled but it isn't.
2025-09-12 20:39:58 +01:00
Hamish Knight
850118c856 [evaluator] Avoid recording dependency sources and sinks when disabled
Short-circuit the logic here early to avoid the dependency logic if
recording is disabled.
2025-09-12 20:39:58 +01:00
swift-ci
7b9382146f Merge remote-tracking branch 'origin/main' into rebranch 2025-09-12 10:55:53 -07:00
Allan Shortlidge
13d61b0709 Frontend: Require -language-mode option when emitting swiftinterfaces.
If a `.swiftinterface` file does not include an explicit `-language-mode`
option (or its predecessor `swift-version`) and needs to be built as a
dependency of a client compilation, then the invocation to build the module
from interface would end up inheriting the language mode that the client code
is built with. This can result in spurious type checking diagnostics or even
mis-compilation. To ensure that a module interface is always built using the
language mode that its source code was originally built with, require an
explicit `-language-mode` option when emitting swiftinterface files.

Resolves rdar://145168219.
2025-09-12 09:10:23 -07:00
Hamish Knight
014ed51ab1 Merge pull request #84220 from hamishknight/times-arrow
[AST] Allow storing original expression in `ErrorTypeRepr`
2025-09-12 17:06:34 +01:00
swift-ci
66c8ef9205 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-11 20:55:58 -07:00
Allan Shortlidge
0ba825e5f2 Merge pull request #84240 from tshortli/always-enabled-availability-domains
AST: Introduce an "always enabled" custom availability domain kind
2025-09-11 20:43:28 -07:00
Slava Pestov
bd3b3ea009 ASTDemangler: Split off resolveOpaqueTypeDecl() from resolveOpaqueType() 2025-09-11 22:55:10 -04:00