Skip to content

Commit 9235e41

Browse files
authored
Merge pull request #73458 from rintaro/6.0-macros-library-provider
[6.0] Macro plugin related changes
2 parents cb2051b + 13a3af1 commit 9235e41

File tree

12 files changed

+14
-1381
lines changed

12 files changed

+14
-1381
lines changed

lib/ASTGen/CMakeLists.txt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
add_pure_swift_host_library(swiftLLVMJSON STATIC EMIT_MODULE
2-
Sources/LLVMJSON/LLVMJSON.swift
3-
4-
DEPENDENCIES
5-
swiftBasic
6-
)
7-
81
set(ASTGen_Swift_dependencies)
92

103
# If requested, build the regular expression parser into the compiler itself.
@@ -61,7 +54,6 @@ add_pure_swift_host_library(swiftASTGen STATIC
6154
SwiftSyntaxBuilder
6255
SwiftSyntaxMacros
6356
SwiftSyntaxMacroExpansion
64-
swiftLLVMJSON
6557
${ASTGen_Swift_dependencies}
6658
)
6759

@@ -116,7 +108,7 @@ else()
116108
endif()
117109

118110
if(SWIFT_BUILD_SWIFT_SYNTAX)
119-
foreach(target swiftASTGen swiftLLVMJSON swiftIDEUtilsBridging)
111+
foreach(target swiftASTGen swiftIDEUtilsBridging)
120112
target_compile_options(${target} PRIVATE ${compile_options})
121113
endforeach()
122114
endif()

lib/ASTGen/Package.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ let package = Package(
4444
],
4545
products: [
4646
.library(name: "swiftASTGen", targets: ["swiftASTGen"]),
47-
.library(name: "swiftLLVMJSON", targets: ["swiftLLVMJSON"]),
4847
],
4948
dependencies: [
5049
.package(path: "../../../swift-syntax")
@@ -63,7 +62,6 @@ let package = Package(
6362
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
6463
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
6564
.product(name: "SwiftSyntaxMacroExpansion", package: "swift-syntax"),
66-
"swiftLLVMJSON",
6765
"_CompilerRegexParser",
6866
],
6967
path: "Sources/ASTGen",
@@ -79,12 +77,6 @@ let package = Package(
7977
path: "Sources/SwiftIDEUtilsBridging",
8078
swiftSettings: swiftSetttings
8179
),
82-
.target(
83-
name: "swiftLLVMJSON",
84-
dependencies: [],
85-
path: "Sources/LLVMJSON",
86-
swiftSettings: swiftSetttings
87-
),
8880
.target(
8981
name: "_CompilerRegexParser",
9082
dependencies: [],

lib/ASTGen/Sources/ASTGen/PluginHost.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import ASTBridging
1414
import BasicBridging
1515
@_spi(PluginMessage) import SwiftCompilerPluginMessageHandling
1616
import SwiftSyntax
17-
import swiftLLVMJSON
1817

1918
enum PluginError: String, Error, CustomStringConvertible {
2019
case stalePlugin = "plugin is stale"
@@ -117,7 +116,7 @@ struct CompilerPlugin {
117116
}
118117

119118
private func sendMessage(_ message: HostToPluginMessage) throws {
120-
let hadError = try LLVMJSON.encoding(message) { (data) -> Bool in
119+
let hadError = try JSON.encode(message).withUnsafeBufferPointer { (data) -> Bool in
121120
return Plugin_sendMessage(opaqueHandle, BridgedData(baseAddress: data.baseAddress, count: data.count))
122121
}
123122
if hadError {
@@ -133,7 +132,9 @@ struct CompilerPlugin {
133132
throw PluginError.failedToReceiveMessage
134133
}
135134
let data = UnsafeBufferPointer(start: result.baseAddress, count: result.count)
136-
return try LLVMJSON.decode(PluginToHostMessage.self, from: data)
135+
return try data.withMemoryRebound(to: UInt8.self) { buffer in
136+
try JSON.decode(PluginToHostMessage.self, from: buffer)
137+
}
137138
}
138139

139140
func sendMessageAndWaitWithoutLock(_ message: HostToPluginMessage) throws -> PluginToHostMessage {

0 commit comments

Comments
 (0)