private void upgradeFunction(OldFunctionDataDB oldFunc) {

		Address entryPt = oldFunc.getEntryPoint();
		SymbolTable symTable = program.getSymbolTable();
		Symbol s = symTable.getPrimarySymbol(entryPt);
		String baseName = null;
		if (s != null && s.getSource() != SourceType.DEFAULT) {
			baseName = s.getName();
			s.delete();
		}
		else {
			baseName = SymbolUtilities.getDefaultFunctionName(entryPt);
		}
		String name = baseName;
		FunctionDB func = null;
		try {
			func = (FunctionDB) program.getFunctionManager().createFunction(name, entryPt,
				oldFunc.getBody(), SourceType.USER_DEFINED);
			func.setCustomVariableStorage(true);
			func.setComment(oldFunc.getComment());
			func.setRepeatableComment(oldFunc.getRepeatableComment());
			func.setReturnType(oldFunc.getReturnType(), SourceType.ANALYSIS);

			func.setValidationEnabled(false); // limit use of compiler spec during upgrade

			func.setStackPurgeSize(oldFunc.getStackDepthChange());
			StackFrame oldFrame = oldFunc.getStackFrame();
			StackFrame frame = func.getStackFrame();
			frame.setLocalSize(oldFrame.getLocalSize());
			frame.setReturnAddressOffset(oldFrame.getReturnAddressOffset());

			// don't worry about parameter offset if bad, function will compute it.
//			try {
//				frame.setParameterOffset(oldFrame.getParameterOffset());
//			}
//			catch (IllegalArgumentException e) {
//			}

			Parameter[] oldParms = oldFunc.getParameters();
			for (Parameter var : oldParms) {
				if (var.getVariableStorage().isBadStorage()) {
					Msg.error(this, "Discarded invalid parameter (" + func.getName() + " at " +
						func.getEntryPoint() + ")");
					continue;
				}
				boolean done = false;
				while (!done) {
					try {
						func.addParameter(var, SourceType.USER_DEFINED);
						done = true;
					}
					catch (DuplicateNameException e) {
						try {
							var.setName(var.getName() + ".dup", SourceType.USER_DEFINED);
						}
						catch (DuplicateNameException e1) {
						}
					}
				}
			}

			Variable[] oldLocalVars = oldFrame.getLocals();
			for (Variable var : oldLocalVars) {
				boolean done = false;
				while (!done) {
					try {
						func.addLocalVariable(var, SourceType.USER_DEFINED);
						done = true;
					}
					catch (DuplicateNameException e) {
						try {
							var.setName(var.getName() + ".dup", SourceType.USER_DEFINED);
						}
						catch (DuplicateNameException e1) {
						}
					}
				}
			}
		}
		catch (OverlappingFunctionException e) {
			throw new AssertException(e);
		}
		catch (InvalidInputException e) {
			throw new AssertException(e);
		}
		finally {
			if (func != null) {
				func.setValidationEnabled(true);
			}
		}
	}
Copy old function into programs current function manager.
@param function existing function
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/oldfunction/OldFunctionManager.java