Commit Graph

779 Commits

Author SHA1 Message Date
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
Doug Gregor
4a4c0f68f1 Teach the "unused variable / value" diagnostics to use SwiftIfConfig
Rather than walking into the inactive regions of IfConfigDecls looking for
references to a declaration before we diagnose it, go to the syntax
tree and look through inactive *and unparsed* regions for identifier
tokens that match. If we find one, suppress the diagnostic.

This reduces our dependency on IfConfigDecl in the AST, and also makes
the same suppression work with code in unparsed regions that had no
representation in IfConfigDecl.
2024-09-06 22:14:52 -07:00
Doug Gregor
66dba4aa46 Use a cached copy of ConfiguredRegions within an ExportedSourceFile
Rather than potentially computing ConfiguredRegions multiple times in
ASTGen and other queries, cache the result in the ExportedSourceFile.

This is temporary; we should bring up a Swift equivalent to the
request-evaluator (or bridge to the C++ one) to manage state like
this.
2024-09-06 21:22:05 -07:00
Alex Hoppen
bf96347d63 Merge pull request #76298 from ahoppen/no-sending-args
[ASTGen] Don’t map `sendingArgsAndResults`
2024-09-06 13:04:16 -07:00
Alex Hoppen
530cff15d0 [ASTGen] Don’t map sendingArgsAndResults
The corresponding evolution proposal has been accepted and the experimental feature no longer exists in swift-syntax.
2024-09-05 14:52:15 -07:00
Alejandro Alonso
bfffd7e119 Set the param kind in ASTGen 2024-09-04 15:13:47 -07:00
Alejandro Alonso
f4f60f4344 Remove Value requirement Add GenericTypeParamKind 2024-09-04 15:13:43 -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
Doug Gregor
a73711ef4b Implement extractInlinableText with swift-syntax
Replace the existing C++ implementation of extractInlinableText with
a new implementation based on swift-syntax. It uses SwiftIfConfig to
remove inactive regions (with a special mode), and a new compiler-only
entrypoint in the library to remove comments and `#sourceLocation`.
2024-08-30 16:43:41 -07:00
Doug Gregor
256f39e5ee Use the SwiftIfConfig library for evaluating #if conditions.
Replace the C++ implementation of #if condition operator folding,
validation, and evaluation with the corresponding facilities in the
SwiftIfConfig library.

Leave the C++ implementation in place for now to permit the compiler
to continue building without swift-syntax.
2024-08-24 21:31:40 -07:00
Doug Gregor
0e72c53f02 [SwiftIfConfig] Adopt updated APIs to for build configuration handling
Switch to the new `canImport` API that includes TokenSyntax nodes for each
import path, so we can provide better source locations. We no longer need
to stuff a random source location into `CompilerBuildConfiguration`.

Make use of `ConfiguredRegions.isActive(_:)` directly instead of going
through the older entrypoint.

When parser validation is enabled, we currently can end up with duplicated
diagnostics from canImport. This is going to require some requestification
to address.
2024-08-23 22:39:40 -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
e27f19520c Merge pull request #75937 from DougGregor/astgen-swiftifconfig 2024-08-21 06:34:17 -07:00
Doug Gregor
afd365b53a Make CompilerBuildConfiguration a struct again 2024-08-20 22:12:13 -07:00
Doug Gregor
dfe17e4d39 Be consistent about deallocating memory allocated from C++ in C++
Fixes a crash on Windows due to mismatched allocators.
2024-08-20 22:12:12 -07:00
Doug Gregor
cccf6c1114 Introduce @unsafe and the ability to prohibit use of unsafe declarations
Allow any declaration to be marked with `@unsafe`, meaning that it
involves unsafe code. This also extends to C declarations marked with
the `swift_attr("unsafe")` attribute.

Under a separate experimental flag (`DisallowUnsafe`), diagnose any
attempt to use an `@unsafe` declaration or any unsafe language feature
(such as `unowned(unsafe)`, `@unchecked Sendable`). This begins to
define a "safe" mode in Swift that prohibits memory-unsafe constructs.
2024-08-19 14:33:07 -07:00
Doug Gregor
1da2631c4e Use SwiftIfConfig to determine where to emit new parser diagnostics 2024-08-17 22:48:18 -07:00
Doug Gregor
0f2cedb92b [ASTGen] Implement #if config handling using the SwiftIfConfig library
Wherever there is a syntax collection in the syntax tree that can involve
an `#if` clause, evaluate the `#if` conditions to find the active clause,
then recurse into the active clause (if one exists) to "flatten" the
translated collection to only contain active elements.

Note that this does not yet handle #if for postfix expressions.
2024-08-17 22:48:18 -07:00
Hamish Knight
55aed16ee6 Requestify FallthroughStmt source and destination lookup
Follow a similar pattern to BreakTargetRequest
and ContinueTargetRequest.
2024-08-14 19:59:05 +01:00
Mateus Rodrigues
ac57e61278 Merge branch 'main' into trailing-comma 2024-08-06 09:34:43 -03:00
Doug Gregor
cfd0a3fc53 Thread a source location through canImport evaluation in CompilerBuildConfiguration
Unlike all of the other build configuration checks, `canImport` has
side effects including the emission of various diagnostics. Thread a
source location through here so the diagnostics end up on the right
line.
2024-08-04 05:58:53 -07:00
Doug Gregor
a844f4fa0b Free memory allocated in Swift from Swift, not C++ 2024-08-02 10:04:29 -07:00
Doug Gregor
ddbbb5a71e Address code review comments and build failure 2024-08-02 10:04:28 -07:00
Doug Gregor
ca588b7aea Insert #endif directives into #if config ranges list produced by SwiftIfConfig
The SIL coverage map generation depends on the locations of the `#endif`
directives, but the mapping from SwiftIfConfig's configured regions wasn't
producing them. The information is implicitly available in the
SwiftIfConfig configured regions, so reconstitute it as we translate
regions.
2024-08-02 10:04:27 -07:00