Commit Graph

2357 Commits

Author SHA1 Message Date
Meghana Gupta
148155710f Merge pull request #76624 from meg-gupta/lifetimedepscoped
Add support for borrow lifetime dependence
2024-10-02 13:58:14 -07:00
Alexis Laferrière
edb0b925c8 Parser: Register all availability macro definition buffers before parsing
The availability macro definitions from the command line are copied into
source buffers for parsing. Let's register all of these buffers in one go,
before starting to parse any of them. Parsing triggers using `findBuffer`
services which sorts all buffers. The new logic should ensure this
sorting happens only once for availability macros.
2024-10-01 11:27:05 -07:00
Alexis Laferrière
ff803c6df1 Sema: Move the availability macros cache to the ASTContext
The availability macros definitions are parsed from the command line and
stored in a cache. The cache was in the Parser, which would have it be
computed for each file using availability macros. Let's move it to the
ASTContext instead where it can generally be computed once per invocation
and used across the module.

rdar://134797088
2024-10-01 09:07:56 -07:00
Nate Chandler
091368ba21 [CoroutineAccessors] Added read.
The name is a placeholder for the mutating single-yield coroutine
accessor.
2024-09-26 18:10:39 -07:00
Nate Chandler
98a2e6a7df [CoroutineAccessors] Added modify.
The name is a placeholder for the mutating single-yield coroutine
accessor.
2024-09-26 18:10:39 -07:00
Nate Chandler
6f6292705e [NFC] AST: Removed dead #define.
It was once used for materializeForSet.
2024-09-25 21:06:36 -07:00
Nate Chandler
6b89f1e62b [NFC] Parse: Contextualize accessor introducer.
To the routine that parses the introducer for an accessor whether it is
would be first accessor, pass whether it would be the first accessor;
from it, return whether the accessor is from an unavailable feature.
These both enable expected behavior when an experimental feature is
disabled: the former enables maintaining source compatibility with code
that uses the introducer name as a function name which is called with a
trailing closure as the first expression in an implicit getter.  The
latter enables suppressing duplicative diagnostics.
2024-09-25 21:06:36 -07:00
Meghana Gupta
34782b750e Parse scoped lifetime dependence kind within the @lifetime attribute 2024-09-20 21:50:51 -07:00
Doug Gregor
5b2520e379 Remove IfConfigDecl from the AST
The swift-syntax tree retains information about the parsed #if
regions. Drop it from the semantic AST.
2024-09-18 20:51:54 -07:00
Doug Gregor
d762dd53f8 Stop parsing into IfConfiDecl nodes in the C++ parser
When parsing #if...#endif regions, parse the active clause directly into
place in the AST without ever producing an IfConfigDecl instance.
2024-09-18 20:51:09 -07:00
Doug Gregor
49aa0e966f Ensure that SourceFiles always have a backing buffer in the SourceManager
The "buffer ID" in a SourceFile, which is used to find the source file's
contents in the SourceManager, has always been optional. However, the
effectively every SourceFile actually does have a buffer ID, and the
vast majority of accesses to this information dereference the optional
without checking.

Update the handful of call sites that provided `nullopt` as the buffer
ID to provide a proper buffer instead. These were mostly unit tests
and testing programs, with a few places that passed a never-empty
optional through to the SourceFile constructor.

Then, remove optionality from the representation and accessors. It is
now the case that every SourceFile has a buffer ID, simplying a bunch
of code.
2024-09-16 21:46:42 -07:00
Allan Shortlidge
02dbb96b94 AST: Rename AvailabilityContext to AvailabilityRange.
The generality of the `AvailabilityContext` name made it seem like it
encapsulates more than it does. Really it just augments `VersionRange` with
additional set algebra operations that are useful for availability
computations. The `AvailabilityContext` name should be reserved for something
pulls together more than just a single version.
2024-09-13 16:25:18 -07:00
Meghana Gupta
2b011b0a3a [NFC] Rename/reorg LifetimeDependence utils 2024-09-09 22:02:44 -07:00
Meghana Gupta
e61d87c01c Add support for parsing @lifetime attribute to specify lifetime dependencies on declarations 2024-09-09 22:02:42 -07:00
Alejandro Alonso
75c2cbf593 Implement value generics
Some requirement machine work

Rename requirement to Value

Rename more things to Value

Fix integer checking for requirement

some docs and parser changes

Minor fixes
2024-09-04 15:13:25 -07:00
Ian Anderson
2a597a7e46 [Sema] Don't clear ParsedUnrecognizedPlatformName when a recognized platform is parsed
The callers of parsePlatformVersionInList need to know if an unrecognized platform was parsed in the whole list. It can get cleared in the case of (unrecognized 1.0, *) but PlatformAndVersions will still be empty.
2024-08-28 11:05:51 -07:00
Ian Anderson
8eb583c04c Merge pull request #76073 from ian-twilightcoder/unknown-platform-attr
[Sema] Allow unrecognized platforms  in @backDeployed and @_originallyDefinedIn
2024-08-27 18:27:40 -07:00
Ian Anderson
eb11ad99a1 [Sema] Allow unrecognized platforms in @backDeployed and @_originallyDefinedIn
Don't emit attr_availability_need_platform_version for a @backDeployed or @_originallyDefinedIn that have a single unrecognized platform name.
2024-08-27 14:02:37 -07:00
Doug Gregor
c241e782e0 Use SwiftIfConfig to determine where to emit new parser diagnostics 2024-08-22 22:33:53 -07:00
Doug Gregor
fc5ba4c7d5 Revert "Use SwiftIfConfig to determine where to emit new parser diagnostics"
This reverts commit 1da2631c4e.
2024-08-22 09:22:20 -07:00
Doug Gregor
1da2631c4e Use SwiftIfConfig to determine where to emit new parser diagnostics 2024-08-17 22:48:18 -07:00
Hamish Knight
e65647c559 Merge pull request #75574 from jamieQ/missing-return-diagnostics
[AST][SILOptimizer]: unify missing return diagnostics in some cases
2024-08-09 16:23:47 +01:00
Jamie
6c676c9f22 [AST][SILOptimizer]: unify missing return diagnostics in some cases
Previously, missing return diagnostics for unreachable subscripts
differed from the treatment unreachable functions received, leading to
inconsistent diagnostic behavior. This change removes the responsibility
for handling the relevant diagnostics from the AST code, in favor of the
diagnostics implemented via the SIL optimizer. Additionally, where the
AST-generation code would previously have diagnosed a missing return for
an implicit empty getter, it will now admit as valid, deferring the
missing return diagnostics to the later SIL passes.
2024-08-07 08:14:11 -05:00
Mateus Rodrigues
ac57e61278 Merge branch 'main' into trailing-comma 2024-08-06 09:34:43 -03:00
Mateus Rodrigues
e3f4228e36 Remove macro role trailing comma support 2024-08-05 15:27:44 -03:00
Hamish Knight
a657f97c9b [Parse] Avoid skipping bodies with #sourceLocation
`#sourceLocation` requires setting and restoring
state in the parser, so we cannot skip any bodies
containing `#sourceLocation` tokens. Member skipping
was already doing this, extend it to function
body skipping too.
2024-07-30 16:56:00 +01:00
Hamish Knight
1bd2a9b18b [Parse] Allow skipping member bodies following #sourceLocation
If the bodies themselves don't have a
`#sourceLocation` in them, there should be no
harm in skipping; the parsed virtual files get
recorded on the SourceManager, so will be
accessible when doing delayed parsing. The
`InPoundLineEnvironment` flag will be inaccurate,
but that's only needed for the parsing of
`#sourceLocation` itself.
2024-07-30 16:56:00 +01:00
Alejandro Alonso
ca8c90ecc0 Support movesAsLike for the array variant of @_rawLayout 2024-07-28 10:29:57 -07:00
Mateus Rodrigues
b1ba769754 Minor changes for better clarity 2024-07-25 15:30:37 -03:00
Mateus Rodrigues
e0d416cdab Ungate accepted parts of SE439 2024-07-22 09:55:16 -03:00
Meghana Gupta
8137aed238 Rename LifetimeDependentReturnTypeRepr -> LifetimeDependentTypeRepr 2024-07-10 14:20:03 -07:00
Hamish Knight
ec597c82fa [Completion] Only complete @unchecked et al in inheritance clauses
Add a case for completing type attributes in
inheritance clause position, and limit the
completion of `@unchecked`, `@preconcurrency`, and
`@retroactive` to that case.
2024-07-03 11:41:58 +01:00
Michael Gottesman
34195ff213 Merge pull request #74610 from gottesmm/pr-324fd70c13e87a329334341aae4667f2d1be152c
[sending] Remove transferring.
2024-07-02 14:02:18 -07:00
Hamish Knight
ff09cad05d [Parse] Add fix-it for unknown isolation in @isolated
Currently `any` is the only supported kind, so we
can suggest that.

rdar://130287211
2024-07-02 12:01:13 +01:00
Xiaodi Wu
e1f537107f Merge branch 'main' into trailing-comma 2024-06-29 16:36:06 -04:00
Ben Barham
d72f5b12c4 Update StringRef::equals references to operator==
`equals` has been deprecated upstream, use `operator==` instead.
2024-06-27 19:14:06 -07:00
Michael Gottesman
112071e57d [sending] Remove transferring.
Out of an abundance of caution, we:

1. Left in parsing support for transferring but internally made it rely on the
internals of sending.

2. Added a warning to tell people that transferring was going to
be removed very soon.

Now that we have given people some time, remove support for parsing
transferring.

rdar://130253724
2024-06-21 16:03:21 -07:00
Hamish Knight
2fbc8b336f Merge pull request #74559 from hamishknight/pound-if-skip
[Parse] Handle `#if` in brace skipping logic
2024-06-21 15:04:19 +01:00
Tim Kientzle
598e5104ef Merge pull request #74184 from tbkka/tbkka-assertions2
Add `#include "swift/Basic/Assertions.h"` to a lot of source files
2024-06-20 12:13:28 -07:00
Mateus Rodrigues
fe0e68332e Remove enum case list trailing comma support 2024-06-20 14:38:39 -03:00
Hamish Knight
eeced060fa [Parse] Handle #if in brace skipping logic
Previously we would strictly match `{` + `}`, but
that ignored the fact that when parsing we consider
`#if` + `#endif` to be a stronger delimiter than
`{` + `}`, so can ignore a stray `}` in a `#if`.
Update the logic to also track opening and closing
`#if` decls, ignoring any braces that happen within
them.

rdar://129195380
2024-06-19 21:39:40 +01:00
Hamish Knight
a85ca1315b [Parse] Unify recovery for invalid tokens following a #if body
Previously we would only diagnose and recover for
invalid tokens following a `#if` body for the decl
and postfix expression case. Sink this logic into
`parseIfConfigRaw`, ensuring that we do this for
all `#if` cases. This requires propagating the
context we're parsing in to customize the
diagnostic.
2024-06-19 21:39:40 +01:00
Pavel Yaskevich
afa66b1a6b [AST] Rework diagnostic about init accessors inside of extensions 2024-06-19 11:24:55 -07:00
Tim Kientzle
1098054291 Merge branch 'main' into tbkka-assertions2 2024-06-18 17:52:00 -07:00
Mateus Rodrigues
013997dae7 Implement trailing comma for comma-separated lists 2024-06-18 14:01:38 -03:00
Zhen Li
e298a663a2 Merge branch 'apple:main' into fix-init-accessor-71578 2024-06-17 12:48:20 -07:00
Doug Gregor
470bdc6934 Provide property source locations for @_documentation.
This was breaking macro expansion in the weirdest way. Fixes rdar://127206128
2024-06-13 12:53:54 -07:00
Meghana Gupta
c14559173d Add dependsOn(immortal) 2024-06-11 11:18:10 -07:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Meghana Gupta
470fa2f365 Remove resultDependsOn/resultDependsOnSelf 2024-06-05 11:36:16 -07:00