Commit Graph

58 Commits

Author SHA1 Message Date
eeckstein
ca76efabb4 Merge pull request #79908 from eeckstein/fix-witness-table-specialization
embedded: fix specialization of associated conformance entries in witness tables
2025-03-11 18:16:23 +01:00
Erik Eckstein
5212d92b57 Swift AST: add Conformance.getAssociatedConformance 2025-03-11 11:17:00 +01:00
WeZZard
2237faca04 [SILOptimizer] Refines the implementation of of the bridged SILType for Swift. 2025-03-11 09:29:11 +08:00
eeckstein
737b5ec924 Merge pull request #79674 from eeckstein/simplify-open-existential-metatype
Optimizer: Rework peephole optimizations to replace existential (archetypes) with concrete types
2025-03-10 08:18:52 +01:00
Rintaro Ishizaki
0a56198879 [ASTGen] Remove BridgedAvailabilityDomain 2025-03-07 07:18:23 -08:00
Erik Eckstein
26c7310a9a Swift AST: Fix debug description of Type
Don't get the swift source version string, but the debug dump string
2025-03-07 15:59:35 +01:00
Erik Eckstein
77dab77702 Swift SIL: make isLegalFormalType available in AST.Type 2025-03-07 15:59:34 +01:00
Erik Eckstein
67925ea27e Swift AST: add GenericSignature
and add `var Type.invocationGenericSignatureOfFunctionType`
2025-03-07 15:59:34 +01:00
Erik Eckstein
810064b7dc Cleanup and additions to AST and SIL Type/CanonicalType
* factor out common methods of AST Type/CanonicalType into a `TypeProperties` protocol.
* add more APIs to AST Type/CanoncialType.
* move `MetatypeRepresentation` from SIL.Type to AST.Type and implement it with a swift enum.
* let `Builder.createMetatype` get a CanonicalType as instance type, because the instance type must not be a lowered type.
2025-03-07 15:59:33 +01:00
Erik Eckstein
eadfbf6842 Swift AST: add some APIs to Type and CanonicalType 2025-03-07 15:59:33 +01:00
Rintaro Ishizaki
d60f1986a8 [ASTGen] Adopt AvailabilityDomainOrIdentifier scheme
Aligning with libParse
2025-03-07 04:14:50 -08:00
Rintaro Ishizaki
4160f101ad [ASTGen] Generate @_unavailableInEmbedded attribute
Which is a sugar of '@available(*, unavailable)' when Embedded feature
is enabled.
2025-02-21 16:54:09 -08:00
Rintaro Ishizaki
8833ff58a2 [AST] Sink the flag collection logic from Parse to AST
* Collect flag in `ParamDecl::setTypeRepr()`.

* [ASTGen] Separate `BridgedParamDecl.setTypeRepr(_:)` from
`BridgedParamDecl.createParsed(_:)` aligning with C++ API. The majority
of the creations don't set the typerepr.

* Update `ParamSpecifierRequest::evaluate` to handle non-implicit
`ParamDecl` without `TypeRepr` (i.e. untyped closure parameter), instead
of `setSpecifier(::Default)` manually in Parse.
2025-02-20 10:04:49 -08:00
Rintaro Ishizaki
2b14a233b7 [ASTGen] Generate generic layout constraint 2025-02-19 16:38:00 -08:00
Rintaro Ishizaki
d109a86bb7 [ASTGen] Generate CustomAttr on types
Rework TypeAttribute bridging facilities.
Eliminate the _fake_ `swift::TypeAttributes`, but just use the normal
`BridgedArrayRef` for briding the attribute list. Introduce
`BridgedTypeOrCustomAttr` tagged pointer which resembles
`swift::TypeOrCustomAttr`.
2025-02-18 13:08:50 -08:00
Rintaro Ishizaki
57b6d1e90b [ASTGen] Generate "minus" number literal expression 2025-02-17 21:34:11 -08:00
Rintaro Ishizaki
6d85bb58c5 Merge pull request #79412 from rintaro/astgen-typeattrs
[ASTGen] Generate OpaqueReturnTypeOfTypeAttr
2025-02-16 13:55:39 -08:00
Rintaro Ishizaki
84875d147e [ASTGen] Bridge ASTContext.Id_x 2025-02-16 05:22:46 -08:00
Rintaro Ishizaki
0ced6e06b4 [ASTGen] Generate CaptureListExpr
Move the capture list entry construction logic to
CaptureListEntry::createParsed() so that ASTGen can use it.
2025-02-16 05:22:46 -08:00
Rintaro Ishizaki
6184367492 [Parse] Post-process parsed AST to register decls with opaque result
Move the logic out of `Paser` so `ASTGen` can use it.
2025-02-14 18:51:22 -08:00
Rintaro Ishizaki
f2db96cc60 [ASTGen] Eliminate ASTGen.ASTNode
We can simply use `BridgedASTNode`, no need to have its own ASTNode
2025-02-14 07:05:10 -08:00
Rintaro Ishizaki
6ea6a31ec7 [ASTGen] Generate TopLevelCodeDecl for PatternBindingDecl
* Instead of hoisting VarDecl in the bridging functions, do it in
  ASTGen.
* Introduce `Decl::forEachDeclToHoist` to handle VarDecls in
  PatternBindingDecl, and EnumElementDecl in EnumCaseDecl.
* Intorduce `withBridgedSwiftClosure(closure:call:)` as a callback
  mechanism between Swift and C++
* In `generate(sourceFile:)`, instead of using `generate(codeBlockItem:)`
  handle `CodeBlockItemSyntax.Item` manually to handle `TLCD` wrapping
  and `VarDecl` hoisting.
* Make `generate(variableDecl:)` handle TLCD correctly.
2025-02-13 00:09:22 -08:00
Rintaro Ishizaki
cb049d8ed1 [ASTGen] Generate anonymous closure parameters
E.g. '$0'
2025-02-07 19:39:57 -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
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
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
Hiroshi Yamauchi
bb197e098d Avoid build error with Visual Studio 17.8.7 MSVC 19.38.33135.0 compiler 2024-12-16 17:25:05 -08:00
Rintaro Ishizaki
71ca3e129a [ASTGen] Use syntax tree based interface hash 2024-12-12 09:51:09 -08:00
Rintaro Ishizaki
6d7b3d69d1 [ASTGen] Generate several attributes
* NonisolatedAttr
* SpecializeAttr
* UnavailableFromAsyncAttr
* DocumentationAttr
* StorageRestrictionsAttr
2024-12-05 15:12:00 -08: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
Rintaro Ishizaki
093d0dffb4 [ASTGen] Generate MacroDecl 2024-11-14 15:10:08 -08:00
Rintaro Ishizaki
0ba92d84e5 [ASTGen] Generate closure signatures
Still TODO:
* Capture list
* Anonymous parameters
2024-11-11 12:21:38 -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
Mykola Pokhylets
cb7a8d5cfc Disable stack promotion for classes with isolated deinit 2024-10-31 20:43:11 +01: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
Rintaro Ishizaki
6018662615 Merge pull request #76889 from rintaro/astgen-regexexpr
[ASTGen] Implement some Expr generation
2024-10-09 22:39:50 -07:00
Rintaro Ishizaki
09f49b0c87 [ASTGen] Generate FloatLiteralExpr 2024-10-08 09:46:56 -07:00
Rintaro Ishizaki
7d9ba2d36d [ASTGen] Generate RegexLiteralExpr, SubscriptExpr, and SuperRefExpr 2024-10-08 09:34:17 -07:00
Erik Eckstein
1856e7f68a SwiftCompilerSources: add the ValueDecl.isObjC API 2024-10-08 16:23:22 +02:00
Erik Eckstein
a3e6e86383 Embedded: support existentials with inherited conformances
That means: derived classes where the base conforms to a protocol
2024-10-07 12:25:18 +02:00
Erik Eckstein
d4192d5d00 SwiftCompilerSources: add Type.subst(with substitutionMap: SubstitutionMap) -> Type API 2024-10-07 09:00:31 +02:00
Erik Eckstein
10782cf42b SwiftCompilerSources: introduce the AST module
As the optimizer uses more and more AST stuff, it's now time to create an "AST" module.
Initially it defines following AST datastructures:
* declarations: `Decl` + derived classes
* `Conformance`
* `SubstitutionMap`
* `Type` and `CanonicalType`

Some of those were already defined in the SIL module and are now moved to the AST module.
This change also cleans up a few things:
* proper definition of `NominalTypeDecl`-related APIs in `SIL.Type`
* rename `ProtocolConformance` to `Conformance`
* use `AST.Type`/`AST.CanonicalType` instead of `BridgedASTType` in SIL and the Optimizer
2024-10-02 07:10:29 +02:00
Erik Eckstein
7ecb407226 SwiftCompilerSources: bridge SILDeclRef
And move NominalTypeDecl and DeclRef from Type.swift into a new file Declarations.swift.
Also add some APIs to NominalTypeDecl
2024-09-25 19:31:40 +02:00