mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Migrate from UnsafePointer<Void> to UnsafeRawPointer. (#3724)
* Migrate from `UnsafePointer<Void>` to `UnsafeRawPointer`. As proposed in SE-0107: UnsafeRawPointer. `void*` imports as `UnsafeMutableRawPointer`. `const void*` imports as `UnsafeRawPointer`. Occurrences of `UnsafePointer<Void>` are replaced with UnsafeRawPointer. * Migrate overlays from UnsafePointer<Void> to UnsafeRawPointer. This requires explicit memory binding in several places, particularly in NSData and CoreAudio. * Fix a bunch of test cases for Void->Raw migration. * qsort takes IUO values * Bridge `Unsafe[Mutable]RawPointer as `void [const] *`. * Parse #dsohandle as UnsafeMutableRawPointer * Update a bunch of test cases for Void->Raw migration. * Trivial fix for the SceneKit test case. * Add an UnsafeRawPointer self initializer. This is unfortunately necessary for assignment between types imported from C. * Tiny simplification of the initializer.
This commit is contained in:
@@ -371,23 +371,16 @@ VarDecl *Module::getDSOHandle() {
|
||||
if (DSOHandle)
|
||||
return DSOHandle;
|
||||
|
||||
auto unsafeMutablePtr = getASTContext().getUnsafeMutablePointerDecl();
|
||||
if (!unsafeMutablePtr)
|
||||
auto unsafeMutableRawPtr = getASTContext().getUnsafeMutableRawPointerDecl();
|
||||
if (!unsafeMutableRawPtr)
|
||||
return nullptr;
|
||||
|
||||
Type arg;
|
||||
auto &ctx = getASTContext();
|
||||
if (auto voidDecl = ctx.getVoidDecl()) {
|
||||
arg = voidDecl->getDeclaredInterfaceType();
|
||||
} else {
|
||||
arg = TupleType::getEmpty(ctx);
|
||||
}
|
||||
|
||||
Type type = BoundGenericType::get(unsafeMutablePtr, Type(), { arg });
|
||||
auto handleVar = new (ctx) VarDecl(/*IsStatic=*/false, /*IsLet=*/false,
|
||||
SourceLoc(),
|
||||
ctx.getIdentifier("__dso_handle"),
|
||||
type, Files[0]);
|
||||
unsafeMutableRawPtr->getDeclaredType(),
|
||||
Files[0]);
|
||||
handleVar->setImplicit(true);
|
||||
handleVar->getAttrs().add(
|
||||
new (ctx) SILGenNameAttr("__dso_handle", /*Implicit=*/true));
|
||||
|
||||
Reference in New Issue
Block a user