C++: Fix more pointer/pointee conflation #13246
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.
When we have IR like:
we reuse the dataflow node for
r2to represent the dataflow node for the indirection node ofr1with indirection index 1 (i.e., the node that represents the value you get from dereferencingr1once).This is implemented by this disjunct in the charpred for
IndirectOperandonmain:That is,
thisis used to represent the dataflow node for the indirect operand whose underlying operand isoperandand whose indirection index isindirectionIndex. However, this line is only correct whenindirectionIndexis 1 (because in that case the IR may have an instruction that can represent the value). If the indirection index is greater than 1, noLoadInstructionwill be able to represent the dataflow node. This wasn't handled in the above disjunct, and we'd simply use the IR instruction to represent the dataflow node irregardless of the indirection index. This meant that an indirect dataflow node was being represented by an IR instruction, and meant that we got pointer/pointee conflation.This PR fixes the conflation by using the
nodeHasInstructioninstruction in the above disjunction, which means that we correctly pick an IR instruction node if the indirection index is right, and otherwise we pick an indirect node.