@@ -185,54 +185,66 @@ 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-
193188/**
194- * Gets the instruction that is propaged through a non-empty sequence of conversion-like instructions.
189+ * INTERNAL: do not use. Encapsulates the details of getting a `FieldNode` from
190+ * an `Instruction` or an `Operand`.
195191 */
196- private Instruction skipSkippableInstructionsRec ( SkippableInstruction skip ) {
197- result = skip . getSourceInstruction ( ) and not result instanceof SkippableInstruction
198- or
199- result = skipSkippableInstructionsRec ( skip . getSourceInstruction ( ) )
200- }
192+ module GetFieldNode {
193+ /** An abstract class that defines conversion-like instructions. */
194+ abstract private class SkippableInstruction extends Instruction {
195+ abstract Instruction getSourceInstruction ( ) ;
196+ }
201197
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- }
198+ /**
199+ * Gets the instruction that is propaged through a non-empty sequence of conversion-like instructions.
200+ */
201+ private Instruction skipSkippableInstructionsRec ( SkippableInstruction skip ) {
202+ result = skip .getSourceInstruction ( ) and not result instanceof SkippableInstruction
203+ or
204+ result = skipSkippableInstructionsRec ( skip .getSourceInstruction ( ) )
205+ }
211206
212- private class SkippableCopyValueInstruction extends SkippableInstruction , CopyValueInstruction {
213- override Instruction getSourceInstruction ( ) { result = this .getSourceValue ( ) }
214- }
207+ /**
208+ * Gets the instruction that is propagated through a (possibly empty) sequence of conversion-like
209+ * instructions.
210+ */
211+ private Instruction skipSkippableInstructions ( Instruction instr ) {
212+ result = instr and not result instanceof SkippableInstruction
213+ or
214+ result = skipSkippableInstructionsRec ( instr )
215+ }
215216
216- private class SkippableConvertInstruction extends SkippableInstruction , ConvertInstruction {
217- override Instruction getSourceInstruction ( ) { result = this .getUnary ( ) }
218- }
217+ private class SkippableCopyValueInstruction extends SkippableInstruction , CopyValueInstruction {
218+ override Instruction getSourceInstruction ( ) { result = this .getSourceValue ( ) }
219+ }
219220
220- private class SkippableCheckedConvertInstruction extends SkippableInstruction ,
221- CheckedConvertOrNullInstruction {
222- override Instruction getSourceInstruction ( ) { result = this .getUnary ( ) }
223- }
221+ private class SkippableConvertInstruction extends SkippableInstruction , ConvertInstruction {
222+ override Instruction getSourceInstruction ( ) { result = this .getUnary ( ) }
223+ }
224224
225- private class SkippableInheritanceConversionInstruction extends SkippableInstruction ,
226- InheritanceConversionInstruction {
227- override Instruction getSourceInstruction ( ) { result = this .getUnary ( ) }
228- }
225+ private class SkippableCheckedConvertInstruction extends SkippableInstruction ,
226+ CheckedConvertOrNullInstruction {
227+ override Instruction getSourceInstruction ( ) { result = this .getUnary ( ) }
228+ }
229229
230- /**
231- * INTERNAL: do not use. Gets the `FieldNode` corresponding to `instr`, if
232- * `instr` is an instruction that propagates an address of a `FieldAddressInstruction`.
233- */
234- FieldNode getFieldNodeForFieldInstruction ( Instruction instr ) {
235- result .getFieldInstruction ( ) = skipSkippableInstructions ( instr )
230+ private class SkippableInheritanceConversionInstruction extends SkippableInstruction ,
231+ InheritanceConversionInstruction {
232+ override Instruction getSourceInstruction ( ) { result = this .getUnary ( ) }
233+ }
234+
235+ /**
236+ * INTERNAL: do not use. Gets the `FieldNode` corresponding to `instr`, if
237+ * `instr` is an instruction that propagates an address of a `FieldAddressInstruction`.
238+ */
239+ FieldNode fromInstruction ( Instruction instr ) {
240+ result .getFieldInstruction ( ) = skipSkippableInstructions ( instr )
241+ }
242+
243+ /**
244+ * INTERNAL: do not use. Gets the `FieldNode` corresponding to `op`, if the definition
245+ * of `op` is an instruction that propagates an address of a `FieldAddressInstruction`.
246+ */
247+ FieldNode fromOperand ( Operand op ) { result = fromInstruction ( op .getDef ( ) ) }
236248}
237249
238250/**
@@ -265,7 +277,7 @@ class FieldNode extends Node, TFieldNode {
265277 * gives the `FieldNode` of `b`, and `f.getObjectNode().getObjectNode()` has no result as `a` is
266278 * not a field.
267279 */
268- FieldNode getObjectNode ( ) { result = getFieldNodeForFieldInstruction ( field .getObjectAddress ( ) ) }
280+ FieldNode getObjectNode ( ) { result = GetFieldNode :: fromInstruction ( field .getObjectAddress ( ) ) }
269281
270282 /**
271283 * Gets the `FieldNode` that has this `FieldNode` as parent, if any.
@@ -683,7 +695,7 @@ private predicate flowOutOfPostUpdate(PartialDefinitionNode nodeFrom, Node nodeT
683695 exists ( AddressOperand addressOperand , PartialFieldDefinition pd |
684696 pd = nodeFrom .getPartialDefinition ( ) and
685697 not exists ( pd .getPreUpdateNode ( ) .getObjectNode ( ) ) and
686- pd .getPreUpdateNode ( ) .getNextNode * ( ) = getFieldNodeForFieldInstruction ( addressOperand . getDef ( ) ) and
698+ pd .getPreUpdateNode ( ) .getNextNode * ( ) = GetFieldNode :: fromOperand ( addressOperand ) and
687699 (
688700 exists ( ChiInstruction chi |
689701 nodeTo .asInstruction ( ) = chi and
@@ -711,7 +723,7 @@ private predicate flowOutOfPostUpdate(PartialDefinitionNode nodeFrom, Node nodeT
711723 */
712724private FieldNode getOutermostFieldNode ( Instruction address ) {
713725 not exists ( result .getObjectNode ( ) ) and
714- result .getNextNode * ( ) = getFieldNodeForFieldInstruction ( address )
726+ result .getNextNode * ( ) = GetFieldNode :: fromInstruction ( address )
715727}
716728
717729private predicate flowIntoReadNode ( Node nodeFrom , FieldNode nodeTo ) {
0 commit comments