Commit Graph

28352 Commits

Author SHA1 Message Date
Anthony Latsis
8519334b89 Merge pull request #76749 from AnthonyLatsis/amanita-muscaria 2024-10-11 18:02:36 +00:00
Nate Chandler
df1c4f6b25 [CoroutineAccessors] Add new SILFnTy CoroKind.
For `modify` and `read` coroutines, produce SILFunctionType's whose
coroutineKind is ::YieldOnce2.
2024-10-11 08:25:02 -07:00
Allan Shortlidge
4acfd20f04 Merge pull request #76972 from tshortli/trc-expansion-request-side-effect 2024-10-10 22:59:27 -07:00
Slava Pestov
9e37df77fe Merge pull request #76965 from slavapestov/type-of-reference
Sema: Split off TypeOfReference.cpp from ConstraintSystem.cpp
2024-10-10 22:28:02 -04:00
Allan Shortlidge
5440dcef92 AST: Make ExpandChildTypeRefinementContextsRequest a side effectful request.
While returning the actual child vector from
`ExpandChildTypeRefinementContextsRequest` is a nice idea, it is both
inefficient (the vector gets copied in and out) and kind of inaccurate, since
the vector remains mutable after the initial expansion and may gain additional
children as macros are lazily expanded.
2024-10-10 18:06:39 -07:00
Anthony Latsis
41adfec8da [NFC] AST, Sema: Move TypeChecker::findReturnStatements into AnyFunctionRef
Also rename it to `getExplicitReturnStmts` for clarity and have it
take a `SmallVector` out parameter instead as a small optimization and
to discourage use of this new method as an alternative to
`AnyFunctionRef::bodyHasExplicitReturnStmt`.
2024-10-11 03:57:43 +03:00
Anthony Latsis
e31e8773d5 [NFC] Sema: Reimplement ReturnStmtFinder as a function with a callback
A callback enables the caller to control whether to abort the walk. This
is handy for `BraceHasExplicitReturnStmtRequest`.
2024-10-11 03:46:35 +03:00
Anthony Latsis
244185c4f4 [NFC] AST: Rename BraceHasReturnRequest to BraceHasExplicitReturnStmtRequest 2024-10-11 03:44:43 +03:00
Anthony Latsis
c7ea672463 [NFC] AST, Sema: Internalize BraceHasReturnRequest evaluation in AnyFunctionRef method 2024-10-11 03:44:43 +03:00
Anthony Latsis
3742da743c Sema: Result builder inference from dynamically replaced decl should look at getter, not storage 2024-10-11 03:44:42 +03:00
Anthony Latsis
5de14cb5a1 [NFC] Sema: Add more comments to inferResultBuilderType 2024-10-11 03:44:42 +03:00
Anthony Latsis
16f97d7ccf Sema: Result builder inference from protocol req should look at getter, not storage 2024-10-11 03:44:42 +03:00
Anthony Latsis
c99657308c Sema: Result builder inference always favors explicit attr on storage decl 2024-10-11 03:44:42 +03:00
Slava Pestov
61bd58d5ef Sema: Split off TypeOfReference.cpp from ConstraintSystem.cpp 2024-10-10 17:53:12 -04:00
Slava Pestov
3a4de0b953 Sema: Optimize computeConnectedComponents()
If there is only one connected component, we don't actually have
to form the array of components at all. Re-organize the code so
that we can short-circuit this decision as soon as possible.
2024-10-10 17:05:30 -04:00
Gabor Horvath
625f45a928 [cxx-interop] Consider extern "C" structs as resilient
Changing the members of these structs are still API and ABI breaking
changes but they are not as fragile as C++ classes where adding/removing
virtual functions or doing other changes can also result in breaking the
ABI.

rdar://119319825
2024-10-10 17:58:09 +01:00
Gábor Horváth
b5a85ed8dc Merge pull request #76907 from swiftlang/gaborh/assume-resilient-cxx-types
[cxx-interop] Add flag to assume C++ types are resilient
2024-10-10 17:15:15 +01:00
Pavel Yaskevich
76f0bcb05c [CSBindings] Adjust hasConversions to handle Void has having not conversions
Tuples in general do have conversions but an empty tuple or `Void`
doesn't, which means that if a type variable has a subtype binding
to `Void` it should be safe to prioritize.
2024-10-10 23:35:53 +09:00
Rintaro Ishizaki
f7e62d892f Merge pull request #76937 from rintaro/swift-macro-evaluation-rdar137448282
[ASTGen] Rename 'swiftMacros' module to 'swiftMacroEvaluation'
2024-10-09 19:15:34 -07:00
Slava Pestov
04f48db7f2 Merge pull request #76932 from slavapestov/cstrail-part-6
Sema: Small SolverTrail cleanups
2024-10-09 20:39:09 -04:00
Rintaro Ishizaki
aa456d19f1 [ASTGen] Rename 'swift/Bridging/Macros.h' to swift/Bridging/MacroEvaluation.h 2024-10-09 15:19:25 -07:00
Rintaro Ishizaki
7dad37ac58 [ASTGen] Rename 'swiftMacros' module to 'swiftMacroEvaluation'
'swiftMacros' is confusing with 'SwiftMacros' which is the standard
libary macro plugin.

rdar://137448282
2024-10-09 15:15:59 -07:00
Meghana Gupta
4df55a12cd Merge pull request #76834 from meg-gupta/lifetimedepmultiple
Replace dependsOn with @lifetime
2024-10-09 10:17:43 -07:00
Slava Pestov
cdc2145ad5 Sema: Use existing utility function 2024-10-09 11:48:08 -04:00
Slava Pestov
6c2e4ecb80 Sema: Rename restoreCurrentScore() to updateScoreAfterConjunction() 2024-10-09 11:48:07 -04:00
Slava Pestov
38fe0696a4 Sema: Factor out clearScore() and replayScore() 2024-10-09 11:48:07 -04:00
Slava Pestov
c8db9f55e6 Sema: Remove last heap allocation of Scope 2024-10-09 11:48:07 -04:00
Slava Pestov
24e5a828e6 Merge pull request #76921 from slavapestov/cstrail-part-5
Sema: Finish hollowing out SolverScope
2024-10-09 08:04:07 -04:00
Gabor Horvath
cf3b333eb6 [cxx-interop] Add flag to assume C++ types are resilient
Currently, C++ types cannot appear in resilient interfaces. There are
some cases where this is overly restrictive. We plan to improve the
logic to detect what types should not appear on resilient moduel
boundaries. In the meantime, this PR introduces a flag to disable these
errors. Users relying on this flag are on their own, this should only be
a temporary workaround until we land further improvements to this
diagnostic.

rdar://137457118
2024-10-09 11:47:10 +01:00
Chris Miles
31dc11ced1 Merge pull request #76796 from swiftlang/eng/chrismiles/fix-print-instrumenting-for-language-mode-6
Fix instrumenting print and debugPrint for Swift 6.
2024-10-08 16:50:14 -07:00
Doug Gregor
bba1432732 Merge pull request #76364 from DougGregor/apply-macro-to-imported
Allow attached macros to be applied to imported C declarations
2024-10-08 15:26:54 -07:00
Meghana Gupta
6710d501b1 Fix SIL parsing of lifetime dependence in parameter position 2024-10-08 15:10:59 -07:00
Slava Pestov
e9add92334 Sema: Remove some unnecessary heap allocation of SolverScopes 2024-10-08 17:23:38 -04:00
Slava Pestov
0b85ce6f00 Sema: Remove SolverScope::numFixes 2024-10-08 16:57:49 -04:00
Slava Pestov
bdab82a192 Sema: Use xmacros to clean up more duplication in CSTrail.{cpp,h} 2024-10-08 16:50:49 -04:00
Slava Pestov
5fdc1a81b8 Sema: Record retired constraints in the trail 2024-10-08 16:39:34 -04:00
Slava Pestov
fc7068ee40 Merge pull request #76910 from slavapestov/open-type-perf-fix
Fix performance regression in ConstraintSystem::openType()
2024-10-08 16:17:58 -04:00
Slava Pestov
90175400d2 Sema: Record generated constraints in the trail 2024-10-08 16:17:28 -04:00
Slava Pestov
1e2d4fbc59 Sema: Record score increases in the trail 2024-10-08 16:16:31 -04:00
Slava Pestov
877c60e3d0 Sema: Rename applySolution() to replaySolution() 2024-10-08 16:16:01 -04:00
Slava Pestov
1323953219 Sema: Try not to make a negative impact 2024-10-08 16:14:05 -04:00
Doug Gregor
5fb8b5f7ad Use the pretty-printed declaration for applying macros to imported decls 2024-10-08 11:12:54 -07:00
Doug Gregor
e35472c34c Create and register SourceFiles for pretty-printed buffers
This will allow the macro system to find them.
2024-10-08 11:12:54 -07:00
Doug Gregor
cdcabd05bd Allow attached macros to be applied to imported C declarations
The Clang importer maps arbitrary attributes spelled with `swift_attr("...")`
over to Swift attributes, using the Swift parser to process those attributes.
Extend this mechanism to allow `swift_attr` to refer to an attached macro,
expanding that macro as needed.

When a macro is applied to an imported declaration, that declaration is
pretty-printed (from the C++ AST) to provide to the macro implementation.
There are a few games we need to place to resolve the macro, and a few more
to lazily perform pretty-printing and adjust source locations to get the
right information to the macro, but this demonstrates that we could
take this path.

As an example, we use this mechanism to add an `async` version of a C
function that delivers its result via completion handler, using the
`@AddAsync` example macro implementation from the swift-syntax
repository.
2024-10-08 11:12:50 -07:00
Steven Wu
5fa12d31ae Merge pull request #76738 from cachemeifyoucan/eng/PR-136787368
[CAS] Use IncludeTreeFileList instead of full CASFS for caching
2024-10-08 10:42:24 -07:00
Slava Pestov
b0303bb5a1 Sema: Restore old behavior in ConstraintSystem::openType()
My change to preserve type sugar in type transforms introduced a
performance regression here, because openType() is called for
every disjunction choice.

My hope is to optimize the TypeAliasType representation and remove
this at some point, but for now, let's just restore the old
desugaring behavior in this case.
2024-10-08 11:53:45 -04:00
Slava Pestov
e3402b1304 Merge pull request #76879 from slavapestov/cstrail-part-3
Sema: Continue to hollow out SolverScope
2024-10-07 21:53:50 -04:00
Slava Pestov
e47f9966ad Sema: ConstraintSystem::openType() uses TypeTransform 2024-10-07 17:46:40 -04:00
Slava Pestov
4a82d384b7 Sema: Record synthesized conformances in the trail 2024-10-07 16:50:49 -04:00
Slava Pestov
12eb7cec26 Sema: Record implicit callAsFunction() roots in the trail 2024-10-07 16:50:49 -04:00