private boolean setSignature(Function func) throws InvalidInputException {

		// take on the signatures name if this is not a user defined symbol
		String name = signature.getName();
		setName(func, name);

		CompilerSpec compilerSpec = program.getCompilerSpec();
		String conventionName = getCallingConvention(func, compilerSpec);
		DataType returnDt = signature.getReturnType();
		ParameterDefinition[] args = signature.getArguments();

		ProgramBasedDataTypeManager targetDtm = func.getProgram().getDataTypeManager();
		DataTypeCleaner dtCleaner =
			applyEmptyComposites ? new DataTypeCleaner(targetDtm, true) : null;
		try {
			if (dtCleaner != null || conflictHandler != DataTypeConflictHandler.DEFAULT_HANDLER) {
				for (ParameterDefinition arg : args) {
					arg.setDataType(prepareDataType(arg.getDataType(), targetDtm, dtCleaner));
				}
				returnDt = prepareDataType(returnDt, targetDtm, dtCleaner);
			}

			ReturnParameterImpl returnParam = new ReturnParameterImpl(returnDt, program);
			List<Parameter> params =
				createParameters(compilerSpec, conventionName, args, returnParam);

			SymbolTable symbolTable = program.getSymbolTable();

			adjustParameterNamesToAvoidConflicts(symbolTable, func, params);

			func.updateFunction(conventionName, returnParam, params,
				FunctionUpdateType.DYNAMIC_STORAGE_FORMAL_PARAMS, false, source);
			func.setVarArgs(signature.hasVarArgs());

			// Only apply noreturn if signature has it set
			if (signature.hasNoReturn()) {
				func.setNoReturn(signature.hasNoReturn());
			}
		}
		catch (DuplicateNameException e) {
			// should not happen unless caused by a concurrent operation
			throw new InvalidInputException(
				"Parameter name conflict, likely due to concurrent operation");
		}
		finally {
			if (dtCleaner != null) {
				dtCleaner.close();
			}
		}

		updateStackPurgeSize(func, program);

		return true;
	}
Sets a function's signature in the program using the command details.
@param func the function
Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/ApplyFunctionSignatureCmd.java