diff --git a/src/main/java/br/unb/cic/analysis/df/OverridingAssignmentAnalysis.java b/src/main/java/br/unb/cic/analysis/df/OverridingAssignmentAnalysis.java index 90e944b7..8529c2d9 100644 --- a/src/main/java/br/unb/cic/analysis/df/OverridingAssignmentAnalysis.java +++ b/src/main/java/br/unb/cic/analysis/df/OverridingAssignmentAnalysis.java @@ -4,10 +4,9 @@ import br.unb.cic.analysis.model.Conflict; import br.unb.cic.analysis.model.Statement; import soot.*; +import soot.jimple.ArrayRef; import soot.jimple.InstanceFieldRef; import soot.jimple.StaticFieldRef; -import soot.jimple.internal.JArrayRef; -import soot.jimple.internal.JInstanceFieldRef; import soot.toolkits.scalar.ArraySparseSet; import soot.toolkits.scalar.FlowSet; @@ -80,13 +79,13 @@ protected FlowSet gen(Unit u, FlowSet if (isLeftStatement(u) || isRightStatement(u)) { Statement stmt = getStatementAssociatedWithUnit(u); u.getDefBoxes().forEach(valueBox -> { - if (valueBox.getValue() instanceof Local){ + if (valueBox.getValue() instanceof Local) { res.add(new DataFlowAbstraction((Local) valueBox.getValue(), stmt)); - } else if (valueBox.getValue() instanceof JArrayRef){ + } else if (valueBox.getValue() instanceof ArrayRef) { res.add(new DataFlowAbstraction(getArrayName(valueBox), stmt)); - } else if (valueBox.getValue() instanceof StaticFieldRef) { + } else if (valueBox.getValue() instanceof StaticFieldRef) { res.add(new DataFlowAbstraction((StaticFieldRef) valueBox.getValue(), stmt)); - } else if (valueBox.getValue() instanceof JInstanceFieldRef){ + } else if (valueBox.getValue() instanceof InstanceFieldRef) { res.add(new DataFlowAbstraction(getFieldName(valueBox), stmt)); } }); @@ -139,11 +138,11 @@ private void checkConflicts(Unit u, List potentialConflicti private boolean abstractionVariableIsInIUnitDefBoxes(DataFlowAbstraction dataFlowAbstraction, Unit u) { for (ValueBox valueBox : u.getDefBoxes()) { Object value = valueBox.getValue(); - if (value instanceof JInstanceFieldRef && dataFlowAbstraction.getFieldRef()!=null) { + if (value instanceof InstanceFieldRef && dataFlowAbstraction.getFieldRef() != null) { return dataFlowAbstraction.getFieldRef().toString().equals(getFieldsChain(value.toString())); - } else if (value instanceof JArrayRef && value.toString().contains("$stack")) { // If contain $stack, contain a array chain + } else if (value instanceof ArrayRef && value.toString().contains("$stack")) { // If contain $stack, contain a array chain return getVarNameFromAbstraction(dataFlowAbstraction).equals(getArrayChain(valueBox)); - } else{ + } else { return getVarNameFromAbstraction(dataFlowAbstraction).equals(getVarNameFromValueBox(valueBox)); } } @@ -174,8 +173,8 @@ private String getVarNameFromValueBox(ValueBox valueBox) { varNameValueBox = getLocalName((Local) valueBox.getValue()); } else if (valueBox.getValue() instanceof StaticFieldRef) { varNameValueBox = getStaticName((StaticFieldRef) valueBox.getValue()); - } else if (valueBox.getValue() instanceof JArrayRef) { - varNameValueBox = getArrayRefName((JArrayRef) valueBox.getValue()).toString(); + } else if (valueBox.getValue() instanceof ArrayRef) { + varNameValueBox = getArrayRefName((ArrayRef) valueBox.getValue()).toString(); } return varNameValueBox; } @@ -206,7 +205,7 @@ private String getLocalName(Local local) { * of the variable used to assign an array; * e.g: int[] arr = {0, 1}; --> "arr" */ - private Value getArrayRefName(JArrayRef arrayRef) { + private Value getArrayRefName(ArrayRef arrayRef) { return arrayRef.getBaseBox().getValue(); } @@ -227,7 +226,7 @@ private InstanceFieldRef getFieldName(ValueBox valueBox) { * Else, returns the Array Name */ private Local getArrayName(ValueBox valueBox){ - Local localName = (Local) getArrayRefName((JArrayRef) valueBox.getValue()); + Local localName = (Local) getArrayRefName((ArrayRef) valueBox.getValue()); if (localName.toString().contains("$stack")) { localName.setName(getArrayChain(valueBox)); } @@ -244,7 +243,7 @@ private String getStaticName(StaticFieldRef staticField) { } /* - * Returns the name of the JArrayRef + * Returns the name of the ArrayRef * The Jimple code is divided in others units * Example: * static int[] y; @@ -259,7 +258,7 @@ private String getStaticName(StaticFieldRef staticField) { * $stack2[0] -> $stack2 = -> (STOP) -> Result: */ private String getArrayChain(ValueBox valueBox){ - String nextKey = ((JArrayRef) valueBox.getValue()).getBase().toString(); + String nextKey = ((ArrayRef) valueBox.getValue()).getBase().toString(); for (HashMap auxMap : getHashMapStatic()) { for (String mapKey : auxMap.keySet()) { if (mapKey.equals(nextKey)) { @@ -366,7 +365,7 @@ private void generateStaticRefDictionary(Unit u, ValueBox valueBox){ } /* - * Generates a dictionary to JInstanceFieldRef + * Generates a dictionary to InstanceFieldRef */ private void generateClassFieldDictionary(Statement stmt){ HashMap auxHashMap = new HashMap<>(); diff --git a/src/main/java/br/unb/cic/analysis/df/ReachDefinitionAnalysis.java b/src/main/java/br/unb/cic/analysis/df/ReachDefinitionAnalysis.java index 105cfb75..18e4dd39 100644 --- a/src/main/java/br/unb/cic/analysis/df/ReachDefinitionAnalysis.java +++ b/src/main/java/br/unb/cic/analysis/df/ReachDefinitionAnalysis.java @@ -8,10 +8,9 @@ import soot.Local; import soot.Unit; import soot.ValueBox; +import soot.jimple.ArrayRef; import soot.jimple.InstanceFieldRef; import soot.jimple.StaticFieldRef; -import soot.jimple.internal.JArrayRef; -import soot.jimple.internal.JInstanceFieldRef; import soot.toolkits.graph.ExceptionalUnitGraph; import soot.toolkits.scalar.ArraySparseSet; import soot.toolkits.scalar.FlowSet; @@ -205,16 +204,15 @@ protected List getUseVariables(Unit u) { protected List getDefVariables(Unit u) { List localDefs = new ArrayList<>(); for (ValueBox v : u.getDefBoxes()) { - if (v.getValue() instanceof Local) { - localDefs.add((Local) v.getValue()); - } else if (v.getValue() instanceof JArrayRef) { - JArrayRef ref = (JArrayRef) v.getValue(); - localDefs.add((Local) ref.getBaseBox().getValue()); - } - else if (v.getValue() instanceof JInstanceFieldRef) { - JInstanceFieldRef ref = (JInstanceFieldRef) v.getValue(); - localDefs.add((Local) ref.getBaseBox().getValue()); - } + if (v.getValue() instanceof Local) { + localDefs.add((Local) v.getValue()); + } else if (v.getValue() instanceof ArrayRef) { + ArrayRef ref = (ArrayRef) v.getValue(); + localDefs.add((Local) ref.getBaseBox().getValue()); + } else if (v.getValue() instanceof InstanceFieldRef) { + InstanceFieldRef ref = (InstanceFieldRef) v.getValue(); + localDefs.add((Local) ref.getBaseBox().getValue()); + } } return localDefs; } diff --git a/src/main/java/br/unb/cic/analysis/df/TaintedAnalysis.java b/src/main/java/br/unb/cic/analysis/df/TaintedAnalysis.java index 973fe349..a0f28bf6 100644 --- a/src/main/java/br/unb/cic/analysis/df/TaintedAnalysis.java +++ b/src/main/java/br/unb/cic/analysis/df/TaintedAnalysis.java @@ -1,14 +1,12 @@ package br.unb.cic.analysis.df; -import soot.*; -import soot.jimple.internal.JArrayRef; +import br.unb.cic.analysis.AbstractMergeConflictDefinition; +import soot.Body; +import soot.Local; +import soot.Unit; import soot.toolkits.scalar.ArraySparseSet; import soot.toolkits.scalar.FlowSet; -import br.unb.cic.analysis.AbstractMergeConflictDefinition; - -import java.util.List; - public class TaintedAnalysis extends ReachDefinitionAnalysis { /**