This paper presents a robust sharp-interface immersed boundary method for simulating inviscid compressible flows over stationary and moving bodies. The flow field is governed by Euler equations, which are solved by using the open source library OpenFOAM. Discontinuities such as those introduced by shock waves are captured by using Kurganov and Tadmor divergence scheme. Wall-slip boundary conditions are enforced at the boundary of body through reconstructing flow variables at some ghost points. Their values are obtained indirectly by interpolating from their mirror points. A bilinear interpolation is employed to determine the variables at the mirror points from boundary conditions and flow conditions around the boundary. To validate the efficiency and accuracy of this method for simulation of high-speed inviscid compressible flows, four cases have been simulated as follows: supersonic flow over a 15\(^\circ\) angle wedge, transonic flow past a stationary airfoil, a piston moving with supersonic velocity in a shock tube and a rigid circular cylinder lift-off from a flat surface triggered by a shock wave. Compared to the exact analytical solutions or the results in literature, good agreement can be achieved.