Class DataFlowGraph


  • public class DataFlowGraph
    extends Object
    A data flow graph for a single method.
    • Constructor Detail

      • DataFlowGraph

        public DataFlowGraph​(IRMethod method)
        Creates an empty graph for a method; call build() to populate it.
        Parameters:
        method - the IR method to graph
    • Method Detail

      • build

        public void build()
        Builds the graph from the method's def-use chains, discarding any previous contents.
      • getNodes

        public List<DataFlowNode> getNodes()
        Returns:
        an unmodifiable view of the graph nodes
      • getEdges

        public List<DataFlowEdge> getEdges()
        Returns:
        an unmodifiable view of the graph edges
      • getNodeForValue

        public DataFlowNode getNodeForValue​(SSAValue value)
        Looks up the node that defines an SSA value.
        Parameters:
        value - the defined SSA value
        Returns:
        the defining node, or null if the value has no node
      • getOutgoingEdges

        public List<DataFlowEdge> getOutgoingEdges​(DataFlowNode node)
        Lists the edges leaving a node.
        Parameters:
        node - the source node
        Returns:
        the outgoing edges, empty if the node is not in the graph
      • getIncomingEdges

        public List<DataFlowEdge> getIncomingEdges​(DataFlowNode node)
        Lists the edges entering a node.
        Parameters:
        node - the target node
        Returns:
        the incoming edges, empty if the node is not in the graph
      • getPotentialSources

        public List<DataFlowNode> getPotentialSources()
        Collects the nodes whose type can act as a taint source.
        Returns:
        the potential source nodes
      • getPotentialSinks

        public List<DataFlowNode> getPotentialSinks()
        Collects the nodes whose type can act as a taint sink.
        Returns:
        the potential sink nodes
      • getNodesByType

        public List<DataFlowNode> getNodesByType​(DataFlowNodeType type)
        Collects the nodes of one node type.
        Parameters:
        type - the node type to match
        Returns:
        the matching nodes
      • getReachableNodes

        public Set<DataFlowNode> getReachableNodes​(DataFlowNode start)
        Walks outgoing edges to find everything the start node flows into.
        Parameters:
        start - the node to walk from
        Returns:
        the reachable nodes, including the start node
      • getFlowingIntoNodes

        public Set<DataFlowNode> getFlowingIntoNodes​(DataFlowNode target)
        Walks incoming edges to find everything that flows into the target node.
        Parameters:
        target - the node to walk back from
        Returns:
        the contributing nodes, including the target node
      • getMethodName

        public String getMethodName()
        Returns:
        the method name
      • getMethod

        public IRMethod getMethod()
        Returns:
        the method
      • getNodeCount

        public int getNodeCount()
        Returns:
        the number of nodes in the graph
      • getEdgeCount

        public int getEdgeCount()
        Returns:
        the number of edges in the graph