private Parameter getReturnParameter(Function toFunction, ToolOptions markupOptions,
			boolean forceApply, boolean useCustomStorage) throws InvalidInputException {
		Parameter returnParam = toFunction.getReturn();
		ParameterDataTypeChoices returnTypeChoice =
			markupOptions.getEnum(FUNCTION_RETURN_TYPE, DEFAULT_OPTION_FOR_FUNCTION_RETURN_TYPE);
		boolean onlyReplaceUndefineds =
			returnTypeChoice == ParameterDataTypeChoices.REPLACE_UNDEFINED_DATA_TYPES_ONLY;
		if (returnTypeChoice == ParameterDataTypeChoices.EXCLUDE) {
			return returnParam; // Not replacing return type.
		}
		DataType toReturnType = toFunction.getReturnType();
		DataType fromReturnType = returnInfo.dataType;
		boolean isFromDefault = fromReturnType == DataType.DEFAULT;
		boolean isToDefault = toReturnType == DataType.DEFAULT;
		boolean isToUndefined = Undefined.isUndefined(toReturnType);
		if (!forceApply && onlyReplaceUndefineds) {
			if (!isToDefault && !isToUndefined) {
				return returnParam; // can't do it because we should only replace undefined data types.
			}
		}
		if (!forceApply && isFromDefault) {
			return returnParam; // do nothing since default data type is lowest priority.
		}

		DataType returnType = (forceApply) ? fromReturnType
				: getHighestPriorityDataType(fromReturnType, toReturnType, onlyReplaceUndefineds);

		VariableStorage returnVariableStorage = VariableStorage.UNASSIGNED_STORAGE;
		if (useCustomStorage && returnInfo.storage != null) {
			returnVariableStorage =
				VariableStorage.deserialize(toFunction.getProgram(), returnInfo.storage);
		}
		return new ReturnParameterImpl(returnType, returnVariableStorage, toFunction.getProgram());
	}
@param toFunction the function whose signature we are setting.
@param markupOptions the options indicate what parts of the function signature to apply.
@param forceApply true indicates that the function signature should be applied even if the
function signature, return type, parameter data type or parameter name options are set
to "do not apply".
@throws VersionTrackingApplyException if all desired parts of the function signature couldn't be applied.
Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/stringable/FunctionSignatureStringable.java