[Macros] Type check user-defined macro plugins (#61861)

Type check user-defined macros plugins with user-provided type signatures.

Also, load plugin libraries with `RTLD_LOCAL` instead of `RTLD_GLOBAL` to prevent symbol collision between plugins. `llvm::sys::DynamicLibrary` only supports `RTLD_GLOBAL` so we use the plain `dlopen` instead. This does not work on Windows and needs to be fixed.

Friend PR: apple/swift-syntax#1042
This commit is contained in:
Richard Wei
2022-11-02 18:22:31 -07:00
committed by GitHub
parent d898e04575
commit d059735260
12 changed files with 213 additions and 63 deletions

View File

@@ -57,4 +57,16 @@ public protocol _CompilerPlugin {
localSourceText: UnsafePointer<UInt8>,
localSourceTextCount: Int
) -> (UnsafePointer<UInt8>?, count: Int)
/// Returns the generic signature of the plugin.
///
/// - Returns: A newly allocated buffer containing the generic signature.
/// The caller is responsible for managing the memory.
static func _genericSignature() -> (UnsafePointer<UInt8>?, count: Int)
/// Returns the type signature of the plugin.
///
/// - Returns: A newly allocated buffer containing the type signature. The
/// caller is responsible for managing the memory.
static func _typeSignature() -> (UnsafePointer<UInt8>, count: Int)
}