public static Function getFunction(Program program, ClangFuncNameToken token) {

		ClangNode parent = token.Parent();
		if (parent instanceof ClangFuncProto) {
			// decompiled function
			ClangFunction clangFunction = parent.getClangFunction();
			if (clangFunction != null) {
				return clangFunction.getHighFunction().getFunction();
			}
		}

		if (parent instanceof ClangStatement) {
			// sub-function call
			PcodeOp pcodeOp = token.getPcodeOp();
			if (pcodeOp != null && pcodeOp.getOpcode() == PcodeOp.CALL) {
				Address functionAddr = pcodeOp.getInput(0).getAddress();
				return program.getFunctionManager().getReferencedFunction(functionAddr);
			}
		}
		return null; // unhandled case
	}
Returns the function represented by the given token.  This will be either the
decompiled function or a function referenced within the decompiled function.

@param program the program
@param token the token
@return the function
Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerUtils.java