private boolean createFunction(Namespace nameSpace, String funcName, Address entry,
			AddressSetView body, SourceType nameSource, Map<Function, AddressSetView> bodyChangeMap,
			TaskMonitor monitor) throws OverlappingFunctionException, InvalidInputException {

		Listing listing = program.getListing();

		// See if there is a codeunit at the function entry point
		// don't allow creation of a function if no CU there.
		CodeUnit cu = listing.getCodeUnitAt(entry);
		if (cu == null) {
			return false;
		}
		try {
			// check for a thunk first
			if (resolveThunk(entry, body, monitor)) {
				return true;
			}
			if (referringThunkAddresses != null) {
				for (Address addr : referringThunkAddresses) {
					if (body.contains(addr)) {
						Msg.error(this, "Failed to create function at " + entry +
							" since its body contains referring thunk at " + addr);
						return false;
					}
				}
			}
			newFunc = listing.createFunction(funcName, nameSpace, entry, body, nameSource);
		}
		catch (InvalidInputException | OverlappingFunctionException e) {
			throw e;
		}

		return true;
	}
create the function, undoing any changes to other functions bodies if the function creation fails

@param nameSpace - functions namespace
@param funcName - functions name
@param entry - entry point of function
@param body - body of function
@param nameSource - source of the name
@param bodyChangeMap - change map to restore other affected functions bodies if this fails
@param monitor task monitor
@return true if function created
@throws OverlappingFunctionException if functions overlaps with existing function
@throws InvalidInputException if function name has bad chars
Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/CreateFunctionCmd.java