Commit Graph

45333 Commits

Author SHA1 Message Date
Doug Gregor
43df05a89c [SE-0470] Prohibit isolated conformances in dynamic casts marked as such
Certain dynamic casts cannot work safely with isolated conformances,
regardless of what executor the code runs on. For such cases, reject
all attempts to conform to the type.
2025-03-26 22:31:52 -07:00
Doug Gregor
e0b52cd20e [SIL] Extend checked-cast instructions with "prohibit isolated conformances" flag
When performing a dynamic cast to an existential type that satisfies
(Metatype)Sendable, it is unsafe to allow isolated conformances of any
kind to satisfy protocol requirements for the existential. Identify
these cases and mark the corresponding cast instructions with a new flag,
`[prohibit_isolated_conformances]` that will be used to indicate to the
runtime that isolated conformances need to be rejected.
2025-03-26 22:31:47 -07:00
nate-chandler
e8d871ced5 Merge pull request #80290 from nate-chandler/general-coro/20250325/1
[CoroutineAccessors] Directly reference allocators.
2025-03-26 21:47:09 -07:00
Michael Gottesman
de7a62e13e Merge pull request #80312 from gottesmm/pr-126bc735b2d01c0f2f35f27268ff26d404b2fb16
[sil] Make SILFunctionTypeInfo a struct enum.
2025-03-26 18:05:57 -07:00
Becca Royal-Gordon
a5a84f188e Merge pull request #79466 from beccadax/abi-inspected-your-appearance
@abi checking
2025-03-26 15:28:39 -07:00
Arnold Schwaighofer
007266869f Merge pull request #80306 from aschwaighofer/fix_cond_fail_message_annotation_help_text
Fix enable-cond-fail-message-annotation option's help text
2025-03-26 14:07:08 -07:00
Gábor Horváth
07929331d0 Merge pull request #80305 from swiftlang/gaborh/string-unsafe
[cxx-interop] Fix a regression making std::string unsafe
2025-03-26 20:16:13 +00:00
Becca Royal-Gordon
6759ad59d1 Add @abi behavior for @constInitialized 2025-03-26 10:47:59 -07:00
Becca Royal-Gordon
ef738e6b5a Make @abi type diagnostics more specific
Specify whether the type with the problem is a result type, parameter type (and which parameter), etc.
2025-03-26 10:47:58 -07:00
Becca Royal-Gordon
7703d115db Filter bad attrs out of module interface @abis
When printing an `@abi` attribute’s decl, we now filter out any attrs that are not valid in that position. Fixes a broken test.
2025-03-26 10:47:58 -07:00
Becca Royal-Gordon
d2276362a4 Support @abi on subscripts
And make sure we reject it on `deinit`s and accessors.
2025-03-26 10:47:57 -07:00
Becca Royal-Gordon
132f49108d Check attributes in @abi attr
This commit compares the attributes on the decl inside the `@abi` attribute to those in the decl it’s attached to, diagnosing ABI-incompatible differences. It also rejects many attributes that don’t need to be specified in the `@abi` attribute, such as ObjC-ness, access control, or ABI-neutral traits like `@discardableResult`, so developers know to remove them.
2025-03-26 10:47:57 -07:00
Becca Royal-Gordon
32b8a11b11 Add flags to specify @abi behavior of attributes
This PR adds a set of DeclAttr.def flags for specifying how a given attribute interacts with `@abi`, and declares a behavior for each existing attribute. Future attributes will be *required* to declare an `@abi` behavior lest they fail a static assert.

Note that the behavior is not actually enforced in this commit—it is merely specified here.
2025-03-26 10:47:56 -07:00
Becca Royal-Gordon
495d464044 Add DeclAttribute::isEquivalent()
Adds a new method to `DeclAttribute` which can compare two attributes and see if they would be “equivalent” in light of the given decl. “Equivalent” here means that they would have the same effect on the declaration; for instance, two attrs with different source locations can be equivalent, and two attributes with the same arguments in a different order are equivalent if the ordering of those argumetns is not semantically equivalent.

This capability is not yet used in this commit, but in a future commit `@abi` will check if certain attributes are equivalent or not.
2025-03-26 10:47:14 -07:00
Becca Royal-Gordon
3baba0b262 Type check @abi decls (sans attrs)
This commit compares the decl inside the `@abi` attribute to the decl it’s attached to, diagnosing ABI-incompatible differences. It does not yet cover attributes, which are a large undertaking.
2025-03-26 10:47:13 -07:00
Becca Royal-Gordon
775bdacefc [NFC] Extract Decl::getExplicitObjCName()
Create a helper method which looks for an `@objc` attribute with an explicit name and returns it, and adopt it in various existing places.
2025-03-26 10:47:12 -07:00
Becca Royal-Gordon
d8349e72ca [NFC] Expose default param specifier computation
Make this logic accessible outside of the mangler.
2025-03-26 10:47:12 -07:00
Becca Royal-Gordon
1af5c04765 [NFC] Hoist getTypeSourceRangeForDiagnostics()
Allows code to get this for any AbstractStorageDecl.
2025-03-26 10:47:12 -07:00
Becca Royal-Gordon
cd61fd4dc5 [NFC] Fix ImplementsAttr::clone()
Correct an issue with `ImplementsAttr` that would come up if you ever tried to clone an attribute that had been deserialized.

No tests because there’s nothing in the compiler yet that might actually do so.
2025-03-26 10:47:11 -07:00
Andrew Trick
97b249bd11 Merge pull request #80263 from atrick/markdep-addr
SIL: add mark_dependence_addr
2025-03-26 10:33:42 -07:00
Michael Gottesman
8cfb029b5c [sil] Make SILFunctionTypeInfo a struct enum.
I am doing this in preparation for adding the ability to represent in the SIL
type system that a function is global actor isolated. Since we have isolated
parameters in SIL, we do not need to represent parameter, nonisolated, or
nonisolated caller in the type system. So this should be sufficient for our
purposes.

I am adding this since I need to ensure that we mangle into thunks that convert
execution(caller) functions to `global actor` functions what the global actor
is. Otherwise, we cannot tell the difference in between such a thunk and a thunk
that converts execution(caller) to execution(concurrent).
2025-03-26 10:23:44 -07:00
John McCall
4da795fd61 Merge pull request #80297 from rjmccall/zero-objc-async-result-on-error-path
Pass a zero normal result to ObjC async completion handlers on the error path
2025-03-26 12:42:38 -04:00
Arnold Schwaighofer
4143d93031 Fix enable-cond-fail-message-annotation option's help text 2025-03-26 09:26:17 -07:00
Nate Chandler
0c2a38b10b [CoroutineAccessors] Directly reference allocators
Replace the call to a runtime function that looks up the allocator with
a direct reference to a just-emittedd sought-after global allocator.
2025-03-26 08:35:35 -07:00
Nate Chandler
9fcd15108b [Gardening] Detypo'd. 2025-03-26 08:35:35 -07:00
Gabor Horvath
ff42f2ee79 [cxx-interop] Fix a regression making std::string unsafe
Currently, we only get warnings for using unsafe types in expressions
but not in the function signature. The tests did not use the std::string
object in the function body. As a result, we regressed and std::string
was considered unsafe.

The reason is that the annotation only mode for calculating escapability
of a type did not do what we intended. std::basic_string is
conditionally escapable if the template argument is escapable. We
considered 'char' to have unknown escapability in annotation only mode.
The annotation only mode was introduced to avoid suddenly importing
certain types as not escapable when they have pointer fields and break
backward compatibility.

The solution is to make annotation only mode to still consider char and
co as escapable types and only fall back to unknown when the inference
otherwise would have deduced non-escapable (for unannotated typed).
2025-03-26 15:25:37 +00:00
eeckstein
964f081e69 Merge pull request #80284 from eeckstein/diagnose-infinite-recursion
DiagnoseInfiniteRecursion: re-implement the pass in swift and fix a bug
2025-03-26 14:17:30 +01:00
Hamish Knight
b719498369 Merge pull request #80242 from hamishknight/mutable-problems-require-mutable-solutions
[AST] Always walk folded SequenceExpr if available
2025-03-26 10:43:50 +00:00
Erik Eckstein
8b2d27007f DiagnoseInfiniteRecursion: re-implement the pass in swift and fix a bug
Fixes a false alarm in case of recursive calls with different type parameters.
For example:

```
protocol P {
  associatedtype E: P
}

func noRecursionMismatchingTypeArgs1<T: P>(_ t: T.Type) {
  if T.self == Int.self {
    return
  }
  noRecursionMismatchingTypeArgs1(T.E.self)
}
```
2025-03-26 09:14:38 +01:00
Erik Eckstein
ac55dae26c AST: add the possibility to compare SubstitutionMaps 2025-03-26 08:45:38 +01:00
Erik Eckstein
85a6df30d6 SIL: add lookup(method:) in VTable and WitnessTable 2025-03-26 08:45:23 +01:00
Erik Eckstein
1844c14c44 SIL: add var ClassMethodInst.member 2025-03-26 08:45:07 +01:00
Erik Eckstein
67556cfbf4 SIL: add some Function APIs
* `var wasDeserializedCanonical`
* `var genericSignature`
* `func mapTypeIntoContext`
* `var forwardingSubstitutionMap`
2025-03-26 08:45:07 +01:00
Erik Eckstein
59ad8b6623 Optimizer: add var Context.currentModuleContext 2025-03-26 08:43:55 +01:00
Erik Eckstein
1ce545ba3d SIL: add some DeclRef APIs
* `var decl`
* `func ==`
* `func calleesAreStaticallyKnowable`
2025-03-26 08:43:55 +01:00
Erik Eckstein
b39a6cdd22 AST: add var GenericSignature.genericParameters 2025-03-26 07:30:11 +01:00
Erik Eckstein
42bba8f484 AST: add some Declaration APIs
* `var Declaration.parentModule`
* `var AbstractFunctionDecl.isOverridden`
2025-03-26 07:30:11 +01:00
Erik Eckstein
d523e303c3 SIL/AST: move some SIL.Type APIs to the TypeProperties protocol which makes them also available for AST.Type and AST.CanonicalType 2025-03-26 07:30:10 +01:00
Andrew Trick
e7000e4668 SIL: Add mark_dependence_addr 2025-03-25 23:02:42 -07:00
Anthony Latsis
631a04e56c Merge pull request #80159 from AnthonyLatsis/danaus-plexippus-5
Sema: Extend adoption mode for `AsyncCallerExecution` to storage declarations
2025-03-26 04:40:58 +00:00
John McCall
3fe70968cc Remove the substitution map from zeroInitializer builtin in SIL.
This is a value operation that can work just fine on lowered types,
so there's no need to carry along a formal type. Make the value/address
duality clearer, and enforce it in the verifier.
2025-03-26 00:34:15 -04:00
Anthony Latsis
a75b63ab6d Merge pull request #77920 from AnthonyLatsis/fissidens
AST: Rename debugger pretty printer `Type::dumpPrint` to `print`
2025-03-25 23:42:36 +00:00
Anthony Latsis
a95785c5b2 Merge pull request #80260 from AnthonyLatsis/eutrema-japonicum
DiagnosticEngine: Print the ID of the wrapped, not wrapper, diagnostic
2025-03-25 23:14:43 +00:00
Dave Lee
c51e10a827 RemoteInspection: Update DefaultActorImpl layout (#80278)
The definition of `DefautlActorImpl` changed in https://github.com/swiftlang/swift/pull/73998. This change reflects those changes on to RemoteInspection's platform independent definition.
2025-03-25 15:42:46 -07:00
Mike Ash
5f5d1cfae6 Merge pull request #80119 from mikeash/allocation-failure-fatal-error
[Runtime] Include size/alignment in allocation failure fatal error message.
2025-03-25 18:32:21 -04:00
Kuba (Brecka) Mracek
1c395e24f6 Merge pull request #79923 from kubamracek/mracek/constinitialized
[Compile Time Values] Add parsing of @constInitialized attribute under CompileTimeValues experimental feature
2025-03-25 13:41:17 -07:00
nate-chandler
17952d4d6f Merge pull request #80221 from nate-chandler/general-coro/20250320/1
[CoroutineAccessors] Default overrides of new symbols.
2025-03-25 12:22:40 -07:00
Pavel Yaskevich
5af7e0d09b Merge pull request #80236 from xedin/is-self-recursive-cache
[SILOptimizer] Turn "is self-recursive" check into analysis
2025-03-25 10:37:07 -07:00
Michael Gottesman
7648bce91b Merge pull request #80210 from gottesmm/pr-5cf03315e9a3442419b1bab18b46f755fdf0b405
[concurrency] Make sure that TypeLowering inserts the extra actor parameter for @execution(caller) parameters.
2025-03-25 10:09:44 -07:00
Nate Chandler
5534eb4043 [DefaultOverides] Install in vtables at runtime. 2025-03-25 07:22:44 -07:00