Class InducedCFG

All Implemented Interfaces:
ControlFlowGraph<SSAInstruction, InducedCFG.BasicBlock>, MinimalCFG<InducedCFG.BasicBlock>, Constants, EdgeManager<InducedCFG.BasicBlock>, Graph<InducedCFG.BasicBlock>, NodeManager<InducedCFG.BasicBlock>, NumberedEdgeManager<InducedCFG.BasicBlock>, NumberedGraph<InducedCFG.BasicBlock>, NumberedNodeManager<InducedCFG.BasicBlock>, Iterable<InducedCFG.BasicBlock>
Direct Known Subclasses:
AstInducedCFG

public class InducedCFG extends AbstractCFG<SSAInstruction, InducedCFG.BasicBlock>
A ControlFlowGraph computed from a set of SSAInstruction instructions.

This is a funny CFG ... we assume that there are always fallthru edges, even from throws and returns. It is extremely fragile and unsuited for flow-sensitive analysis. Someday this should be nuked.

  • Constructor Details

    • InducedCFG

      public InducedCFG(SSAInstruction[] instructions, IMethod method, Context context)
      TODO: we do not yet support induced CFGS with exception handlers.

      NOTE: SIDE EFFECT!!! ... nulls out phi instructions and pi instructions in the instruction array!

      Throws:
      IllegalArgumentException - if instructions is null
  • Method Details

    • hashCode

      public int hashCode()
      Specified by:
      hashCode in class AbstractCFG<SSAInstruction, InducedCFG.BasicBlock>
    • equals

      public boolean equals(Object o)
      Specified by:
      equals in class AbstractCFG<SSAInstruction, InducedCFG.BasicBlock>
    • getInstructions

      public SSAInstruction[] getInstructions()
      Returns:
      the instructions of this CFG, as an array.
    • makeBranchVisitor

      protected InducedCFG.BranchVisitor makeBranchVisitor(boolean[] r)
    • makePEIVisitor

      protected InducedCFG.PEIVisitor makePEIVisitor(boolean[] r)
    • getBlockForInstruction

      public InducedCFG.BasicBlock getBlockForInstruction(int index)
      Parameters:
      index - an instruction index
      Returns:
      the basic block which contains this instruction.
    • toString

      public String toString()
      Overrides:
      toString in class AbstractCFG<SSAInstruction, InducedCFG.BasicBlock>
    • getProgramCounter

      public int getProgramCounter(int index)
      Since this CFG is synthetic, for now we assume the instruction index is the same as the program counter
      Parameters:
      index - an instruction index
      Returns:
      the program counter (bytecode index) corresponding to that instruction
    • getIndexFromIIndex

      public int getIndexFromIIndex(int iindex)
      Get the position of a instruction with a given iindex in the internal list.
      Parameters:
      iindex - The iindex used when generating the SSAInstruction
      Returns:
      index into the internal list of instructions
      Throws:
      IllegalStateException - if no instruction exists with iindex or it's not in the internal array (Phi)
    • getAllPhiInstructions

      public Collection<SSAPhiInstruction> getAllPhiInstructions()