Class PDGEdge


  • public class PDGEdge
    extends Object
    A directed dependence edge in a program dependence graph.
    • Constructor Detail

      • PDGEdge

        public PDGEdge​(PDGNode source,
                       PDGNode target,
                       PDGDependenceType type)
        Creates an unlabelled edge that carries no value.
        Parameters:
        source - the depended-upon node
        target - the dependent node
        type - the dependence kind
      • PDGEdge

        public PDGEdge​(PDGNode source,
                       PDGNode target,
                       PDGDependenceType type,
                       SSAValue dependentValue)
        Creates an unlabelled edge that carries the value flowing along it.
        Parameters:
        source - the depended-upon node
        target - the dependent node
        type - the dependence kind
        dependentValue - the value flowing from source to target
      • PDGEdge

        public PDGEdge​(PDGNode source,
                       PDGNode target,
                       PDGDependenceType type,
                       String label)
        Creates a labelled edge that carries no value.
        Parameters:
        source - the depended-upon node
        target - the dependent node
        type - the dependence kind
        label - text shown on the edge
      • PDGEdge

        public PDGEdge​(PDGNode source,
                       PDGNode target,
                       PDGDependenceType type,
                       String label,
                       SSAValue dependentValue,
                       boolean branchCondition)
        Creates an edge with every attribute given explicitly.
        Parameters:
        source - the depended-upon node
        target - the dependent node
        type - the dependence kind
        label - text shown on the edge, or null
        dependentValue - the value flowing from source to target, or null
        branchCondition - the branch outcome this control edge is taken on
    • Method Detail

      • getSource

        public PDGNode getSource()
        Returns:
        the source
      • getTarget

        public PDGNode getTarget()
        Returns:
        the target
      • getLabel

        public String getLabel()
        Returns:
        the label
      • getDependentValue

        public SSAValue getDependentValue()
        Returns:
        the dependent value
      • isBranchCondition

        public boolean isBranchCondition()
        Returns:
        whether branch condition
      • isTainted

        public boolean isTainted()
        Returns:
        whether tainted
      • setTainted

        public void setTainted​(boolean tainted)
        Marks whether tainted data travels along this edge.
        Parameters:
        tainted - true if the flow is tainted
      • controlEdge

        public static PDGEdge controlEdge​(PDGNode source,
                                          PDGNode target,
                                          boolean condition)
        Creates a control dependence edge for one outcome of a branch.
        Parameters:
        source - the branching node
        target - the node controlled by the branch
        condition - the branch outcome the target is reached on
        Returns:
        the control edge
      • dataEdge

        public static PDGEdge dataEdge​(PDGNode source,
                                       PDGNode target,
                                       SSAValue value)
        Creates a def-use data dependence edge.
        Parameters:
        source - the defining node
        target - the using node
        value - the value that flows
        Returns:
        the data edge
      • phiEdge

        public static PDGEdge phiEdge​(PDGNode source,
                                      PDGNode target,
                                      SSAValue value,
                                      String blockLabel)
        Creates a data dependence edge feeding one operand of a phi.
        Parameters:
        source - the node defining the incoming operand
        target - the phi node
        value - the incoming value
        blockLabel - the predecessor block the operand arrives from
        Returns:
        the phi edge
      • isControlDependence

        public boolean isControlDependence()
        Returns:
        true if the dependence type is a control dependence
      • isDataDependence

        public boolean isDataDependence()
        Returns:
        true if the dependence type is a data dependence
      • isInterprocedural

        public boolean isInterprocedural()
        Returns:
        true if the dependence type crosses a procedure boundary
      • hasDependentValue

        public boolean hasDependentValue()
        Returns:
        true if a flowing value is attached to this edge
      • hasLabel

        public boolean hasLabel()
        Returns:
        true if a non-empty label is attached to this edge
      • getVariable

        public String getVariable()
        Returns:
        the name of the flowing value, or null if no value is attached
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object