Package ghidra.app.util.demangler

# Class DemangledFunction

java.lang.Object
ghidra.app.util.demangler.DemangledObject
ghidra.app.util.demangler.DemangledFunction

All Implemented Interfaces:
  `Demangled`

Direct Known Subclasses:
  `DemangledLambda`

public class DemangledFunction extends DemangledObject
A class to represent a demangled function.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected String`
  `callingConvention`
  `static final String`
  `CONST`
  `protected boolean`
  `isOverloadedOperator`
  `protected List<DemangledDataType>`
  `parameters`
  `static final String`
  `PTR64`
  `static final String`
  `RESTRICT`
  `protected DemangledDataType`
  `returnType`
  `protected SourceType`
  `signatureSourceType`
  `protected DemangledTemplate`
  `template`
  `protected boolean`
  `thisPassedOnStack`
  `static final String`
  `UNALIGNED`
  `static final String`
  `VOLATILE`

  ### Fields inherited from class ghidra.app.util.demangler.DemangledObject

  `basedName, EMPTY_STRING, isRestrict, isStatic, isThunk, isUnaligned, isVirtual, mangled, memberScope, namespace, NAMESPACE_SEPARATOR, originalDemangled, SPACE, SPACE_PATTERN, specialPrefix, storageClass, visibility`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DemangledFunction(String mangled, String originalDemangled, String name)`
  Create a `DemangledFunction` instance which is marked with a signature `SourceType` of `SourceType.ANALYSIS` which will be used when function signatures are applied to a program.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addParameter(DemangledDataType parameter)`
  `protected void`
  `addParameters(StringBuilder buffer, boolean format)`
  `boolean`
  `applyTo(Program program, Address address, DemanglerOptions options, TaskMonitor monitor)`
  Apply this demangled object detail to the specified program.
  `protected Function`
  `createFunction(Program prog, Address addr, boolean doDisassembly, TaskMonitor monitor)`
  `String`
  `getCallingConvention()`
  Returns the calling convention or null, if unspecified.
  `String`
  `getNamespaceName()`
  Returns this object's namespace name without the fully-qualified parent path.
  `List<DemangledDataType>`
  `getParameters()`
  `String`
  `getParameterString()`
  `DemangledDataType`
  `getReturnType()`
  Returns the return type or null, if unspecified.
  `String`
  `getSignature(boolean format)`
  Returns a complete signature for the demangled symbol.
  `SourceType`
  `getSignatureSourceType()`
  Get the signature source type which is used when applying the function signature to a program.
  `DemangledTemplate`
  `getTemplate()`
  `protected boolean`
  `isAlreadyDemangled(Program program, Address address)`
  Determine if the symbol at address has already been demangled.
  `protected boolean`
  `isDefinedFunctionDataTypes(Function func)`
  check if the return/param data types were defined by better than analysis (user, import)
  `boolean`
  `isTrailingConst()`
  `boolean`
  `isTrailingPointer64()`
  `boolean`
  `isTrailingRestrict()`
  `boolean`
  `isTrailingUnaligned()`
  `boolean`
  `isTrailingVolatile()`
  `boolean`
  `isTypeCast()`
  `protected Structure`
  `maybeCreateClassStructure(Program program, Function function, String convention)`
  `void`
  `setCallingConvention(String callingConvention)`
  Sets the function calling convention.
  `void`
  `setOverloadedOperator(boolean isOverloadedOperator)`
  Sets whether this demangled function represents an overloaded operator.
  `void`
  `setReturnType(DemangledDataType returnType)`
  Sets the function return type.
  `void`
  `setSignatureSourceType(SourceType signatureSourceType)`
  Set signature `SourceType` of `SourceType.ANALYSIS` which will be used when function signatures are applied to a program.
  `void`
  `setTemplate(DemangledTemplate template)`
  `void`
  `setTemplatedConstructorType(String type)`
  Special constructor where it has a templated type before the parameter list
  `void`
  `setThrowAttribute(String throwAttribute)`
  `void`
  `setTrailingConst()`
  `void`
  `setTrailingPointer64()`
  `void`
  `setTrailingRestrict()`
  `void`
  `setTrailingUnaligned()`
  `void`
  `setTrailingVolatile()`
  `void`
  `setTypeCast()`

  ### Methods inherited from class ghidra.app.util.demangler.DemangledObject

  `applyDemangledName, applyDemangledName, applyPlateCommentOnly, createNamespace, demangledNameSuccessfully, ensureNameLength, generatePlateComment, getBasedName, getDemangledName, getErrorMessage, getMangledString, getMemberScope, getName, getNamespace, getNamespaceString, getOriginalDemangled, getSignature, getSpecialPrefix, getStorageClass, getVisibility, isConst, isPointer64, isRestrict, isStatic, isThunk, isUnaligned, isVirtual, isVolatile, setBackupPlateComment, setBasedName, setConst, setErrorMessage, setMemberScope, setName, setNamespace, setPointer64, setRestrict, setSpecialPrefix, setStatic, setStorageClass, setThunk, setUnaligned, setVirtual, setVisibilty, setVolatile, toString`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### VOLATILE

    public static final String VOLATILE
    See Also:
      - Constant Field Values

  - ### CONST

    public static final String CONST
    See Also:
      - Constant Field Values

  - ### PTR64

    public static final String PTR64
    See Also:
      - Constant Field Values

  - ### UNALIGNED

    public static final String UNALIGNED
    See Also:
      - Constant Field Values

  - ### RESTRICT

    public static final String RESTRICT
    See Also:
      - Constant Field Values

  - ### returnType

    protected DemangledDataType returnType

  - ### callingConvention

    protected String callingConvention

  - ### thisPassedOnStack

    protected boolean thisPassedOnStack

  - ### parameters

    protected List<DemangledDataType> parameters

  - ### template

    protected DemangledTemplate template

  - ### isOverloadedOperator

    protected boolean isOverloadedOperator

  - ### signatureSourceType

    protected SourceType signatureSourceType

- ## Constructor Details

  - ### DemangledFunction

    public DemangledFunction(String mangled, String originalDemangled, String name)
    Create a `DemangledFunction` instance which is marked with a signature `SourceType` of `SourceType.ANALYSIS` which will be used when function signatures are applied to a program. This source type may be changed if needed using `setSignatureSourceType(SourceType)`. The function name and namespace is always applied using a symbol source of `SourceType.ANALYSIS`.
    Parameters:
      `mangled` - original mangled symbol name
      `originalDemangled` - demangled function signature generally used when generating comments
      `name` - demangled function name

- ## Method Details

  - ### setSignatureSourceType

    public void setSignatureSourceType(SourceType signatureSourceType)
    Set signature `SourceType` of `SourceType.ANALYSIS` which will be used when function signatures are applied to a program. Specifying `SourceType.DEFAULT` will prevent function return and parameters from being applied but will still apply calling convention name if specified.
    Parameters:
      `signatureSourceType` - signature source type

  - ### getSignatureSourceType

    public SourceType getSignatureSourceType()
    Get the signature source type which is used when applying the function signature to a program. A value of `SourceType.DEFAULT` indicates that function return and parameters should not be applied.
    Returns:
      signature source type

  - ### setReturnType

    public void setReturnType(DemangledDataType returnType)
    Sets the function return type.
    Parameters:
      `returnType` - the function return type

  - ### setCallingConvention

    public void setCallingConvention(String callingConvention)
    Sets the function calling convention. For example, "__cdecl".
    Parameters:
      `callingConvention` - the function calling convention

  - ### setTemplate

    public void setTemplate(DemangledTemplate template)

  - ### getTemplate

    public DemangledTemplate getTemplate()

  - ### setOverloadedOperator

    public void setOverloadedOperator(boolean isOverloadedOperator)
    Sets whether this demangled function represents an overloaded operator. For example, "operator+()".
    Parameters:
      `isOverloadedOperator` - true if overloaded operator

  - ### addParameter

    public void addParameter(DemangledDataType parameter)

  - ### getParameters

    public List<DemangledDataType> getParameters()

  - ### getReturnType

    public DemangledDataType getReturnType()
    Returns the return type or null, if unspecified.
    Returns:
      the return type or null, if unspecified

  - ### getCallingConvention

    public String getCallingConvention()
    Returns the calling convention or null, if unspecified.
    Returns:
      the calling convention or null, if unspecified

  - ### setTemplatedConstructorType

    public void setTemplatedConstructorType(String type)
    Special constructor where it has a templated type before the parameter list
    Parameters:
      `type` - the type

  - ### isTrailingConst

    public boolean isTrailingConst()

  - ### setTrailingConst

    public void setTrailingConst()

  - ### isTrailingVolatile

    public boolean isTrailingVolatile()

  - ### setTrailingVolatile

    public void setTrailingVolatile()

  - ### isTrailingPointer64

    public boolean isTrailingPointer64()

  - ### setTrailingPointer64

    public void setTrailingPointer64()

  - ### isTrailingUnaligned

    public boolean isTrailingUnaligned()

  - ### setTrailingUnaligned

    public void setTrailingUnaligned()

  - ### isTrailingRestrict

    public boolean isTrailingRestrict()

  - ### setTrailingRestrict

    public void setTrailingRestrict()

  - ### isTypeCast

    public boolean isTypeCast()

  - ### setTypeCast

    public void setTypeCast()

  - ### setThrowAttribute

    public void setThrowAttribute(String throwAttribute)

  - ### getSignature

    public String getSignature(boolean format)
    Description copied from class: `DemangledObject`
    Returns a complete signature for the demangled symbol.
    For example: "unsigned long foo" "unsigned char * ClassA::getFoo(float, short *)" "void * getBar(int **, MyStruct &)"
    Note: based on the underlying mangling scheme, the return type may or may not be specified in the signature.
    Specified by:
      `getSignature` in class `DemangledObject`
    Parameters:
      `format` - true if signature should be pretty printed
    Returns:
      a complete signature for the demangled symbol

  - ### addParameters

    protected void addParameters(StringBuilder buffer, boolean format)

  - ### getNamespaceName

    public String getNamespaceName()
    Description copied from interface: `Demangled`
    Returns this object's namespace name without the fully-qualified parent path. The value returned here may have had some special characters replaced, such as ' ' replaced with '_' and '::' replaced with '--'.
    Specified by:
      `getNamespaceName` in interface `Demangled`
    Overrides:
      `getNamespaceName` in class `DemangledObject`
    Returns:
      the name

  - ### getParameterString

    public String getParameterString()

  - ### isAlreadyDemangled

    protected boolean isAlreadyDemangled(Program program, Address address)
    Description copied from class: `DemangledObject`
    Determine if the symbol at address has already been demangled. While memory symbols check for presence of demangledName, external symbols simply check if demangled/alternate name has already been assigned.
    Overrides:
      `isAlreadyDemangled` in class `DemangledObject`
    Parameters:
      `program` - the program being modified
      `address` - address of demangled symbol
    Returns:
      true if symbol at address has already been demangled

  - ### applyTo

    public boolean applyTo(Program program, Address address, DemanglerOptions options, TaskMonitor monitor) throws Exception
    Description copied from class: `DemangledObject`
    Apply this demangled object detail to the specified program.
    NOTE: An open Program transaction must be established prior to invoking this method.
    Overrides:
      `applyTo` in class `DemangledObject`
    Parameters:
      `program` - program to which demangled data should be applied.
      `address` - address which corresponds to this demangled object
      `options` - options which control how demangled data is applied
      `monitor` - task monitor
    Returns:
      true if successfully applied, else false
    Throws:
      `Exception` - if an error occurs during the apply operation

  - ### isDefinedFunctionDataTypes

    protected boolean isDefinedFunctionDataTypes(Function func)
    check if the return/param data types were defined by better than analysis (user, import)
    Parameters:
      `func` - the function to check
    Returns:
      true if the parameters are not undefined, or are of a higher source type.

  - ### maybeCreateClassStructure

    protected Structure maybeCreateClassStructure(Program program, Function function, String convention)

  - ### createFunction

    protected Function createFunction(Program prog, Address addr, boolean doDisassembly, TaskMonitor monitor) throws DemangledException
    Throws:
      `DemangledException`