C++: Map some indirect nodes to expressions in localExprFlowStep
#12507
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.
This PR supersede #12477 and (hopefully) contains the correct performance fix.
On certain projects containing heavily macro-expanded code like:
we hit a performance problem caused by each expression of the form
x[i]
being stepped to from*x = source()
in certain cases in the expression-only local flow relation.To see why this is the case, consider the transitive closure over
localStepFromNonExpr
inlocalStepsToExpr
. We start atn2
for whichn.asExpr()
exists. For example,n2
in the above example could bex[i]
in any of theuse(x[i])
above. We then step to a dataflow predecessor ofn2
. In the above code fragment, thats the indirect node corresponding tox
inx[i-1]
. Since this doesn't have a result forNode::asExpr()
we continue with the recursion until we reach*x = source()
which does have a result forNode::asExpr()
.If
N
is very large this blows up.This PR fixes this problem by mapping those indirect nodes for
x
inx[i]
to thex[i]
expression. Ideally, this would be handled automatically by assigning the dataflow node for the indirection ofx
to the same dataflow node asx[i]
, but doing this in the past has let to some strange conflations. However, by just doing this in the expression-only local flow relation we're not seeing these strange conflations.