Commit Graph

721 Commits

Author SHA1 Message Date
Doug Gregor
c5de02f60e Merge pull request #77628 from DougGregor/clang-importer-parse-request
[Clang importer] Use ParseSourceFileRequest for parsing swift_attr attributes
2024-11-16 01:12:27 -08:00
Rintaro Ishizaki
5e6904f8c7 [ASTGen] Add a convenient method to process attribute arguments 2024-11-15 15:45:16 -08:00
Jakub Florek
5b39ba66b8 Merge branch 'main' into swift-lexical-lookup-validation 2024-11-15 22:05:43 +01:00
Doug Gregor
7872fc6c4b Introduce DeclAttribute::clone() to clone declaration attributes (obviously) 2024-11-15 09:02:45 -08:00
Rintaro Ishizaki
1fc00ae248 [ASTGen] Remove LegacyParser ping-pong mechanism
Now that ASTGen should be able to generate most Swift code. Let's
remove "legacy parser" call-in, and remove the unhealthy cyclic
dependency between lib/Parse and ASTGen.
2024-11-14 22:46:43 -08:00
Rintaro Ishizaki
f47c2b353f [ASTGen] Generate CustomAttr
Update macro tests
2024-11-14 15:10:12 -08:00
Rintaro Ishizaki
0f1b650716 [AST] MacroRoleAttr accept any 'Expr *' as the conformances arguments 2024-11-14 15:10:11 -08:00
Rintaro Ishizaki
093d0dffb4 [ASTGen] Generate MacroDecl 2024-11-14 15:10:08 -08:00
Rintaro Ishizaki
97eda9ac03 Merge pull request #77608 from rintaro/astgen-decl-optional
[ASTGen] Skip named decls with missing name
2024-11-14 09:45:44 -08:00
Jakub Florek
d724230a91 Add casting of exported source file syntax to SourceFileSyntax. 2024-11-14 13:22:27 +01:00
Jakub Florek
34c90f1c01 Merge remote-tracking branch 'upstream/main' into swift-lexical-lookup-validation 2024-11-14 10:38:20 +01:00
Rintaro Ishizaki
c4955edb6d [ASTGen] Skip value decls missing the name 2024-11-13 23:09:03 -08:00
Rintaro Ishizaki
2891d9e460 [ASTGen] Make generate(decl:) return optional value 2024-11-13 23:01:40 -08:00
Doug Gregor
8f5e941667 [ASTGen] Move unimplemented macro role case down 2024-11-13 21:22:02 -08:00
Doug Gregor
989c73d014 Ensure that buffers containing Clang swift_attr attributes are parsed as attributes
Previously, they were being parsed as top-level code, which would cause
errors because there are no definitions. Introduce a new
GeneratedSourceInfo kind to mark the purpose of these buffers so the
parser can handle them appropriately.
2024-11-13 21:19:37 -08:00
Rintaro Ishizaki
ac8dd89ffd [ASTGen] Generate 'switch' expressions 2024-11-13 10:25:50 -08:00
Jakub Florek
3ef2312a3e Merge branch 'swift-lexical-lookup-validation' of https://github.com/MAJKFL/swift into swift-lexical-lookup-validation 2024-11-13 17:43:46 +01:00
Jakub Florek
8fc6951c9f Use ConfiguredRegions instead of BuildConfiguration with LookupConfig. 2024-11-13 17:43:12 +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
13406e3b58 Update Exprs.swift 2024-11-06 13:56:09 -08:00
Alejandro Alonso
5520baeab0 Address ASTGen feedback 2024-11-06 13:55:01 -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
bba4f65b6c Merge pull request #77404 from rintaro/astgen-diagnostics-simple
[ASTGen] Simplify diagnostics framework
2024-11-06 10:59:36 -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
92c4989730 [ASTGen] Simplify diagnostics framework
This simplifies both the diagnostic declarations and usages.

To create a new diangnostic message, create a static method:

  extension ASTGenDiagnostic {
    static func invalidToken(_ token: TokenSyntax) -> Self {
      return Self(
        node: token,
        message: "invalid token: '\(token.trimmed)'"
      )
    }
  }

To use it In ASTGenVisitor:

  self.diagnose(.invalidToken(token))
2024-11-05 13:12:20 -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
Jakub Florek
ba004b6be0 Fix validation of names with end flag. Fix missing lib in cmake file. 2024-11-01 20:45:55 +01:00
Rintaro Ishizaki
00306613ef [ASTGen] Unify common logic among FreestandingMacroExpansion 2024-10-30 22:43:28 -07:00
Rintaro Ishizaki
dfdba15121 [ASTGen] Generrate MacroExpansionExpr 2024-10-30 22:43:26 -07:00
Rintaro Ishizaki
0d6f0743ab Merge pull request #77089 from rintaro/astgen-postfix-if-config-expr
[ASTGen] Generate postfix #if expressions
2024-10-30 15:49:55 -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
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
ce0bbb12d3 [ASTGen] Generate postfix #if expressions 2024-10-18 18:45:03 +09:00
Allan Shortlidge
dccc87f4e7 ASTGen: Remove a superfluous break. 2024-10-16 16:32:38 -07: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
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
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
Rintaro Ishizaki
cb6372a9c4 [ASTGen] Generate EditorPlaceholderExpr and 'do' expressions 2024-10-11 09:34:41 -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
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
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
Rintaro Ishizaki
1d3cb5c34e Merge pull request #76918 from rintaro/astgen-top-level-endloc
[ASTGen] Fix end location of TopLevelCodeDecl
2024-10-09 11:06:11 -07:00
Erik Eckstein
8935517eae ASTGen: fix a compiler warning
Fixes
```
.../swift/lib/ASTGen/Sources/ASTGen/Types.swift:359:29: warning: 'specifier' is deprecated: Access the specifiers list instead
    if let specifier = node.specifier {
                            ^
```
2024-10-09 10:52:41 +02:00
Rintaro Ishizaki
0df94f1551 [ASTGen] Fix end location of TopLevelCodeDecl
TopLevelCodeDecl::getEndLoc() should return the token location of the
last token. If the last token is a string literal or a regex literal,
it should be the location of the literal token.
2024-10-08 15:09:35 -07:00
Rintaro Ishizaki
e7a2102203 [ASTGen] Generate UnresolvedSpecializeExpr 2024-10-08 09:47:12 -07:00
Rintaro Ishizaki
834d98dca8 [ASTGen] Genrate InOutExpr 2024-10-08 09:47:11 -07:00