-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[🦩] Add swiftASTGen library to build a C++ AST from a SwiftSyntax parse tree #61426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This incorporates @zoecarver 's #60943, and cleans up some of the build system and integration bits so we can hopefully land it. |
@swift-ci please smoke test |
@swift-ci please test source compatibility |
Thank you for fixing this up, Doug! |
@swift-ci please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets remove the xcworkspacedata
file and Zoe's UserInterfaceState.xcuserstate
.
FYI there's a |
@swift-ci please test |
This really doesn't do much now, and lots of stuff is likely to get reworked. We need to do a deep dive on a small part of the grammar (types and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overall build structure looks good to me. I didn’t review any of the new Swift or C++ code because IIUC that’s not the intention of this PR.
@swift-ci please smoke test |
(cherry picked from commit 7bc67c9)
(cherry picked from commit 2df25fc)
(cherry picked from commit ddede20)
(cherry picked from commit 4e9e5fe)
(cherry picked from commit 1b1944e)
(cherry picked from commit 629fb68)
(cherry picked from commit d58a01d)
(cherry picked from commit 5935670)
Only introduce it and its dependency when the new Swift parser is being built, and rely more on existing logic to make sure we get the right build/link flags.
We'll be going the other way, with diagnostics existentials.
This is a temporary hack; we shouldn't even need to create the C++ parser here.
@swift-ci please smoke test |
TO BE CLEAR, I have no idea what the flamingo is about. @zoecarver gonna hafta answer that one. I just work here. |
Just keeping things organized... |
@swift-ci please test source compatibility |
@swift-ci please test macOS |
Windows test failure is unrelated |
Builds of Swift sources via CMake are not getting a target triple set, so they pick up the host triple. This leads to spurious warnings about linking in code built for a newer OS version (e.g., the one you're on) into libraries with an older deployment target. It also breaks building a cross-compiler. Always set the target triple.
@swift-ci please test |
@swift-ci please test source compatibility |
@swift-ci please build toolchain |
Introduce a
swiftASTGen
library, written as a Swift module, which produces a C++ AST from the corresponding SwiftSyntax syntax tree as produced by the new Swift parser. Architecturally, this new library sits between the C++ AST library (since it constructs ASTs) and the C++ parser (whose entry points will be diverted through this library). This new code path intercepts the main entry point of the C++ parser, which parses "top-level" declarations, when the command-line option--enable-experimental-feature ParserASTGen
. It doesn't do much yet; this pull request is primarily to get all of the major architectural pieces in place so we can iterate on them.swiftASTGen
depends on theCASTBridging
layer, a painstakingly-crafted C API that is used to build and inspect C++ AST nodes, so they can be used from Swift. We cannot currently depend on Swift/C++ interoperability, because it is an experimental feature, whereas this library will need to be able to build with a host Swift compiler from up to a year ago.The CMake build system is the only one that's able to produce a working compiler. There is also a
Package.swift
that makes it easier to build and work with theswiftASTGen
library within IDEs, but it's mainly there for editing---it won't create something that can be meaningfully executed. Most things with the new Swift parser are better implemented/tested within or on top of theswift-syntax
package.