Commit Graph

309 Commits

Author SHA1 Message Date
Rintaro Ishizaki
f25104ff24 [ASTGen] Generate MagicIdentifierLiteralExpr 2025-02-12 20:47:52 -08:00
Allan Shortlidge
0722efe97e AST: Retire PlatformAgnosticVersionConstraintAvailabilitySpec. 2025-02-12 20:41:00 -08:00
Allan Shortlidge
6844cfe714 AST: Retire OtherPlatformAvailabilitySpec. 2025-02-12 19:39:30 -08:00
Allan Shortlidge
3142803d2f AST: Remove runtime version from AvailabilitySpec.
Instead of canonicalizing platform versions during parsing and storing two
versions, just canonicalize the parsed version on-demand when its requested.
2025-02-11 20:10:07 -08:00
Rintaro Ishizaki
04b2174c52 Merge pull request #79232 from rintaro/astgen-closure-anonparam
[ASTGen] Generate anonymous closure parameters
2025-02-10 11:44:12 -08:00
Rintaro Ishizaki
1c1570b5f6 Merge pull request #79203 from rintaro/astgen-miscavailableattr
[ASTGen] Generate miscellaneous availability related nodes
2025-02-07 20:14:17 -08:00
Rintaro Ishizaki
cb049d8ed1 [ASTGen] Generate anonymous closure parameters
E.g. '$0'
2025-02-07 19:39:57 -08:00
Rintaro Ishizaki
c56dd2efca [ASTGen] Generate miscellaneous availability related nodes
* `@_specialize` with `availability:` arguments
* `@backDeployed` attributes
* `@_originallyDefinedIn` attributes
* `#available()` and `#unavailable()` statement conditions
2025-02-07 10:01:07 -08:00
Michael Gottesman
d33371a51a Merge pull request #79178 from xedin/execution-attr-in-type-context
[AST/Parse] Initial implementation of `@execution(concurrent | caller)` in type context
2025-02-06 18:44:00 -08:00
Rintaro Ishizaki
ebf7a421fd [Bridging] Add 'const' variations to BRIDGING_WRAPPER
Only for `AvailabilityMacroMap` for now.
2025-02-05 11:44:54 -08:00
Pavel Yaskevich
f206956a23 [AST] Add @execution(concurrent | caller) type attribute 2025-02-05 00:19:40 -08:00
Rintaro Ishizaki
df2ada37df [ASTGen] Generate AvailableAttr
* Move `AvailabilitySpec` handling logic to AST, so they can be shared
  between libParse and ASTGen
* Requestify '-define-availability' arguments parsing and parse them
  with 'SwiftParser' according to the 'ParserASTGen' feature flag
* Implement 'AvailableAttr' generation in ASTGen
2025-02-04 23:40:01 -08:00
Erik Eckstein
f53635911c Swift AST: add var Decl.hasClangNode 2025-01-27 09:59:48 +01:00
Pavel Yaskevich
667a976ec5 [ASTGen] Add support for @execution(...) attribute 2025-01-17 15:40:01 -08:00
Doug Gregor
8bb5bbedbc Implement an unsafe expression to cover uses of unsafe constructs
Introduce an `unsafe` expression akin to `try` and `await` that notes
that there are unsafe constructs in the expression to the right-hand
side. Extend the effects checker to also check for unsafety along with
throwing and async operations. This will result in diagnostics like
the following:

    10 |   func sum() -> Int {
    11 |     withUnsafeBufferPointer { buffer in
    12 |       let value = buffer[0]
       |                   |     `- note: reference to unsafe subscript 'subscript(_:)'
       |                   |- warning: expression uses unsafe constructs but is not marked with 'unsafe'
       |                   `- note: reference to parameter 'buffer' involves unsafe type 'UnsafeBufferPointer<Int>'
    13 |       tryWithP(X())
    14 |       return fastAdd(buffer.baseAddress, buffer.count)

These will come with a Fix-It that inserts `unsafe` into the proper
place. There's also a warning that appears when `unsafe` doesn't cover
any unsafe code, making it easier to clean up extraneous `unsafe`.

This approach requires that `@unsafe` be present on any declaration
that involves unsafe constructs within its signature. Outside of the
signature, the `unsafe` expression is used to identify unsafe code.
2025-01-10 10:39:14 -08:00
Rintaro Ishizaki
660a2ea39a Merge pull request #78335 from rintaro/revert-revert-77140-swift-lexical-lookup-validation
Reapply "[SwiftLexicalLookup] New unqualified lookup implementation validation"
2025-01-06 09:12:45 -08:00
Rintaro Ishizaki
a0d7068162 Revert "Merge pull request #78280 from swiftlang/revert-77140-swift-lexical-lookup-validation"
This reverts commit ae88aaca8f, reversing
changes made to b0123bca14.
2024-12-20 16:37:36 -08:00
Becca Royal-Gordon
a6df4ef85c Merge pull request #76878 from beccadax/abi-changed-your-name 2024-12-20 10:30:48 -08:00
Becca Royal-Gordon
9c1e00ce52 [ASTGen] Lower @abi in ASTGen 2024-12-19 15:49:35 -08:00
Becca Royal-Gordon
201ccaf053 [NFC] [ASTGen] Refactor attribute attachment
Use `Decl::attachParsedAttrs()` instead of `Decl::setAttrs()` to attach attributes to a declaration in ASTGen. This causes the common attribute-setup logic there to be run.

NFC in this commit because none of the attributes that have special setup logic are currently implemented in ASTGen. Prepares to add support for `@abi` in a future commit.
2024-12-19 15:49:35 -08:00
Erik Eckstein
4fdf16de1b SIL: add CanonicalType.canBeClass
And move the implementation of `SIL.Type.canBeClass` to the AST Type. The SIL Type just calls the AST Type implementation.
Also rename `SIL.Type.canonicalASTType` -> `SIL.Type.astType`.
2024-12-19 20:53:46 +01:00
Erik Eckstein
1545e01ab5 SIL: Let SubstitutionMap.replacementTypes return AST types rather than optional SIL types.
This is what the C++ SubstitutionMap does. One has to use `Type.loweredType` to get from the AST type to the SIL type.
2024-12-19 20:53:45 +01:00
Ben Barham
e06d0b9357 Revert "[SwiftLexicalLookup] New unqualified lookup implementation validation" 2024-12-18 15:04:16 -08:00
Jakub Florek
5dbe202087 Merge pull request #77140 from MAJKFL/swift-lexical-lookup-validation
[SwiftLexicalLookup] New unqualified lookup implementation validation
2024-12-18 17:29:47 +01:00
Rintaro Ishizaki
71ca3e129a [ASTGen] Use syntax tree based interface hash 2024-12-12 09:51:09 -08:00
Doug Gregor
ee9c066050 Introduce a new Initializer subclass for the arguments of custom attributes
Since the introduction of custom attributes (as part of property
wrappers), we've modeled the context of expressions within these
attributes as PatternBindingInitializers. These
PatternBindingInitializers would get wired in to the variable
declarations they apply to, establishing the appropriate declaration
context hierarchy. This worked because property wrappers only every
applied to---you guessed it!---properties, so the
PatternBindingInitializer would always get filled in.

When custom attributes were extended to apply to anything for the
purposes of macros, the use of PatternBindingInitializer became less
appropriate. Specifically, the binding declaration would never get
filled in (it's always NULL), so any place in the compiler that
accesses the binding might have to deal with it being NULL, which is a
new requirement. Few did, crashes ensued.

Rather than continue to play whack-a-mole with the abused
PatternBindingInitializer, introduce a new CustomAttributeInitializer
to model the context of custom attribute arguments. When the
attributes are assigned to a declaration that has a
PatternBindingInitializer, we reparent this new initializer to the
PatternBindingInitializer. This helps separate out the logic for
custom attributes vs. actual initializers.

Fixes https://github.com/swiftlang/swift/issues/76409 / rdar://136997841
2024-12-06 17:40:32 -08:00
Rintaro Ishizaki
6d7b3d69d1 [ASTGen] Generate several attributes
* NonisolatedAttr
* SpecializeAttr
* UnavailableFromAsyncAttr
* DocumentationAttr
* StorageRestrictionsAttr
2024-12-05 15:12:00 -08:00
Jakub Florek
866f1c1c04 Merge branch 'main' into swift-lexical-lookup-validation 2024-11-26 09:37:23 +01:00
Jakub Florek
5b39ba66b8 Merge branch 'main' into swift-lexical-lookup-validation 2024-11-15 22:05:43 +01:00
Jakub Florek
bda3c7f6c0 Use BRIDGED_INLINE to avoid dummy constructor in BridgedConsumedLookupResult. 2024-11-15 22:01:44 +01:00
Doug Gregor
7872fc6c4b Introduce DeclAttribute::clone() to clone declaration attributes (obviously) 2024-11-15 09:02:45 -08:00
Rintaro Ishizaki
f47c2b353f [ASTGen] Generate CustomAttr
Update macro tests
2024-11-14 15:10:12 -08:00
Rintaro Ishizaki
093d0dffb4 [ASTGen] Generate MacroDecl 2024-11-14 15:10:08 -08:00
Jakub Florek
f4a5069204 Add a dummy BridgedConsumedLookupResult constructor for compatibility with ARM windows. 2024-11-13 17:51:01 +01:00
Jakub Florek
4b544e963a Merge branch 'main' into swift-lexical-lookup-validation 2024-11-13 15:54:30 +01:00
Rintaro Ishizaki
0ba92d84e5 [ASTGen] Generate closure signatures
Still TODO:
* Capture list
* Anonymous parameters
2024-11-11 12:21:38 -08:00
Alejandro Alonso
ba3bc1d5f1 Implement ASTGen changes for integer generics from Swift Syntax
Support negatives
2024-11-06 13:54:59 -08:00
Rintaro Ishizaki
47f27a411c Merge pull request #77398 from rintaro/astgen-keypathexpr
[ASTGen] Generate Swift key-path expressions
2024-11-06 10:15:37 -08:00
Rintaro Ishizaki
dc156a644a [ASTGen] Generate Swift key-path expressions 2024-11-05 13:38:21 -08:00
Rintaro Ishizaki
e566a746c8 [ASTGen] Support macro expanded buffer
* Make ExportedSourceFile hold any Syntax as the root node
* Move `ExportedSourceFileRequest::evaluate()` to `ParseRequests.cpp`
* Pass  the decl context and `GeneatedSourceFileInfo::Kind` to
  `swift_ASTGen_parseSourceFile()` to customize the parsing
* Make `ExportedSourceFile` to hold an arbitrary Syntax node
* Move round-trip checking into `ExportedSourceFileRequest::evaluate()`
* Split `parseSourceFileViaASTGen` completely from C++ parsing logic
  (in `ParseSourceFileRequest::evaluate()`)
* Remove 'ParserDiagnostics' experimental feature: Now that we have
  ParserASTGen mode which includes the swift-syntax parser diagnostics.
2024-11-05 11:00:33 -08:00
Konrad `ktoso` Malawski
43839ac5fd Merge pull request #76995 from nickolas-pohilets/mpokhylets/disable-stack-promotion
Disable stack promotion for classes with isolated deinit
2024-11-04 18:07:11 +09:00
Mykola Pokhylets
cb7a8d5cfc Disable stack promotion for classes with isolated deinit 2024-10-31 20:43:11 +01:00
Rintaro Ishizaki
dfdba15121 [ASTGen] Generrate MacroExpansionExpr 2024-10-30 22:43:26 -07:00
Hamish Knight
9d4a78678a [Sema] Add logic to diagnose regex feature availability
Add the necessary compiler-side logic to allow
the regex parsing library to hand back a set of
features for a regex literal, which can then be
diagnosed by ExprAvailabilityWalker if the
availability context isn't sufficient. No tests
as this only adds the necessary infrastructure,
we don't yet hand back the features from the regex
parsing library.
2024-10-28 17:09:47 +00:00
Erik Eckstein
ed67e36ce5 bridging: reduce #ifdef USED_IN_CPP_SOURCE in bridging headers
Especially avoid any constructors in `#ifdef USED_IN_CPP_SOURCE` blocks, because this breaks Windows ARM64.
2024-10-25 09:47:56 +02:00
Jakub Florek
2cc00889bd Switch to integer division inaddPaddingUpTo. Rename magic constants in LoggingASTScopeDeclConsumer. Format BridgedConsumedLookupResult. 2024-10-23 12:27:15 +02:00
Jakub Florek
1d94844322 Add SwiftLexicalLookup validation. 2024-10-20 12:12:22 +02:00
Rintaro Ishizaki
66138e8395 [ASTGen] Generate ForceValueExpr and BindOptionalExpr 2024-10-13 07:30:36 -07:00
Hamish Knight
7c3f965578 Merge pull request #76979 from hamishknight/regex-request
Requestify regex pattern parsing
2024-10-12 19:19:09 +01: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