Consider a system which is initially at a state $A$. Then it is moved to state $B$ absorbing $Q_h$ amount of heat from a heat reservoir at $T_h$. As the process is reversible so during heat exchange, the temperature of reservoir and the system will approximately be the same as finite temperature difference cause irreversibilities. Then if we come back to $A$ reversibly by the same path as of $A\to B$ but the direction being opposite, it dumps same heat $Q_h$ to a heat reservoir at temperature $T_h$.
So, $\oint_{A\to B}\frac{dq}{T}\;=\;\frac{1}{T_h}\oint_{A\to B}dq\;=\;\frac{Q_h}{T_h}$
Similarly, $\oint_{B\to A}\frac{dq}{T}\;=\;\frac{Q_h}{T_h}$
So $\frac{Q_h}{T_h}-\frac{Q_h}{T_h}=0$.
Hence, $\int_{A\to B\to A}\frac{dQ}{T}=0$.
Now suppose the system is at a state $A'$ such that the temperature of the system $T'$ (say, gas piston system) is significantly less than that of the temperature of reservoir $T_h$. If the sytem goes from $A'$ to $B'$ taking $Q_h$ amount of heat from the reservoir then the heat exchange occurs due to finite temperature difference between the system and the reservoir (source of irreversibility).
I have a doubt that in the case of irreversible process, what form does the $\int_{A'\to B'}\frac{dq}{T}$ takes?
As in that case temperature of the system changes abruptly from $T'$ to $T_h$ (final temperature due to heat transfer) and also the temperature in-between $T'$ and $T_h$ can not be even measured due to irreversible process, so I think $T$ can't be taken out from the integral.
I have a confusion that what form it will take. Please clarify the doubt.