Commit Graph

21693 Commits

Author SHA1 Message Date
Holly Borla
e1bf19822d [Sema] Put effects checking behind a request for experimental lazy
type checking.
2024-10-11 20:33:38 -07:00
Allan Shortlidge
6bc9cf5e43 AST: Remove ExplicitAvailabilityInfo from TypeRefinementContext.
This field was complicating initialization of `TypeRefinementContext` and
bloating its storage just to make it slightly more convenient to look up
information that is pretty easy to derive on-demand when it is actually needed.
2024-10-11 17:10:38 -07:00
swift-ci
8a2edbc4c5 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-11 17:05:06 -07:00
nate-chandler
249831f9f3 Merge pull request #76942 from nate-chandler/general-coro/20240927/1
[CoroutineAccessors] SIL represents callee alloc.
2024-10-11 16:39:53 -07:00
swift-ci
3fbd2b5151 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-11 13:15:53 -07:00
Rintaro Ishizaki
9461af4c5a Merge pull request #76978 from rintaro/astgen-placeholderexpr
[ASTGen] Generate EditorPlaceholderExpr and 'do' expressions
2024-10-11 13:12:21 -07:00
Hamish Knight
6a435960b7 Requestify regex pattern parsing
Instead of doing the pattern parsing in both the
C++ parser and ASTGen, factor out the parsing into
a request that returns the pattern to emit, regex
type, and version. This can then be lazily run
during type-checking.
2024-10-11 19:25:58 +01:00
Hamish Knight
21cbfc4567 NFC: Remove unused var 2024-10-11 19:25:57 +01:00
swift-ci
e1cfbb45cc Merge remote-tracking branch 'origin/main' into rebranch 2024-10-11 11:19:47 -07:00
Anthony Latsis
8519334b89 Merge pull request #76749 from AnthonyLatsis/amanita-muscaria 2024-10-11 18:02:36 +00:00
Rintaro Ishizaki
cb6372a9c4 [ASTGen] Generate EditorPlaceholderExpr and 'do' expressions 2024-10-11 09:34:41 -07:00
Nate Chandler
49a2831d3f [CoroutineAccessors] Old ABI may be used via flag.
Add a setting to IRGenOptions and key off of it to emit yield_once_2
coroutines using either (1) the same code-path as yield_once coroutines
or (2) a new, not-yet implemented code-path.

Add flags to set the value in both directions.  During bringup, by
default, use the existing caller-allocated ABI.
2024-10-11 08:25:02 -07:00
Nate Chandler
11b5d27594 [CoroutineAccessors] Add flag to observe errors.
Temporarily allow the legacy behavior of allowing caller coroutine
accessors to observe errors (i.e. by executing no code after the yield
if the caller threw an error) behind the
CoroutineAccessorsUnwindOnCallerError flag.
2024-10-11 08:25:02 -07: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
swift-ci
eb44cd10be Merge remote-tracking branch 'origin/main' into rebranch 2024-10-10 23:13:50 -07:00
Allan Shortlidge
4acfd20f04 Merge pull request #76972 from tshortli/trc-expansion-request-side-effect 2024-10-10 22:59:27 -07:00
swift-ci
5fa6829c78 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-10 19:47:48 -07: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
c7ea672463 [NFC] AST, Sema: Internalize BraceHasReturnRequest evaluation in AnyFunctionRef method 2024-10-11 03:44:43 +03:00
Konrad `ktoso` Malawski
6f245bb8eb ABI comments: include stored property names 2024-10-11 08:01:43 +09:00
swift-ci
1a59843e00 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-10 09:15:22 -07: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
swift-ci
6c5df94ea4 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-09 22:54:18 -07:00
Rintaro Ishizaki
6018662615 Merge pull request #76889 from rintaro/astgen-regexexpr
[ASTGen] Implement some Expr generation
2024-10-09 22:39:50 -07:00
swift-ci
c49a0e84d3 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-09 10:44:16 -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
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
swift-ci
0532e29e70 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-08 21:09:22 -07:00
Allan Shortlidge
cee810a0bc Merge pull request #76912 from tshortli/sorted-type-refinement-contexts
AST: Sort TypeRefinementContexts for better lookup performance
2024-10-08 20:48:53 -07:00
swift-ci
40aee60b24 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-08 19:09:12 -07:00
Allan Shortlidge
bfbb9f85e2 Merge pull request #76922 from tshortli/remove-unused-server-field
AST: Remove unused server field from InProcessPlugins
2024-10-08 18:19:04 -07:00
swift-ci
72676c2c4a Merge remote-tracking branch 'origin/main' into rebranch 2024-10-08 15:43:57 -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
swift-ci
929ebb1290 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-08 15:14:22 -07:00
Meghana Gupta
b443ff76e4 [NFC] Use llvm::TrailingObjects to represent variable list of lifetime sources 2024-10-08 15:11:26 -07:00
Meghana Gupta
f591680c2a Update SIL printing of @lifetime
Lifetime dependencies in SIL tests continue to be represented as a type modifier on the target.

As before, they are represented as a LifetimeDependentTypeRepr in the AST.
2024-10-08 15:10:59 -07:00
Meghana Gupta
4ac90a3e11 Diagnose multiple @lifetime attributes with same target 2024-10-08 15:10:59 -07:00
Meghana Gupta
31c1dc7eb5 Add support for specifying target in @lifetime
@lifetime(target: source1, source2...) where target can be any
parameter or 'self'. We cannot have @lifetime attributes with duplicate targets.

Also, update the internal data structures. Previously LifetimeEntry stored
pairwise (target, source) dependencies. Now, LifetimeEntry will store an optional
target descriptor and an array of source descriptors.
2024-10-08 15:10:48 -07:00
Ravi Kandhadai
cda4dc54b6 Merge pull request #76859 from j-hui/fix-frt-conversion
[cxx-interop] Fix swift::Type to clang::QualType conversion to correctly handle foreign reference types
2024-10-08 15:05:48 -07:00
Allan Shortlidge
c9d1ac07eb AST: Remove unused server field from InProcessPlugins. 2024-10-08 14:32:56 -07:00
swift-ci
c11a29a722 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-08 13:28:36 -07: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
Doug Gregor
70980b95f8 Add experimental feature MacrosOnImporters for applying macro to imported decl
This is still very much experimental and we don't want to accidentally
enable it everywhere.
2024-10-08 11:12:55 -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
swift-ci
9fd863f81e Merge remote-tracking branch 'origin/main' into rebranch 2024-10-08 10:50:24 -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
Allan Shortlidge
42ebee8dd1 AST: Improve TypeRefinementContext debug descriptions.
When printing the source ranges for nodes that represent an expansion within a
source file, print the range from the original source file and include a
description of the kind of expansion.
2024-10-08 09:55:28 -07:00
Allan Shortlidge
ac38469101 AST: Add verifier support for the TypeRefinementContext tree.
Verify the integrity of the tree formed by `TypeRefinementContext` nodes. In
general, parent nodes should "contain" their children and children always be in
sorted order.
2024-10-08 09:55:28 -07:00
Allan Shortlidge
5cf7141c08 AST: Maintain TypeRefinementContext children in sorted order.
Improve the performance of looking up the most refined `TypeRefinementContext`
for a given source location by storing children in sorted order and using a
binary search to query each layer of the tree. This slightly pessimizes
insertion (primarily when macros are expanded out of source location order) but
lookup is a far more common operation.
2024-10-08 09:55:28 -07:00