Check if the symbol exists before checking its visibility in isEntityNameVisible.

Should fix #1348.