MobileNativeFoundation / swift-index-store

Library to read from Swift / clang source code indexes
Apache License 2.0
137 stars 11 forks source link

Swift 5.9 / Xcode 15 Warning: forming 'UnsafeMutableRawPointer' to a variable of type '[Type]' #47

Closed tinder-owenthomas closed 1 year ago

tinder-owenthomas commented 1 year ago

I'm working on getting ready for Xcode 15 and Swift 5.9 and seeing some warnings coming from IndexStore.swift.

Looks like these were added with this swift evolution proposal, in which they provide some #workarounds-for-common-cases

Here's the build warnings we're seeing:

INFO: From Compiling Swift module @com_github_lyft_swift_index_store//:IndexStore:
external/com_github_lyft_swift_index_store/Sources/IndexStore/IndexStore.swift:49:67: warning: forming 'UnsafeMutableRawPointer' to a variable of type '(String) -> ()'; this is likely incorrect because '(String) -> ()' may contain an object reference.
        indexstore_store_units_apply_f(self.store, /*unsorted*/0, &context) { context, unitName in
                                                                  ^
external/com_github_lyft_swift_index_store/Sources/IndexStore/IndexStore.swift:173:66: warning: forming 'UnsafeMutableRawPointer' to a variable of type '(UnitReader, (UnitDependency) -> ())'; this is likely incorrect because '(UnitReader, (UnitDependency) -> ())' may contain an object reference.
        indexstore_unit_reader_dependencies_apply_f(self.reader, &context) { context, unitDependency in
                                                                 ^
external/com_github_lyft_swift_index_store/Sources/IndexStore/IndexStore.swift:229:80: warning: forming 'UnsafeMutableRawPointer' to a variable of type '(RecordReader, (Symbol) -> ())'; this is likely incorrect because '(RecordReader, (Symbol) -> ())' may contain an object reference.
        indexstore_record_reader_symbols_apply_f(self.reader, /*nocache*/true, &context) { context, symbol in
                                                                               ^
external/com_github_lyft_swift_index_store/Sources/IndexStore/IndexStore.swift:242:67: warning: forming 'UnsafeMutableRawPointer' to a variable of type '(RecordReader, (SymbolOccurrence) -> ())'; this is likely incorrect because '(RecordReader, (SymbolOccurrence) -> ())' may contain an object reference.
        indexstore_record_reader_occurrences_apply_f(self.reader, &context) { context, occurrence in
                                                                  ^
external/com_github_lyft_swift_index_store/Sources/IndexStore/IndexStore.swift:278:66: warning: forming 'UnsafeMutableRawPointer' to a variable of type '(SymbolOccurrence, (Symbol, SymbolRoles) -> ())'; this is likely incorrect because '(SymbolOccurrence, (Symbol, SymbolRoles) -> ())' may contain an object reference.
        indexstore_occurrence_relations_apply_f(self.occurrence, &context) { context, relation in
                                                                 ^
keith commented 1 year ago

can you test with this branch https://github.com/lyft/swift-index-store/pull/45

keith commented 1 year ago

but yea i hadn't seen that proposal until after I did that so maybe we can simplify by using withUnsafePointer

keith commented 1 year ago

Here's another take doing that https://github.com/lyft/swift-index-store/pull/48

tinder-owenthomas commented 1 year ago

Sorry, haven't looked at this in a long time since the issue seemed to go away a while ago. Since #48 has been merged though I'm guessing we can close this out? I'll go ahead and do so in a few days (or next time I remember to look at it) if no one objects. Or feel free to close it out for me if you believe it is done!

keith commented 1 year ago

ah yes thanks! lmk if you hit any issues!