rename getTrue/FalseSuccessor to getTaken/NotTakenSuccessor and check for IllegalArgumentExceptions
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@1510 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
0d32f296f4
commit
155aaf9f50
|
@ -51,15 +51,32 @@ public class Util {
|
||||||
return G.getBlockForInstruction(b.getLastInstructionIndex() + 1);
|
return G.getBlockForInstruction(b.getLastInstructionIndex() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IBasicBlock getFalseSuccessor(ControlFlowGraph G, IBasicBlock b) {
|
/**
|
||||||
return getFallThruBlock(G, b);
|
* Given that b ends with a conditional branch, return the basic block to which control
|
||||||
}
|
* transfers if the branch is not taken.
|
||||||
|
*/
|
||||||
public static IBasicBlock getTrueSuccessor(ControlFlowGraph G, IBasicBlock b) {
|
public static IBasicBlock getNotTakenSuccessor(ControlFlowGraph G, IBasicBlock b) {
|
||||||
if (G == null) {
|
if (G == null) {
|
||||||
throw new IllegalArgumentException("G is null");
|
throw new IllegalArgumentException("G is null");
|
||||||
}
|
}
|
||||||
IBasicBlock fs = getFalseSuccessor(G, b);
|
if (!endsWithConditionalBranch(G, b)) {
|
||||||
|
throw new IllegalArgumentException(b.toString() + " does not end with a conditional branch");
|
||||||
|
}
|
||||||
|
return getFallThruBlock(G, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given that b ends with a conditional branch, return the basic block to which control
|
||||||
|
* transfers if the branch is not taken.
|
||||||
|
*/
|
||||||
|
public static IBasicBlock getTakenSuccessor(ControlFlowGraph G, IBasicBlock b) {
|
||||||
|
if (G == null) {
|
||||||
|
throw new IllegalArgumentException("G is null");
|
||||||
|
}
|
||||||
|
if (!endsWithConditionalBranch(G, b)) {
|
||||||
|
throw new IllegalArgumentException(b.toString() + " does not end with a conditional branch");
|
||||||
|
}
|
||||||
|
IBasicBlock fs = getNotTakenSuccessor(G, b);
|
||||||
for (Iterator ss = G.getSuccNodes(b); ss.hasNext();) {
|
for (Iterator ss = G.getSuccNodes(b); ss.hasNext();) {
|
||||||
IBasicBlock s = (IBasicBlock) ss.next();
|
IBasicBlock s = (IBasicBlock) ss.next();
|
||||||
if (s != fs)
|
if (s != fs)
|
||||||
|
@ -119,34 +136,34 @@ public class Util {
|
||||||
switch ((ConditionalBranchInstruction.Operator) c.getOperator()) {
|
switch ((ConditionalBranchInstruction.Operator) c.getOperator()) {
|
||||||
case EQ:
|
case EQ:
|
||||||
if (c1 == c2)
|
if (c1 == c2)
|
||||||
return getTrueSuccessor(G, bb);
|
return getTakenSuccessor(G, bb);
|
||||||
else
|
else
|
||||||
return getFalseSuccessor(G, bb);
|
return getNotTakenSuccessor(G, bb);
|
||||||
case NE:
|
case NE:
|
||||||
if (c1 != c2)
|
if (c1 != c2)
|
||||||
return getTrueSuccessor(G, bb);
|
return getTakenSuccessor(G, bb);
|
||||||
else
|
else
|
||||||
return getFalseSuccessor(G, bb);
|
return getNotTakenSuccessor(G, bb);
|
||||||
case LT:
|
case LT:
|
||||||
if (c1 < c2)
|
if (c1 < c2)
|
||||||
return getTrueSuccessor(G, bb);
|
return getTakenSuccessor(G, bb);
|
||||||
else
|
else
|
||||||
return getFalseSuccessor(G, bb);
|
return getNotTakenSuccessor(G, bb);
|
||||||
case GE:
|
case GE:
|
||||||
if (c1 >= c2)
|
if (c1 >= c2)
|
||||||
return getTrueSuccessor(G, bb);
|
return getTakenSuccessor(G, bb);
|
||||||
else
|
else
|
||||||
return getFalseSuccessor(G, bb);
|
return getNotTakenSuccessor(G, bb);
|
||||||
case GT:
|
case GT:
|
||||||
if (c1 > c2)
|
if (c1 > c2)
|
||||||
return getTrueSuccessor(G, bb);
|
return getTakenSuccessor(G, bb);
|
||||||
else
|
else
|
||||||
return getFalseSuccessor(G, bb);
|
return getNotTakenSuccessor(G, bb);
|
||||||
case LE:
|
case LE:
|
||||||
if (c1 <= c2)
|
if (c1 <= c2)
|
||||||
return getTrueSuccessor(G, bb);
|
return getTakenSuccessor(G, bb);
|
||||||
else
|
else
|
||||||
return getFalseSuccessor(G, bb);
|
return getNotTakenSuccessor(G, bb);
|
||||||
}
|
}
|
||||||
|
|
||||||
Assertions.UNREACHABLE();
|
Assertions.UNREACHABLE();
|
||||||
|
|
|
@ -1286,8 +1286,8 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
||||||
system.newConstraint(dst, assignOperator, src);
|
system.newConstraint(dst, assignOperator, src);
|
||||||
} else {
|
} else {
|
||||||
PointerKey dst = getFilteredPointerKeyForLocal(instruction.getDef(), new FilteredPointerKey.SingleClassFilter(cls));
|
PointerKey dst = getFilteredPointerKeyForLocal(instruction.getDef(), new FilteredPointerKey.SingleClassFilter(cls));
|
||||||
if ((target == com.ibm.wala.cfg.Util.getTrueSuccessor(CFG, getBasicBlock()) && dir == 1)
|
if ((target == com.ibm.wala.cfg.Util.getTakenSuccessor(CFG, getBasicBlock()) && dir == 1)
|
||||||
|| (target == com.ibm.wala.cfg.Util.getFalseSuccessor(CFG, getBasicBlock()) && dir == -1)) {
|
|| (target == com.ibm.wala.cfg.Util.getNotTakenSuccessor(CFG, getBasicBlock()) && dir == -1)) {
|
||||||
system.newConstraint(dst, getBuilder().filterOperator, src);
|
system.newConstraint(dst, getBuilder().filterOperator, src);
|
||||||
// System.err.println("PI " + dst + " " + src);
|
// System.err.println("PI " + dst + " " + src);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1295,8 +1295,8 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ((dir = nullConstantTest(cond, instruction.getVal())) != 0) {
|
} else if ((dir = nullConstantTest(cond, instruction.getVal())) != 0) {
|
||||||
if ((target == com.ibm.wala.cfg.Util.getTrueSuccessor(CFG, getBasicBlock()) && dir == -1)
|
if ((target == com.ibm.wala.cfg.Util.getTakenSuccessor(CFG, getBasicBlock()) && dir == -1)
|
||||||
|| (target == com.ibm.wala.cfg.Util.getFalseSuccessor(CFG, getBasicBlock()) && dir == 1)) {
|
|| (target == com.ibm.wala.cfg.Util.getNotTakenSuccessor(CFG, getBasicBlock()) && dir == 1)) {
|
||||||
PointerKey dst = getPointerKeyForLocal(instruction.getDef());
|
PointerKey dst = getPointerKeyForLocal(instruction.getDef());
|
||||||
system.newConstraint(dst, assignOperator, src);
|
system.newConstraint(dst, assignOperator, src);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue