@@ -423,6 +423,15 @@ predicate simpleLocalFlowStep(Node nodeFrom, Node nodeTo) {
423423 simpleInstructionLocalFlowStep ( nodeFrom .asInstruction ( ) , nodeTo .asInstruction ( ) )
424424}
425425
426+ pragma [ noinline]
427+ private predicate getFieldSizeOfClass ( Class c , Type type , int size ) {
428+ exists ( Field f |
429+ f .getDeclaringType ( ) = c and
430+ f .getType ( ) = type and
431+ type .getSize ( ) = size
432+ )
433+ }
434+
426435cached
427436private predicate simpleInstructionLocalFlowStep ( Instruction iFrom , Instruction iTo ) {
428437 iTo .( CopyInstruction ) .getSourceValue ( ) = iFrom
@@ -472,12 +481,11 @@ private predicate simpleInstructionLocalFlowStep(Instruction iFrom, Instruction
472481 )
473482 or
474483 // Flow from stores to structs with a single field to a load of that field.
475- iTo .( LoadInstruction ) .getSourceValueOperand ( ) .getAnyDef ( ) = iFrom .( StoreInstruction ) and
476- exists ( Class c , Type t |
477- c = iTo .getResultType ( ) and
478- t = iFrom .getResultType ( ) and
479- c .getAField ( ) .getUnspecifiedType ( ) = t and
480- c .getSize ( ) = t .getSize ( )
484+ iTo .( LoadInstruction ) .getSourceValueOperand ( ) .getAnyDef ( ) = iFrom and
485+ exists ( int size , Type type |
486+ type = iFrom .getResultType ( ) and
487+ iTo .getResultType ( ) .getSize ( ) = size and
488+ getFieldSizeOfClass ( iTo .getResultType ( ) , type , size )
481489 )
482490 or
483491 // Flow through modeled functions
0 commit comments