Class ReferenceType

java.lang.Object
de.fraunhofer.aisec.cpg.graph.Node
de.fraunhofer.aisec.cpg.graph.types.Type
de.fraunhofer.aisec.cpg.graph.types.ReferenceType
All Implemented Interfaces:
Persistable, SecondOrderType, IVisitable<de.fraunhofer.aisec.cpg.graph.Node>

public class ReferenceType
extends Type
implements SecondOrderType
ReferenceTypes describe CPP References (int&), which are represent an alternative name for a variable. It is necessary to make this distinction, and not just rely on the original type as it is required for matching parameters in function arguments to discover which implementation is called.
  • Constructor Details

    • ReferenceType

      public ReferenceType​(Type reference)
    • ReferenceType

      public ReferenceType​(Type type, Type reference)
    • ReferenceType

      public ReferenceType​(Type.Storage storage, Type.Qualifier qualifier, Type reference)
  • Method Details

    • reference

      public Type reference​(PointerType.PointerOrigin pointerOrigin)
      Specified by:
      reference in class Type
      Parameters:
      pointerOrigin - Reason for the reference (array of pointer)
      Returns:
      Referencing a ReferenceType results in a PointerType to the original ReferenceType
    • dereference

      public Type dereference()
      Specified by:
      dereference in class Type
      Returns:
      Dereferencing a ReferenceType equals to dereferencing the original (non-reference) type
    • duplicate

      public Type duplicate()
      Specified by:
      duplicate in class Type
      Returns:
      Creates an exact copy of the current type (chain)
    • getElementType

      public Type getElementType()
      Specified by:
      getElementType in interface SecondOrderType
    • setElementType

      public void setElementType​(Type reference)
      Specified by:
      setElementType in interface SecondOrderType
    • isSimilar

      public boolean isSimilar​(Type t)
      Description copied from class: Type
      Required for possibleSubTypes to check if the new Type should be considered a subtype or not
      Overrides:
      isSimilar in class Type
      Parameters:
      t - other type the similarity is checked with
      Returns:
      True if the parameter t is equal to the current type (this)
    • refreshName

      public void refreshName()
    • equals

      public boolean equals​(java.lang.Object o)
      Overrides:
      equals in class Type
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Type
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class Type