Package com.ibm.wala.cfg
Class Util
- java.lang.Object
-
- com.ibm.wala.cfg.Util
-
public class Util extends Object
Convenience methods for navigating aControlFlowGraph
.
-
-
Constructor Summary
Constructors Constructor Description Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
endsWithConditionalBranch(ControlFlowGraph G, IBasicBlock b)
Does basic block b end with a conditional branch instruction?static boolean
endsWithSwitch(ControlFlowGraph G, IBasicBlock b)
Does basic block b end with a switch instruction?static <I,T extends IBasicBlock<I>>
TgetFallThruBlock(ControlFlowGraph<I,T> G, T b)
Given that b falls through to the next basic block, what basic block does it fall through to?static SSAInstruction
getLastInstruction(ControlFlowGraph cfg, IBasicBlock b)
static <I,T extends IBasicBlock<I>>
TgetNotTakenSuccessor(ControlFlowGraph<I,T> G, T b)
Given that b ends with a conditional branch, return the basic block to which control transfers if the branch is not taken.static <I,T extends IBasicBlock<I>>
intgetSwitchLabel(ControlFlowGraph<I,T> G, T b, T s)
When a switch statement at the end of block b transfers control to block s, which case was taken? TODO: Is this correct? Can't we have multiple cases that apply? Check on this.static <I,T extends IBasicBlock<I>>
TgetTakenSuccessor(ControlFlowGraph<I,T> G, T b)
Given that b ends with a conditional branch, return the basic block to which control transfers if the branch is taken.static <I,T extends IBasicBlock<I>>
booleanisSwitchDefault(ControlFlowGraph<I,T> G, T b, T s)
Is block s the default case for the switch instruction which is the last instruction of block b?static <I,T extends IBasicBlock<I>>
TresolveBranch(ControlFlowGraph<I,T> G, T bb, int c1, int c2)
To whichIBasicBlock
does control flow from basic block bb, which ends in a conditional branch, when the conditional branch operands evaluate to the constants c1 and c2, respectively.static <I,T extends IBasicBlock<I>>
TresolveSwitch(ControlFlowGraph<I,T> G, T b, int c)
When the tested value of the switch statement in b has value c, which basic block does control transfer to.static <I,T extends IBasicBlock<I>>
intwhichPred(ControlFlowGraph<I,T> cfg, T a, T b)
Given that a is a predecessor of b in the cfg ..
-
-
-
Method Detail
-
getLastInstruction
public static SSAInstruction getLastInstruction(ControlFlowGraph cfg, IBasicBlock b)
- Returns:
- the last instruction in basic block b, as stored in the instruction array for cfg
-
endsWithConditionalBranch
public static boolean endsWithConditionalBranch(ControlFlowGraph G, IBasicBlock b)
Does basic block b end with a conditional branch instruction?
-
endsWithSwitch
public static boolean endsWithSwitch(ControlFlowGraph G, IBasicBlock b)
Does basic block b end with a switch instruction?
-
getFallThruBlock
public static <I,T extends IBasicBlock<I>> T getFallThruBlock(ControlFlowGraph<I,T> G, T b)
Given that b falls through to the next basic block, what basic block does it fall through to?
-
getNotTakenSuccessor
public static <I,T extends IBasicBlock<I>> T getNotTakenSuccessor(ControlFlowGraph<I,T> G, T b)
Given that b ends with a conditional branch, return the basic block to which control transfers if the branch is not taken.
-
getTakenSuccessor
public static <I,T extends IBasicBlock<I>> T getTakenSuccessor(ControlFlowGraph<I,T> G, T b)
Given that b ends with a conditional branch, return the basic block to which control transfers if the branch is taken.
-
resolveSwitch
public static <I,T extends IBasicBlock<I>> T resolveSwitch(ControlFlowGraph<I,T> G, T b, int c)
When the tested value of the switch statement in b has value c, which basic block does control transfer to.
-
isSwitchDefault
public static <I,T extends IBasicBlock<I>> boolean isSwitchDefault(ControlFlowGraph<I,T> G, T b, T s)
Is block s the default case for the switch instruction which is the last instruction of block b?
-
getSwitchLabel
public static <I,T extends IBasicBlock<I>> int getSwitchLabel(ControlFlowGraph<I,T> G, T b, T s)
When a switch statement at the end of block b transfers control to block s, which case was taken? TODO: Is this correct? Can't we have multiple cases that apply? Check on this.
-
resolveBranch
public static <I,T extends IBasicBlock<I>> T resolveBranch(ControlFlowGraph<I,T> G, T bb, int c1, int c2)
To whichIBasicBlock
does control flow from basic block bb, which ends in a conditional branch, when the conditional branch operands evaluate to the constants c1 and c2, respectively. Callers must resolve the constant values from theSymbolTable
before calling this method. These integers arenot value numbers;
-
whichPred
public static <I,T extends IBasicBlock<I>> int whichPred(ControlFlowGraph<I,T> cfg, T a, T b)
Given that a is a predecessor of b in the cfg .. When we enumerate the predecessors of b in order, which is the first index in this order in which a appears? Note that this order corresponds to the order of operands in a phi instruction.
-
-