DataFlow: Add language-specific predicate for ignoring steps in flow-through calculation #14799
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.
TLDR
This PR adds a language-level hook for excluding steps from the flow-through calculation. It's a no-op PR for all other languages than C/C++.
Slightly longer explanation
We have a well-known source of FPs in C/C++ caused by the following pattern:
This happens because we model each indirection of a parameter as a separate SSA variable, so dataflow really sees the above program as
and in the above program it's easy to see that there's a
ReturnNodeExt
generated that updates the parameterderef_p
inmodify_copy
.The problem is the SSA step generated by
int x = *p;
which should be treated special when generating flow-throughs since a subsequent update ofx
should not affect*p
(which is currently what the flow-through summaries give us).@aschackmull I'd like to hear if you have any problems with 748625c? I hope it's not controversial since:
DCA looks good. I've verified that all the removed results are instances of the
test_modify_copy_of_pointer
testcase.