Skip to content

[SwiftCompilerSources] NFC: Renamed two helper fns #69069

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

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions SwiftCompilerSources/Sources/Optimizer/Utilities/Test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public func registerOptimizerTests() {

private func registerFunctionTest(_ test: FunctionTest) {
test.name._withBridgedStringRef { ref in
registerFunctionTest(ref, eraseInvocation(test.invocation))
registerFunctionTest(ref, castToOpaquePointer(fromInvocation: test.invocation))
}
}

Expand All @@ -161,7 +161,7 @@ private func functionTestThunk(
_ function: BridgedFunction,
_ arguments: BridgedTestArguments,
_ passInvocation: BridgedSwiftPassInvocation) {
let invocation = uneraseInvocation(erasedInvocation)
let invocation = castToInvocation(fromOpaquePointer: erasedInvocation)
let context = FunctionPassContext(_bridged: BridgedPassContext(invocation: passInvocation.invocation))
invocation(function.function, arguments.native, context)
}
Expand All @@ -170,15 +170,15 @@ private func functionTestThunk(
///
/// Needed so that the closure can be represented in C++ for storage in the test
/// registry.
private func eraseInvocation(_ invocation: FunctionTestInvocation) -> UnsafeMutableRawPointer {
private func castToOpaquePointer(fromInvocation invocation: FunctionTestInvocation) -> UnsafeMutableRawPointer {
return unsafeBitCast(invocation, to: UnsafeMutableRawPointer.self)
}

/// Bitcast a void * to a thin test closure.
///
/// Needed so that the closure stored in the C++ test registry can be invoked
/// via the functionTestThunk.
private func uneraseInvocation(_ erasedInvocation: UnsafeMutableRawPointer) -> FunctionTestInvocation {
private func castToInvocation(fromOpaquePointer erasedInvocation: UnsafeMutableRawPointer) -> FunctionTestInvocation {
return unsafeBitCast(erasedInvocation, to: FunctionTestInvocation.self)
}

Expand Down