Skip to content

Commit

Permalink
Dataset bug fix (#157)
Browse files Browse the repository at this point in the history
- Remove added constraint.
- Add function invocation processing.

Now, we can track datasets without explicitly adding a constraint.
  • Loading branch information
khatchad committed Mar 4, 2024
1 parent 4c02e7c commit b8dfbb7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ private static Set<PointsToSetVariable> getDataflowSources(
processInstructionInterprocedurally(
propertyRead, objectRef, localPointerKeyNode, src, sources, pointerAnalysis);
} else if (def instanceof EachElementGetInstruction
|| def instanceof PythonPropertyRead) {
|| def instanceof PythonPropertyRead
|| def instanceof PythonInvokeInstruction) {
processInstruction(
def,
du,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@

import com.ibm.wala.cast.ipa.callgraph.AstSSAPropagationCallGraphBuilder;
import com.ibm.wala.cast.ipa.callgraph.GlobalObjectKey;
import com.ibm.wala.cast.ir.ssa.AstPropertyRead;
import com.ibm.wala.cast.ir.ssa.EachElementGetInstruction;
import com.ibm.wala.cast.python.ipa.summaries.BuiltinFunctions.BuiltinFunction;
import com.ibm.wala.cast.python.ir.PythonLanguage;
import com.ibm.wala.cast.python.ssa.PythonInstructionVisitor;
import com.ibm.wala.cast.python.ssa.PythonInvokeInstruction;
import com.ibm.wala.cast.python.ssa.PythonPropertyRead;
import com.ibm.wala.cast.python.types.PythonTypes;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IField;
Expand All @@ -40,7 +37,6 @@
import com.ibm.wala.ssa.SSAArrayStoreInstruction;
import com.ibm.wala.ssa.SSABinaryOpInstruction;
import com.ibm.wala.ssa.SSAGetInstruction;
import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.ssa.SymbolTable;
import com.ibm.wala.types.FieldReference;
import com.ibm.wala.types.TypeReference;
Expand Down Expand Up @@ -179,42 +175,6 @@ public String toString() {
super.visitGet(instruction);
}

@Override
public void visitPropertyRead(AstPropertyRead instruction) {
super.visitPropertyRead(instruction);

if (instruction instanceof PythonPropertyRead) {
PythonPropertyRead ppr = (PythonPropertyRead) instruction;
SSAInstruction memberRefDef = du.getDef(ppr.getMemberRef());

if (memberRefDef != null && memberRefDef instanceof EachElementGetInstruction) {
// most likely a for each "property."
final PointerKey memberRefKey = this.getPointerKeyForLocal(ppr.getMemberRef());

// for each def of the property read.
for (int i = 0; i < ppr.getNumberOfDefs(); i++) {
PointerKey defKey = this.getPointerKeyForLocal(ppr.getDef(i));

// add an assignment constraint straight away as the traversal variable won't have a
// non-empty points-to set but still may be used for a dataflow analysis.
if (this.system.newConstraint(defKey, assignOperator, memberRefKey))
logger.fine(
() ->
"Added new system constraint for global read from: "
+ defKey
+ " to: "
+ memberRefKey
+ " for instruction: "
+ instruction
+ ".");
else
logger.fine(
() -> "No constraint added for global read in instruction: " + instruction + ".");
}
}
}
}

@Override
public void visitPythonInvoke(PythonInvokeInstruction inst) {
visitInvokeInternal(inst, new DefaultInvariantComputer());
Expand Down

0 comments on commit b8dfbb7

Please sign in to comment.