Commit Graph

32 Commits

Author SHA1 Message Date
Rintaro Ishizaki
a0d7068162 Revert "Merge pull request #78280 from swiftlang/revert-77140-swift-lexical-lookup-validation"
This reverts commit ae88aaca8f, reversing
changes made to b0123bca14.
2024-12-20 16:37:36 -08:00
Ben Barham
e06d0b9357 Revert "[SwiftLexicalLookup] New unqualified lookup implementation validation" 2024-12-18 15:04:16 -08:00
Jakub Florek
4b544e963a Merge branch 'main' into swift-lexical-lookup-validation 2024-11-13 15:54:30 +01: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
Jakub Florek
1d94844322 Add SwiftLexicalLookup validation. 2024-10-20 12:12:22 +02:00
Rintaro Ishizaki
4c403a3ddb [ASTGen] Correct MacroEvaluation source path in Package.swift 2024-10-18 18:46:14 +09: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
134c0a1bdc [ASTGen] Move macros related code to a new dedicated module
Introduce 'swiftMacros' module.
2024-10-02 15:22:16 -07: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
Doug Gregor
5c3b7777e7 Implement a SwiftIfConfig.BuildConfiguration that queries the ASTContext
This concrete implementation of the BuildConfiguration allows the use of
the SwiftIfConfig library's APIs where the build configuration comes from
the compiler itself.
2024-08-02 10:04:26 -07:00
Rintaro Ishizaki
3f8d13d491 [swift-syntax] Update for underscored product names 2024-06-26 09:32:44 -07:00
Rintaro Ishizaki
2f7aa428db [Macros] In-process plugin server
Separate swift-syntax libs for the compiler and for the library plugins.
Compiler communicates with library plugins using serialized messages
just like executable plugins.

* `lib/swift/host/compiler/lib_Compiler*.dylib`(`lib/CompilerSwiftSyntax`):
  swift-syntax libraries for compiler. Library evolution is disabled.
* Compiler (`ASTGen` and `swiftIDEUtilsBridging`) only depends on
  `lib/swift/host/compiler` libraries.
* `SwiftInProcPluginServer`: In-process plugin server shared library.
  This has one `swift_inproc_plugins_handle_message` entry point that
  receives a message and return the response.
* In the compiler
  * Add `-in-process-plugin-server-path` front-end option, which specifies
    the `SwiftInProcPluginServer` shared library path.
  * Remove `LoadedLibraryPlugin`, because all library plugins are managed
    by `SwiftInProcPluginServer`
  * Introduce abstract `CompilerPlugin` class that has 2 subclasses:
    * `LoadedExecutablePlugin` existing class that represents an
      executable plugin
    * `InProcessPlugins` wraps `dlopen`ed `SwiftInProcPluginServer`
  * Unified the code path in `TypeCheckMacros.cpp` and `ASTGen`, the
    difference between executable plugins and library plugins are now
    abstracted by `CompilerPlugin`
2024-06-17 11:36:52 -07:00
Rintaro Ishizaki
cd54cc1c31 [Macros] Use SwiftCompilerPluginMessageHandling JSON encoder/decoder
Replacing swiftLLVMSJON with SwiftCompilerPluginMessageHandling.JSON
2024-04-25 14:42:20 -07:00
Rintaro Ishizaki
b2781938fe [ASTGen] Use Absolute paths for -I options
Don't rely on the working directory being the package directory.
2024-04-24 14:23:39 -07:00
Alex Hoppen
8fd025625b [SourceKit] Use NameMatcher that is rewritten in Swift for syntactic rename 2023-11-17 09:30:04 -08:00
Rintaro Ishizaki
47f18d492e [ASTGen] Move regex literal parsing from SwiftCompilerSources to ASTGen
ASTGen always builds with the host Swift compiler, without requiring
bootstrapping, and is enabled in more places. Move the regex literal
parsing logic there so it is enabled in more host environments, and
makes use of CMake's Swift support. Enable all of the regex literal
tests when ASTGen is built, to ensure everything is working.

Remove the "AST" and "Parse" Swift modules from SwiftCompilerSources,
because they are no longer needed.
2023-11-16 10:59:23 -08:00
Hamish Knight
32ee2ccf68 [ASTGen] Build with -disable-target-os-checking
Temporarily workaround an availability issue with
CxxStdlib.
2023-11-01 17:39:55 +00:00
Hamish Knight
3cb74e911b Address review feedback 2023-10-30 23:50:01 +00:00
Hamish Knight
e5442fea50 [ASTGen] Enable C++ interop 2023-10-30 23:49:52 +00:00
Hamish Knight
5d105f175d [ASTGen] NFC: Format with swift-format
This uses the same formatting configuration as
sourcekit-lsp.
2023-10-23 10:51:23 +01:00
Rintaro Ishizaki
3e9c2536f6 [Macros] Unify PluginMessages.swift
Use PluginMessages.swift in swift-syntax consistently.
2023-06-29 13:04:10 -07:00
Rintaro Ishizaki
5fe2ead4e2 [Madros] Update for SwiftSyntaxMacroExpansion module
Share the same expansion logic between ASTGen and
SwiftCompilerMessageHandling
2023-05-11 19:45:14 -07:00
Rintaro Ishizaki
c4b3edd6df [Macros] Add swift-plugin-server executable
This executable is intended to be installed in the toolchain and act as
an executable compiler plugin just like other 'macro' plugins.

This plugin server has an optional method 'loadPluginLibrary' that
dynamically loads dylib plugins.
The compiler has a newly added option '-external-plugin-path'. This
option receives a pair of the plugin library search path (just like
'-plugin-path') and the corresponding "plugin server" path, separated
by '#'. i.e.

  -external-plugin-path
    <plugin library search path>#<plugin server executable path>

For exmaple, when there's a macro decl:

  @freestanding(expression)
  macro stringify<T>(T) -> (T, String) =
      #externalMacro(module: "BasicMacro", type: "StringifyMacro")

The compiler look for 'libBasicMacro.dylib' in '-plugin-path' paths,
if not found, it falls back to '-external-plugin-path' and tries to find
'libBasicMacro.dylib' in them. If it's found, the "plugin server" path
is launched just like an executable plugin, then 'loadPluginLibrary'
method is invoked via IPC, which 'dlopen' the library path in the plugin
server. At the actual macro expansion, the mangled name for
'BasicMacro.StringifyMacro' is used to resolve the macro  just like
dylib plugins in the compiler.

This is useful for
 * Isolating the plugin process, so the plugin crashes doesn't result
   the compiler crash
 * Being able to use library plugins linked with other `swift-syntax`
   versions

rdar://105104850
2023-03-16 14:00:45 -07:00
Rintaro Ishizaki
9004fd24d4 [ASTGen] Separate JSON serialization module from ASTGen
For future usage from other host libraries written in Swift

For CMake:
 * Explicitly specify LINKER_LANGAGE to CXX in existing components so
   that 'swiftc' is not used when linking with 'swiftASTGen'
 * Add 'EMIT_MODULE' argument to 'add_pure_swift_host_library' to emit
   .swiftmodule usable from other Swift libraries.
2023-03-09 19:15:45 -08:00
Doug Gregor
027ce8d21c [ASTGen/Macros] Introduce a Swift-side SourceManager into ASTGen.
Add SourceManager that can keep track of multiple source file syntax
nodes along with their external representations. The source manager can
emit diagnostics into any of those files, including tracking any
explicitly "detached" syntax nodes used for macro expansion.

Make sure we detach syntax nodes before passing them to macro
implementations, so they cannot see more of the source file than they
are permitted. We hadn't been doing this before (by accident), and
doing so motivated the introduction of the SourceManager.

Additionally, perform operator folding on macro arguments as part of
detaching them. Macro clients shouldn't have to do this, and moreover,
when clients do this, they lose the ability to easily emit diagnostics
on the now-folded nodes.
2023-01-28 22:23:52 -08:00
Doug Gregor
182950bacb Update to account for SwiftSyntaxMacros module rename and overhaul 2023-01-28 09:00:54 -08:00
Richard Wei
1930f86a1a [Macros] Emit diagnostics from plugins
Make `_rewrite` return an buffer containing diagnostics and emit them.
2022-11-17 03:17:57 -08:00
zoecarver
61b160d288 [nfc] Run swift-format over Swift ASTGen sources. 2022-10-30 11:03:53 -07:00
Doug Gregor
636e6d1524 [Macros] "Expand" builtin macros for magic literals.
Introduce an experimental option `BuiltinMacros` that takes the magic
literals (`#file`, `#line`, `#function`, etc.) after type checking and
processes the original source for the expression using the build
syntactic macro system in the swift-syntax library. At present, the
result of expansion is printed to standard output, but it's enough to
verify that we're able to find the corresponding syntax node based on
the C++ AST.
2022-10-21 06:41:05 -07:00
Doug Gregor
5a0d775fa5 [ASTGen] Add a comment about the purporse of its Package.swift 2022-10-07 10:19:06 -07:00
Doug Gregor
8e6628616d Fix the package that builds swiftASTGen. 2022-10-07 10:19:06 -07:00
zoecarver
bed2742ba8 Make ASTGen a swift package
(cherry picked from commit 4e9e5fe6a8)
2022-10-07 10:19:05 -07:00