Commit Graph

803 Commits

Author SHA1 Message Date
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
2f81b70c89 Merge pull request #77311 from rintaro/astgen-macroexpr
[ASTGen] Generate standalone macro expansions
2024-10-31 16:28:23 -07:00
Rintaro Ishizaki
dc25477e63 Merge pull request #77310 from rintaro/astgen-package-purebridging
[ASTGen] Use 'PURE' bridging mode to improve editor experience
2024-10-31 00:50:46 -07: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
Rintaro Ishizaki
053f7ac65d [ASTGen] Use 'PURE' bridging mode to improve editor experience
'PURE' briding mode avoids importing things from `swift::` or `llvm::`
namespaces. Since it significantly reduces the number of decls to
import, editor experience is improved.
2024-10-30 15:30:18 -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
1461460770 Merge pull request #77096 from rintaro/macro-evaluation-package
[ASTGen] Correct swiftMacroEvaluation source path in Package.swift
2024-10-18 22:42:22 +09:00
Rintaro Ishizaki
4c403a3ddb [ASTGen] Correct MacroEvaluation source path in Package.swift 2024-10-18 18:46:14 +09: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
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
Rintaro Ishizaki
ea2b8ff749 [ASTGen] Remove all #if RESILIENT_SWIFT_SYNTAX
Building ASTGen with resilient swift-syntax modules is not a thing
anymore. `RESILIENT_SWIFT_SYNTAX` is never used.
2024-10-06 15:56:51 -07:00
Rintaro Ishizaki
d8cbdc35c3 Merge pull request #76843 from rintaro/cmake-astgen-cxxinterop
[CMake] Reorganize CMakeLists.txt for ASTGen
2024-10-03 10:51:08 -07:00
Konrad `ktoso` Malawski
dea3b59331 Merge pull request #76250 from ktoso/wip-experimental-isolated-deinit 2024-10-03 17:19:10 +09:00
Rintaro Ishizaki
d480761a9c [CMake] Sink add_pure_swift_host_library call into actual source dirs
Instead of doing everything in lib/ASTGen/CMakeLists.txt
2024-10-02 19:35:45 -07:00
Rintaro Ishizaki
fdacd9dabb [CMake] Add 'CXX_INTEROP' option to add_pure_swift_host_library 2024-10-02 19:34:59 -07:00
Rintaro Ishizaki
58ba27b34e [ASTGen/CMake] Remove redundant -Xcc -I options
Include directories are already specified in parent directories or
dependencies, and `-I` for swiftc are propagated to ClangImporter. We
don't need to specify them manually.
2024-10-02 19:34:57 -07:00
Rintaro Ishizaki
b3b7d35edc [ASTGen] Rename macro related @_cdecl functions to swift_Macros_*
Rename @_cdecl name of functions moved to swiftMacros module.
Also move those function decls to dedicated 'Macros.h' header.
2024-10-02 15:22:17 -07:00
Rintaro Ishizaki
134c0a1bdc [ASTGen] Move macros related code to a new dedicated module
Introduce 'swiftMacros' module.
2024-10-02 15:22:16 -07:00
Allan Shortlidge
6f91b4156c ASTGen/SIL: Suppress retroactive conformance warnings.
When building ASTGen and SIL using the Swift 6.0 compiler the compiler emits
diagnostics about various retroactive conformances. Since Swift code in the
compiler needs to remain compatible with the Swift 5.10 compiler for now, use
module qualification syntax to suppress the warning. I've also included the
`@retroactive` attribute in a comment to document the retroactive conformance
acknowledgement more explicitly.

NFC.
2024-10-01 17:07:03 -07:00
nate-chandler
ba8f8ea282 Merge pull request #76526 from nate-chandler/general-coro/20240906/1
[CoroutineAccessors] Initial framing.
2024-09-30 07:04:04 -07:00
Konrad `ktoso` Malawski
45b97f146b Merge branch 'main' into wip-experimental-isolated-deinit 2024-09-30 13:47:39 +09:00
Rintaro Ishizaki
efe38a0bcf [Windows] Enable "INLINE" bridging mode
* Workaround for https://github.com/swiftlang/llvm-project/issues/7172
* `-D_CRT_USE_BUILTIN_OFFSETOF` to make `offsetof()` a constant
* Pass correct 'swift/shims' search path
2024-09-27 13:50:18 -07:00
Nate Chandler
66e6c59681 [Features] Added CoroutineAccessors. 2024-09-26 18:10:38 -07:00
Nate Chandler
053e79ed64 [ASTGen] Added feature-mapping for ref bindings. 2024-09-26 18:10:38 -07:00
Konrad `ktoso` Malawski
7d1ce789ad Revert "Revert "Isolated synchronous deinit"" 2024-09-17 17:35:38 +09:00
Rintaro Ishizaki
57ff50d786 [Package.swift] Bump macOS deployment target version to 13.0
Compiler's minimum deployment target version is now 13.0
2024-09-13 10:15:40 -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
Doug Gregor
42809af51e Merge pull request #76327 from DougGregor/suppress-warnings-in-inactive-regions-without-ifconfigdecl
Suppress certain warnings in inactive `#if` regions without relying on `IfConfigDecl`
2024-09-07 10:16:20 -07:00
Doug Gregor
48db8767b5 Suppress the warning for inactive try/throw in do..catch
In the warning about having no try/throw within the body of a do..catch,
replace the walk of the inactive clauses of IfConfigDecl with a syntactic
check of inactive and unparsed regions to look for 'try' and 'throw'
keywords.

This both eliminates a dependency on IfConfigDecl and expands the
usefulness of this warning suppression to unparsed code.
2024-09-06 22:38:04 -07:00