First you will need to get the permissions for the user (XenForo_Visitor::getInstance()->toArray()["permissions"]), then use XenForo_Permissions::hasPermission(permissionArray, permissionGroup, permissionID) to check whether the user has permissions. Additionally, a shortcut XenForo_Visitor::getInstance()->hasPermission(permissionGroup, permissionID) is also available.
I highly recommend you to dig around XF's code to see it in action.
In this case I'm checking to see if the user has the permission to view soft deleted posts and threads.
// get permissions
$permissions = XenForo_Visitor::getInstance()->getPermissions();
// get viewDeleted permission
$viewDeleted = XenForo_Permission::hasPermission($permissions, "forum", "viewDeleted");
// if viewDeleted is false display no permission response