@@ -185,54 +185,15 @@ class OperandNode extends Node, TOperandNode {
185185 override string toString ( ) { result = this .getOperand ( ) .toString ( ) }
186186}
187187
188- /** An abstract class that defines conversion-like instructions. */
189- abstract private class SkippableInstruction extends Instruction {
190- abstract Instruction getSourceInstruction ( ) ;
191- }
192-
193- /**
194- * Gets the instruction that is propaged through a non-empty sequence of conversion-like instructions.
195- */
196- private Instruction skipSkippableInstructionsRec ( SkippableInstruction skip ) {
197- result = skip .getSourceInstruction ( ) and not result instanceof SkippableInstruction
198- or
199- result = skipSkippableInstructionsRec ( skip .getSourceInstruction ( ) )
200- }
201-
202- /**
203- * Gets the instruction that is propagated through a (possibly empty) sequence of conversion-like
204- * instructions.
205- */
206- private Instruction skipSkippableInstructions ( Instruction instr ) {
207- result = instr and not result instanceof SkippableInstruction
208- or
209- result = skipSkippableInstructionsRec ( instr )
210- }
211-
212- private class SkippableCopyValueInstruction extends SkippableInstruction , CopyValueInstruction {
213- override Instruction getSourceInstruction ( ) { result = this .getSourceValue ( ) }
214- }
215-
216- private class SkippableConvertInstruction extends SkippableInstruction , ConvertInstruction {
217- override Instruction getSourceInstruction ( ) { result = this .getUnary ( ) }
218- }
219-
220- private class SkippableCheckedConvertInstruction extends SkippableInstruction ,
221- CheckedConvertOrNullInstruction {
222- override Instruction getSourceInstruction ( ) { result = this .getUnary ( ) }
223- }
224-
225- private class SkippableInheritanceConversionInstruction extends SkippableInstruction ,
226- InheritanceConversionInstruction {
227- override Instruction getSourceInstruction ( ) { result = this .getUnary ( ) }
228- }
229-
230188/**
231189 * INTERNAL: do not use. Gets the `FieldNode` corresponding to `instr`, if
232190 * `instr` is an instruction that propagates an address of a `FieldAddressInstruction`.
233191 */
234192FieldNode getFieldNodeForFieldInstruction ( Instruction instr ) {
235- result .getFieldInstruction ( ) = skipSkippableInstructions ( instr )
193+ result .getFieldInstruction ( ) =
194+ any ( FieldAddressInstruction fai |
195+ instructionOperandLocalFlowStep * ( instructionNode ( fai ) , instructionNode ( instr ) )
196+ )
236197}
237198
238199/**
@@ -651,6 +612,11 @@ class VariableNode extends Node, TVariableNode {
651612 */
652613InstructionNode instructionNode ( Instruction instr ) { result .getInstruction ( ) = instr }
653614
615+ /**
616+ * Gets the node corresponding to `operand`.
617+ */
618+ OperandNode operandNode ( Operand operand ) { result .getOperand ( ) = operand }
619+
654620/**
655621 * DEPRECATED: use `definitionByReferenceNodeFromArgument` instead.
656622 *
@@ -770,17 +736,26 @@ private predicate flowIntoReadNode(Node nodeFrom, FieldNode nodeTo) {
770736
771737/**
772738 * INTERNAL: do not use.
773- *
774- * This is the local flow predicate that's used as a building block in global
775- * data flow. It may have less flow than the `localFlowStep` predicate.
739+ * Holds if `nodeFrom` is an operand and `nodeTo` is an instruction node that uses this operand, or
740+ * if `nodeFrom` is an instruction and `nodeTo` is an operand that refers to this instruction.
776741 */
777- cached
778- predicate simpleLocalFlowStep ( Node nodeFrom , Node nodeTo ) {
742+ predicate instructionOperandLocalFlowStep ( Node nodeFrom , Node nodeTo ) {
779743 // Operand -> Instruction flow
780744 simpleInstructionLocalFlowStep ( nodeFrom .asOperand ( ) , nodeTo .asInstruction ( ) )
781745 or
782746 // Instruction -> Operand flow
783747 simpleOperandLocalFlowStep ( nodeFrom .asInstruction ( ) , nodeTo .asOperand ( ) )
748+ }
749+
750+ /**
751+ * INTERNAL: do not use.
752+ *
753+ * This is the local flow predicate that's used as a building block in global
754+ * data flow. It may have less flow than the `localFlowStep` predicate.
755+ */
756+ cached
757+ predicate simpleLocalFlowStep ( Node nodeFrom , Node nodeTo ) {
758+ instructionOperandLocalFlowStep ( nodeFrom , nodeTo )
784759 or
785760 flowIntoReadNode ( nodeFrom , nodeTo )
786761 or
0 commit comments