Commit Graph

103491 Commits

Author SHA1 Message Date
Henrik G. Olsson
374658aae0 [Swiftify] Don't import counted_by with suffixed integer literals (#82469)
Integer literal expressions with types that are not of type `int` are
printed with a suffix to indicate the type (e.g. `123U` or `456L` for
`unsigned` and `long`). This is not valid syntax for integer literals in
Swift, so until we fully translate the count expr syntax to Swift we
need to avoid importing these count expressions.

Also fixes some -Werror related stuff in test cases.

rdar://154141719
2025-06-27 09:27:50 -07:00
Egor Zhdan
f8664adbad Merge pull request #82496 from swiftlang/egorzhdan/allow-qual-swift-name
[cxx-interop] Allow import-as-member for types in namespaces
2025-06-27 13:22:25 +01:00
Andrew Trick
5a866009f9 Merge pull request #82472 from atrick/explicit-init
Disable surprising lifetime inference of implicit initializers
2025-06-27 04:19:05 -07:00
Charles Zablit
04ed5cf599 Merge pull request #82527 from charles-zablit/charles-zablit/demangling/add-wrapper
[demangling] add new wrapper API
2025-06-27 09:41:08 +01:00
Slava Pestov
34253a8606 Merge pull request #82506 from slavapestov/warn-long-expression-type-checking
Sema: Fix the -warn-long-expression-type-checking flag
2025-06-27 01:10:25 -04:00
eeckstein
ea6ed2fdec Merge pull request #82537 from eeckstein/fix-closure-specializer
ClosureSpecializer: don't specialize captures of stack-allocated Objective-C blocks
2025-06-27 06:46:48 +02:00
eeckstein
81d22c890b Merge pull request #82530 from eeckstein/fix-semantic-arc-opt
SemanticARCOpts: don't ignore dead-end blocks in the liverange analysis
2025-06-27 06:46:29 +02:00
Meghana Gupta
b58b6ccdfd Merge pull request #82548 from meg-gupta/printast
[NFC] Add a flag to print a function's ast before SILGen
2025-06-26 19:31:16 -07:00
Meghana Gupta
f19adcaf63 [NFC] Add a flag to print a function's ast before SILGen 2025-06-26 14:42:40 -07:00
Xi Ge
2236206bdf Merge pull request #82499 from swiftlang/153683760
ABI checker: drop usage of AllowDeserializingImplementationOnly option
2025-06-26 13:39:34 -07:00
Anthony Latsis
1f89bb6a94 Merge pull request #82452 from swiftlang/jepa2
Sema: Fix the insertion location for conformances attributes
2025-06-26 21:38:41 +01:00
Andrew Trick
7abe2222f9 Disable surprising lifetime inference of implicit initializers
Non-escapable struct definitions often have inicidental integer fields that are
unrelated to lifetime. Without an explicit initializer, the compiler would infer
these fields to be borrowed by the implicit intializer.

    struct CountedSpan: ~Escapable {
      let span: Span<Int>
      let i: Int

      /* infer: @lifetime(copy span, borrow i) init(...) */
    }

This was done because
- we always want to infer lifetimes of synthesized code if possible
- inferring a borrow dependence is always conservative

But this was the wrong decision because it inevitabely results in lifetime
diagnostic errors elsewhere in the code that can't be tracked down at the use
site:

    let span = CountedSpan(span: span, i: 3) // ERROR: span depends on the lifetime of this value

Instead, force the author of the data type to specify whether the type actually
depends on trivial fields or not. Such as:

    struct CountedSpan: ~Escapable {
      let span: Span<Int>
      let i: Int

      @lifetime(copy span) init(...) { ... }
    }

This fix enables stricter diagnostics, so we need it in 6.2.

Fixes rdar://152130977 ([nonescapable] confusing diagnostic message when a
synthesized initializer generates dependence on an Int parameter)
2025-06-26 12:47:01 -07:00
nate-chandler
76fd74753b Merge pull request #82510 from nate-chandler/rdar80334865
[IRGen] Sign these function pointers.
2025-06-26 12:02:07 -07:00
Erik Eckstein
1a009f5b0d ClosureSpecializer: don't specialize captures of stack-allocated Objective-C blocks
Bail if the closure captures an ObjectiveC block which might _not_ be copied onto the heap, i.e optimized by SimplifyCopyBlock.
We can't do this because the optimization inserts retains+releases for captured arguments.
That's not possible for stack-allocated blocks.

Fixes a mis-compile
rdar://154241245
2025-06-26 19:17:37 +02:00
Doug Gregor
f94159029e Merge pull request #82493 from DougGregor/effects-subst-parameter-packs
[Effects] Ensure that we properly substitute function types in ByClosure checks
2025-06-26 09:41:24 -07:00
Pavel Yaskevich
32a0d80b60 Merge pull request #82085 from xedin/rdar-149811049
[ClangImporter] SE-0463: Implement `@Sendable` inference exception for global actor isolated functions
2025-06-26 09:26:28 -07:00
Erik Eckstein
45dc83bcd8 SemanticARCOpts: don't ignore dead-end blocks in the liverange analysis
This can result in wrong ARC optimizations in dead-end blocks.
Fixes a SIL verification error.

rdar://154356277
2025-06-26 16:06:32 +02:00
Egor Zhdan
e95f6a3ce9 [cxx-interop] Allow import-as-member for types in namespaces
This adds support for `swift_name` attribute being used with C++ types that are declared within namespaces, e.g.
```
__attribute__((swift_name("MyNamespace.MyType.my_method()")))
```

Previously import-as-member would only accept a top-level unqualified type name.

rdar://138934888
2025-06-26 12:39:50 +01:00
Hamish Knight
46f5e417fd Merge pull request #82481 from hamishknight/tic-tac-toe
[SourceKit] Print backticks if needed in `printDisplayName`
2025-06-26 12:29:27 +01:00
Charles Zablit
1a598665b9 [demangling] add new wrapper API 2025-06-26 12:16:51 +01:00
Allan Shortlidge
da64fd7e5a Merge pull request #82489 from tshortli/warnings
Fix a couple of warnings
2025-06-26 03:03:54 -07:00
Andrew Trick
e25dcfa0a7 Merge pull request #82505 from atrick/inout-syntax
Fix diagnostics for missing or invalid @_lifetime annotations on inout params
2025-06-26 01:14:49 -07:00
Allan Shortlidge
6b05efd087 Sema: Remove unused variable in CSSolver.cpp. 2025-06-25 22:23:47 -07:00
Allan Shortlidge
3e780ac69e Driver: Remove unused functions. 2025-06-25 22:23:46 -07:00
Slava Pestov
487918f07b Sema: Fix -warn-long-expression-type-checking when expression timer is turned off
My change 983b75e1cf broke
-warn-long-expression-type-checking because now the
ExpressionTimer is not instantiated by default and that
entire code path is skipped.

Change it so that if -warn-long-expression-type-checking
is passed in, we still start the timer, we just don't
ever consider it to have 'expired'.

Fixes rdar://problem/152998878.
2025-06-25 22:07:23 -04:00
Slava Pestov
84d1d115e1 Sema: Change -solver-memory-threshold into a frontend flag for consistency with the others 2025-06-25 22:07:23 -04:00
Slava Pestov
0f00c89b31 Sema: Remove unused variable 2025-06-25 22:07:23 -04:00
Andrew Trick
87f2510a27 Diagnostic note for invalid @_lifetime annotations on inout params
Users commonly try to write a lifetime dependency on an 'inout' parameters as:

    @_lifetime(a: &a)
    func f_inout_useless(a: inout MutableRawSpan) {}

This is useless. Guide them toward what they really wanted:

    @_lifetime(a: copy a)

Fixes rdar://151618856 (@lifetime(..) gives inconsistent error messages)
2025-06-25 16:34:43 -07:00
Andrew Trick
080b68292d Fix a compiler crash with '@'_lifetime(inout x), add diagnostic
This is a common mistake made more common be suggestions of existing diagnostic
that tell users not to use a 'copy' dependency.

Report a diagnostic error rather than crashing the compiler. Fix the diagnostic
output to make sense relative to the source location.

Fixes rdar://154136015 ([nonescapable] compiler assertion with @_lifetime(x: inout x))
2025-06-25 16:34:43 -07:00
Andrew Trick
05fa82b7a7 Fix misleading Lifetime diagnostics for inout parameters
Correctly diagnose this as:
"invalid use of inout dependence on the same inout parameter

    @_lifetime(a: &a)
    func f_inout_useless(a: inout MutableRawSpan) {}

Correctly diagnose this as:
"lifetime-dependent parameter must be 'inout'":

    @_lifetime(a: borrow a)
    func f_inout_useless(a: borrowing MutableRawSpan) {}
2025-06-25 16:34:43 -07:00
Andrew Trick
df0b81c88d Lifetime diagnostics: clarify @_lifetime usage for inout parameters
This comes up often when passing a MutableSpan as an 'inout' argument.  The
vague diagnostic was causing developers to attempt incorrect @_lifetime
annotations. Be clear about why the annotation is needed and which annotation
should be used.
2025-06-25 16:34:42 -07:00
Nate Chandler
c108d480ab [IRGen] Sign these function pointers.
Value witness tables for prespecialized metadata for multi payload enums
contain references to `swift_getMultiPayloadEnumTagSinglePayload` and
`swift_storeMultiPayloadEnumTagSinglePayload`.  On platforms with
ptrauth, those functions must be signed.  Use the same helper when
adding these functions to the table as is used to add every single other
function to the table.

rdar://80334865
2025-06-25 16:24:40 -07:00
Pavel Yaskevich
0999792bf4 Merge pull request #82467 from xedin/swift-testing-troubles
[CSSimplify] Narrow down tuple wrapping for pack expansion matching
2025-06-25 16:03:07 -07:00
Dave Lee
ce7a3b39a4 IRGen: Emit objc type encoding for ivars (#81967)
ObjC ivar metadata has up to now emitted an empty string for the ivar's objc type encoding. Conversely, ObjC property metadata is emitted with an objc type encoding. This changes the compiler to also emit an objc type encoding for ivars.

The motivation for this change is for lldb to print ivars of classes declared in Objective-C but implemented in Swift, as defined in [SE-0436](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0436-objc-implementation.md). Without the presence of type encoding for ivars, lldb is unable to present to the user the ivars/properties of instances of such classes.

rdar://138569299
2025-06-25 15:39:23 -07:00
Andrew Trick
465d6a82e7 Fix LifetimeDependence diagnostic formatting
Remove incorrectly nested single quotes from the suggested fix.
2025-06-25 15:24:12 -07:00
Argyrios Kyrtzidis
d385e8c87a Merge pull request #81792 from sina-mahdavi/sina-mahdavi/fix-llvm-prefix-mapping-calls
fix calls to llvm prefix mapping functions to use space-separated opt…
2025-06-25 13:19:21 -07:00
Xi Ge
5c530ea4e4 ABI checker: drop usage of AllowDeserializingImplementationOnly
AllowDeserializingImplementationOnly was historically added as a defensive
check against deserailzation issues introduced by @implementationOnly imports.
It's no longer specified by other tools, thus the ABI checker should drop
it as well.

rdar://153683760
2025-06-25 12:15:21 -07:00
Doug Gregor
5391887b01 [Effects] Ensure that we properly substitute function types in ByClosure checks
We weren't substituting generic arguments into function types. In the
presence of parameter packs, this could mean that the parameter and
argument lists no longer match up, which would cause the effects
checker to prematurely bail out after treating this as "invalid" code.
The overall effect is that we would not properly check for throwing
behavior in this case, allowing invalid code (as in the example) and
miscompiling valid code by not treating the call as throwing.

Fixes rdar://153926820.
2025-06-25 10:01:34 -07:00
Artem Chikin
705b1a667f Merge pull request #82429 from artemcm/ScannerInvalidBinaryModuleRefactor
[Dependency Scanning] Refactor the scanner to simplify layering
2025-06-25 09:03:18 -07:00
Tony Allevato
180693b6ea Merge pull request #82453 from azarovalex/fix-overridden-typo
[Diagnostics] Fix typo in 'overridden' warning message and identifier
2025-06-25 11:01:41 -04:00
Hamish Knight
55ef1bcaf0 [SourceKit] Print backticks if needed in printDisplayName
Ensure we print raw identifier names with backticks for e.g the
document structure request.

rdar://152524780
2025-06-25 15:15:17 +01:00
Pavel Yaskevich
b41a21a114 Merge pull request #82465 from xedin/rdar-154202375
[Concurrency] Global actor isolated conformances are only allowed to …
2025-06-25 01:10:27 -07:00
Adrian Prantl
e24e676520 Merge pull request #82336 from charles-zablit/charles-zablit/add-new-demangling-methods
add new methods to the NodePrinter to enable range tracking possibilities when demangling a name
2025-06-24 16:11:06 -07:00
Pavel Yaskevich
4804f2131b [CSSimplify] Narrow down tuple wrapping for pack expansion matching
Follow-up for https://github.com/swiftlang/swift/pull/82326.

The optional injection is only viable is the wrapped type is
not yet resolved, otherwise it's safe to wrap the optional.
2025-06-24 15:30:25 -07:00
Doug Gregor
ab4e87fe5a Merge pull request #82443 from DougGregor/preconcurrency-unsafe-silence
Allow '@unsafe' on import declarations to silence '@preconcurrency' warning
2025-06-24 13:49:55 -07:00
Sina Mahdavi
7090b7e145 fix calls to llvm prefix mapping functions to use space-separated option format 2025-06-24 13:32:55 -07:00
Pavel Yaskevich
2e1fe444a6 [Concurrency] Global actor isolated conformances are only allowed to override nonisolated.
Follow-up for https://github.com/swiftlang/swift/pull/79893.

More than one global actor isolated conformance at any level
creates a clash and conforming type should be inferred as `nonisolated`.

Resolves: rdar://154202375
2025-06-24 12:46:41 -07:00
eeckstein
830a842b7b Merge pull request #82455 from eeckstein/adress-of-borrow-feature
Guard InlineArray addressors with feature flag
2025-06-24 20:58:18 +02:00
Allan Shortlidge
24aaff9fba Merge pull request #82434 from tshortli/reorganize-availability
SILGen: Reorganize some availability related code
2025-06-24 09:21:38 -07:00
Pavel Yaskevich
b1470321e8 Merge pull request #82430 from xedin/issue-82397
[CSSimplify] Prevent `missing call` fix from recording fixes while ma…
2025-06-24 09:12:33 -07:00