Swift: Model withUnsafeBytes and similar closure methods #13827
+222
−18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(draft PR because this is currently sitting atop an early version of #13741 that is necessary to get some of the results; please ignore those commits, they will be rebased away once that PR is merged)
Model
withUnsafeBytesand some similar closure methods.Limitations:
.ArrayContentto access content when we know theCollectionis anArray. I've used two models - one with.ArrayContentand one with no content specifier - when the object could be anArrayor another type ofCollection. I've used no content specifier for pointers (UnsafePointeretc) since we don't have content for any of those (yet). Thus, some level of conflation (e.g. betweenptrandptr[0]) is inevitable at this stage. We should be able to improve accuracy as we implement further types of content flow..baseAddress) are not yet modelled. There is an in-progress issue for these.int.swiftline 19. It works if the qualifier is a tainted array, but not if it's an array with tainted content as in the test (despite there being models for both cases).TODO:
maywill also benefit from 098db58 (for missing test results such asint.swiftline 19)