mirror of
https://github.com/apple/swift.git
synced 2026-06-20 15:42:51 +02:00
425cd0ebd7
**Overview**: This PR introduces the basic infrastructure needed to eventually migrate derived macros generation from hand-crafted AST nodes to macros. No conformance have been migrated yet. **Motivation**: Derived conformances (e.g. `Equatable`, `Hashable`, `Codable`, ...) are currently implemented as a special case in the compiler, producing synthetic AST nodes directly. Migrating this to macros will hopefully unify the code path with the existing macro expansion infrastructure, make conformance synthesis easier to extend and test as well as reducing the amount of special cases in the compiler. **Changes**: - New experimental feature flag `DeriveConformancesViaMacros`: Introduces the flag that will eventually gate the new derived conformance code paths. It does not control any behaviour for the moment as none have been migrated yet but this enables future changes to be built incrementally. - New GeneratedSourceInfo and SourceFile kinds `SyntheticMacro`: Introduces new GSI and SourceFile kinds named `SyntheticMacro` to represent macros synthesized by the compiler. Since macros need a real buffer to expand, this is the kind of source file and GSI associated with those buffers. - Conformance derivation via macros API: Introduces the `deriveRequirementViaMacro` function that produces the required witness via macro expansion. See https://github.com/swiftlang/llvm-project/pull/13124 for llvm-related changes. **Next steps**: - Macros do not contain any semantic information, especially regarding types. Therefore it is necessary to provide them with type information as an argument so they can eventually derive the conformances. A separate PR is being created to generate this type information as strings containing swift-parsable code for easy parsing on the macro end. - Implement derived conformance synthesis for individual protocols using the new infrastructure, like `Equatable` or `Hashable` for starters. - Wire the experimental flag to gate the new path once an implementation exists --------- Co-authored-by: Hamish Knight <hamish_knight@apple.com>
//===----------------------------------------------------------------------===//
// SourceKit README
//===----------------------------------------------------------------------===//
Welcome to SourceKit! SourceKit is a framework for supporting IDE features like
indexing, syntax-coloring, code-completion, etc. In general it provides the
infrastructure that an IDE needs for excellent language support.
SourceKit currently only supports the Swift language.
//===----------------------------------------------------------------------===//
// Linking to the SourceKit C API
//===----------------------------------------------------------------------===//
The stable C API for SourceKit is provided via the sourcekitd.framework which
uses an XPC service for process isolation and the libsourcekitdInProc.dylib
library which is in-process.
libsourcekitdInProc.dylib is more convenient for debugging. To use it either:
-Link to this library instead of the framework ("-lsourcekitdInProc" instead
of "-framework sourcekitd")
-Run the binary that linked to the framework using these environment variables:
DYLD_INSERT_LIBRARIES=/path/to/libsourcekitdInProc.dylib DYLD_FORCE_FLAT_NAMESPACE=1 <...>
//===----------------------------------------------------------------------===//