/** * value val gets new base, fields are preserved. * * @param original The original access path * @param val The new base value * @return This access path with the base replaced by the value given in the val * parameter */ public AccessPath copyWithNewValue(AccessPath original, Value val, Type newType, boolean cutFirstField) { return copyWithNewValue(original, val, newType, cutFirstField, true); }
/** * Copies the given access path with a new base value, but retains the base type * * @param original The original access path * @param val The new value * @return The new access path with the exchanged value */ public AccessPath copyWithNewValue(AccessPath original, Value val) { return copyWithNewValue(original, val, original.getBaseType(), false); }
/** * value val gets new base, fields are preserved. * * @param original The original access path * @param val The new base value * @param reduceBases True if circular types shall be reduced to bases * @return This access path with the base replaced by the value given in the val * parameter */ public AccessPath copyWithNewValue(AccessPath original, Value val, Type newType, boolean cutFirstField, boolean reduceBases) { return copyWithNewValue(original, val, newType, cutFirstField, reduceBases, original.getArrayTaintType()); }
@Override public Collection<Abstraction> propagateNormalFlow(Abstraction d1, Abstraction source, Stmt stmt, Stmt destStmt, ByReferenceBoolean killSource, ByReferenceBoolean killAll) { // Do not process zero abstractions if (source == getZeroValue()) return null; // Do we catch an exception here? if (source.getExceptionThrown() && stmt instanceof DefinitionStmt) { DefinitionStmt def = (DefinitionStmt) stmt; if (def.getRightOp() instanceof CaughtExceptionRef) { killSource.value = true; AccessPath ap = getManager().getAccessPathFactory().copyWithNewValue(source.getAccessPath(), def.getLeftOp()); return ap == null ? null : Collections.singleton(source.deriveNewAbstractionOnCatch(ap)); } } // Do we throw an exception here? if (stmt instanceof ThrowStmt) { ThrowStmt throwStmt = (ThrowStmt) stmt; if (getAliasing().mayAlias(throwStmt.getOp(), source.getAccessPath().getPlainValue())) { killSource.value = true; return Collections.singleton(source.deriveNewAbstractionOnThrow(throwStmt)); } } return null; }
if(params[0].equals(source.getAccessPath().getPlainValue())) { if (manager.getTypeUtils().checkCast(source.getAccessPath(), params[2].getType())) { AccessPath ap = manager.getAccessPathFactory().copyWithNewValue(source.getAccessPath(), params[2], source.getAccessPath().getBaseType(), false); Abstraction abs = source.deriveNewAbstraction(ap, call); if(params[1].equals(source.getAccessPath().getPlainValue())) { if (manager.getTypeUtils().checkCast(source.getAccessPath(), params[1].getType())) { AccessPath ap = manager.getAccessPathFactory().copyWithNewValue(source.getAccessPath(), params[1], source.getAccessPath().getBaseType(), false, true, ArrayTaintType.Length); Abstraction abs = source.deriveNewAbstraction(ap, call);
thisLocal = callee.getActiveBody().getThisLocal(); res.add(manager.getAccessPathFactory().copyWithNewValue(ap, thisLocal)); if (res == null) res = new HashSet<AccessPath>(); res.add(manager.getAccessPathFactory().copyWithNewValue(ap, callee.getActiveBody().getThisLocal())); AccessPath newAP = manager.getAccessPathFactory().copyWithNewValue(ap, paramLocals[j], null, false); if (newAP != null) AccessPath newAP = manager.getAccessPathFactory().copyWithNewValue(ap, paramLocals[i]); if (newAP != null) res.add(newAP);
if(params[0].equals(source.getAccessPath().getPlainValue())) { if (manager.getTypeUtils().checkCast(source.getAccessPath(), params[2].getType())) { AccessPath ap = manager.getAccessPathFactory().copyWithNewValue(source.getAccessPath(), params[2], source.getAccessPath().getBaseType(), false); Abstraction abs = source.deriveNewAbstraction(ap, call); if(params[1].equals(source.getAccessPath().getPlainValue())) { if (manager.getTypeUtils().checkCast(source.getAccessPath(), params[1].getType())) { AccessPath ap = manager.getAccessPathFactory().copyWithNewValue(source.getAccessPath(), params[1], source.getAccessPath().getBaseType(), false, true, ArrayTaintType.Length); Abstraction abs = source.deriveNewAbstraction(ap, call);
ReturnStmt retStmt = (ReturnStmt) stmt; if (callSite instanceof AssignStmt && ((AssignStmt) callSite).getLeftOp() == curAP.getPlainValue()) { return manager.getAccessPathFactory().copyWithNewValue(curAP, retStmt.getOp()); if (iiExpr.getBase() == curAP.getPlainValue()) { Local thisLocal = callee.getActiveBody().getThisLocal(); return manager.getAccessPathFactory().copyWithNewValue(curAP, thisLocal); if (callSite.getInvokeExpr().getArg(i) == curAP.getPlainValue()) { Local paramLocal = callee.getActiveBody().getParameterLocal(i); return manager.getAccessPathFactory().copyWithNewValue(curAP, paramLocal); Local paramLocal = curMethod.getActiveBody().getParameterLocal(i); if (paramLocal == curAP.getPlainValue()) { return manager.getAccessPathFactory().copyWithNewValue(curAP, callSite.getInvokeExpr().getArg(i), curMethod.getParameterType(i), false);
if (callSite instanceof DefinitionStmt) { DefinitionStmt def = (DefinitionStmt) callSite; AccessPath ap = getManager().getAccessPathFactory().copyWithNewValue(source.getAccessPath(), def.getLeftOp()); Abstraction abs = source.deriveNewAbstraction(ap, returnStmt); AccessPath ap = getManager().getAccessPathFactory().copyWithNewValue(source.getAccessPath(), leftOp); Abstraction abs = source.deriveNewAbstraction(ap, returnStmt);
if (!callee.isStatic()) if (curAP.getPlainValue() == thisLocal) return manager.getAccessPathFactory().copyWithNewValue(curAP, stmt.getInvokeExpr().getArg(0)); AccessPath newAP = manager.getAccessPathFactory().copyWithNewValue(curAP, stmt.getInvokeExpr().getArg(i)); if (newAP != null) { AccessPath newAP = manager.getAccessPathFactory().copyWithNewValue(curAP, ((InstanceInvokeExpr) stmt.getInvokeExpr()).getBase()); if (newAP != null) { ReturnStmt rStmt = (ReturnStmt) u; if (rStmt.getOp() == curAP.getPlainValue()) { AccessPath newAP = manager.getAccessPathFactory().copyWithNewValue(curAP, assign.getLeftOp()); if (newAP != null) { curAP = newAP;
newAP = manager.getAccessPathFactory().createAccessPath(newBase, true); else newAP = manager.getAccessPathFactory().copyWithNewValue(scap.curAP, newBase); if (newAP != null) { scap.curAP = newAP; newAP = manager.getAccessPathFactory().createAccessPath(rop, false); else newAP = manager.getAccessPathFactory().copyWithNewValue(scap.curAP, rop, null, false); if (newAP != null) { scap.curAP = newAP; AccessPath matchedAP = matchAccessPath(scap.curAP, ifref.getBase(), ifref.getField()); if (matchedAP != null) { AccessPath newAP = manager.getAccessPathFactory().copyWithNewValue(matchedAP, assignStmt.getRightOp(), matchedAP.getFirstFieldType(), true); if (newAP != null) { scap.curAP = manager.getAccessPathFactory().copyWithNewValue(scap.curAP, lop, null, false); matched = true; } else if (assignStmt.getRightOp() instanceof InstanceFieldRef) { AccessPath matchedAP = matchAccessPath(scap.curAP, ifref.getBase(), ifref.getField()); if (matchedAP != null) { scap.curAP = manager.getAccessPathFactory().copyWithNewValue(matchedAP, assignStmt.getLeftOp(), matchedAP.getFirstFieldType(), true); matched = true;
AccessPath ap = getManager().getAccessPathFactory().copyWithNewValue(source.getAccessPath(), leftVal, targetType, false, true, arrayTaintType); newAbs = source.deriveNewAbstraction(ap, assignStmt); AccessPath ap = getManager().getAccessPathFactory().copyWithNewValue(source.getAccessPath(), leftVal, null, false, true, arrayTaintType); newAbs = source.deriveNewAbstraction(ap, assignStmt); if (getAliasing().mayAlias(source.getAccessPath().getPlainValue(), newArrayExpr.getSize())) { AccessPath ap = getManager().getAccessPathFactory().copyWithNewValue(source.getAccessPath(), leftVal, null, false, true, ArrayTaintType.Length); newAbs = source.deriveNewAbstraction(ap, assignStmt);
manager.getAccessPathFactory().createAccessPath(leftValue, true), assignStmt, true); else { AccessPath ap = manager.getAccessPathFactory().copyWithNewValue(source.getAccessPath(), leftValue, targetType, cutFirstField, true, arrayTaintType); newAbs = source.deriveNewAbstraction(ap, assignStmt);
&& ref.getBase() == source.getAccessPath().getPlainValue() && source.getAccessPath().firstFieldMatches(ref.getField())) { AccessPath ap = manager.getAccessPathFactory().copyWithNewValue(source.getAccessPath(), leftValue, source.getAccessPath().getFirstFieldType(), true); newLeftAbs = checkAbstraction(source.deriveNewAbstraction(ap, defStmt)); if (source.getAccessPath().isStaticFieldRef() && source.getAccessPath().firstFieldMatches(ref.getField())) { AccessPath ap = manager.getAccessPathFactory().copyWithNewValue(source.getAccessPath(), leftValue, source.getAccessPath().getBaseType(), true); newLeftAbs = checkAbstraction(source.deriveNewAbstraction(ap, defStmt)); AccessPath ap = manager.getAccessPathFactory().copyWithNewValue(source.getAccessPath(), leftValue, newType, false); newLeftAbs = checkAbstraction(source.deriveNewAbstraction(ap, defStmt)); AccessPath ap = manager.getAccessPathFactory().copyWithNewValue(source.getAccessPath(), rightValue, targetType, cutFirstField); Abstraction newAbs = checkAbstraction(source.deriveNewAbstraction(ap, defStmt));