Swift: Update the inline dataflow tests #14761
Merged
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.
Update all the inline dataflow tests to:
InlineFlowTest.qll
library added by @MathiasVP in Swift: Add variable-capture flow #14577 . Until now this was only used in thedataflow/capture
test. This change reduces code duplication as much of the code is very similar between the different tests.Source labels are a feature where we can label sources explicitly with a string in tests, rather than using their line number to identify them. This makes maintaining tests a lot less painful when line numbers inevitably change.
I wanted this change to be fully backwards compatible as far as the existing test cases were concerned (i.e. the existing
.swift
code with line numbers as labels). Not only does that make this PR smaller, is makes it much less likely to conflict with other changes to the tests are are going on continuously. I had to add a couple of compatibility features toInlineFlowTest.qll
to accomplish this - in particular, custom inline tags (such astainted=
), and using line numbers as a fallback source label (rather than""
). We lose the (unused) ability to have unlabelled sources.I've updated a minority of test cases to use source labels, as a proof of concept. We can gradually migrate the rest as and when we need to (i.e. when we would otherwise have to renumber them).