@@ -98,11 +98,15 @@ abstract class TranslatedCoreExpr extends TranslatedExpr {
9898 * All exprs produce a final value, apart from reads. They first need an access,
9999 * then a load.
100100 */
101+ // TODO: When the compatibility layer is in place,
102+ // create a special class for the following cases
101103 override final predicate producesExprResult ( ) {
102- // TODO: When the compatibility layer is in place,
103- // create a special class for the following cases
104104 not ( expr instanceof AssignableRead ) or
105- expr .getParent ( ) instanceof ArrayAccess
105+ expr .getParent ( ) instanceof ArrayAccess or
106+ // TODO: Make sure this is enough
107+ // Ref types need no loads
108+ // Eg. `Object obj = oldObj`;
109+ expr .getType ( ) instanceof RefType
106110 }
107111
108112 /**
@@ -976,10 +980,13 @@ abstract class TranslatedVariableAccess extends TranslatedNonConstantExpr {
976980
977981class TranslatedNonFieldVariableAccess extends TranslatedVariableAccess {
978982 TranslatedNonFieldVariableAccess ( ) {
979- // TODO: Make sure those are enough and correct
980983 not expr instanceof FieldAccess and
981- // Init should take care of this access (check with cpp)
982- ( not expr .getParent ( ) instanceof LocalVariableDeclAndInitExpr )
984+ // If the parent expression is a declaration + initialization
985+ // expr, then translate only the variables that are initializers (on the RHS)
986+ // and not the LHS (the address of the LHS is generated during
987+ // the translation of the initialization
988+ ( expr .getParent ( ) instanceof LocalVariableDeclAndInitExpr implies
989+ expr = expr .getParent ( ) .( LocalVariableDeclAndInitExpr ) .getInitializer ( ) )
983990 }
984991
985992 override Instruction getFirstInstruction ( ) {
0 commit comments