Protecting regulator from alternate power supply
Diode D2 protects the regulator from reverse current spoiling the LDO.
The diode can be either schottky or normal diodes.

The schottky will be costlier but conducts sooner when the output voltage is higher than the input voltage (during shutdown or when input voltage is not present, but the output capacitors still have charge stored)

The topology of the regulator determines whether the safety protection is needed or not

Refer to the datasheet of the regulator for both topology and recommendations example below)