Consider the SDE $$ dS(t) = rS(t)dt + \sigma dW(t). $$ To solve this, I let $f(t,x) = xe^{-rt}$, so $\frac{\partial f}{\partial t} = -rxe^{-rt}$, $\frac{\partial f}{\partial x} = e^{-rt}$ and $\frac{\partial^2 f}{\partial x^2} = 0$. Using Ito's lemma I get \begin{align*} df(t,S(t)) & = -rS(t)e^{-rt}dt + e^{-rt}dS(t) \\ & = -rS(t)e^{-rt}dt + e^{-rt}[rS(t)dt + \sigma dW(t)] \\ & = e^{-rt}\sigma dW(t). \end{align*} Then \begin{align*} f(t,S(t)) & = f(0,S(0)) + \sigma \int_0^t e^{-rs} dW(s) \\ & = S(0) + \sigma \int_0^t e^{-rs} dW(s) \\ & = S(t)e^{-rt} \\ & \implies S(t) = S(0)e^{rt} + \sigma e^{rt} \int_0^t e^{-rs} dW(s). \end{align*}
I now want to check my solution by differentiating $S(t)$ and verifying I obtain the original SDE, but I'm unsure how to treat the stochastic integral term when using Ito's lemma. Specifically, I'd like to write a "dummy" function $f$ as I did for the SDE (I find this makes applying Ito's lemma more clear), but my best guess is $f(t,x) = S(0)e^{rt} + \sigma e^{rt} \int_0^t e^{-rs} dx$. It is not clear to me what $\frac{\partial f}{\partial t}$, $\frac{\partial f}{\partial x}$ or $\frac{\partial^2 f}{\partial x^2}$ should be. Thanks!
Note that the random variable $\int_{0}^{t}e^{-rs}\text dW_r$ is not a function of solely $W_r$ but, rather, depends on the entire process $\{W_r\}_{0\leqslant r\leqslant t}$. This is why your choice of function, $$f(t,x) = S_0e^{rt} + \sigma e^{rt} \int_0^t e^{-rs} \text dx ,$$ is not a well-defined $C^{1,2}$ function (and hence, your intended version of Ito's lemma cannot be applied). Instead, we could try
where $X_t = \int_{0}^{t}e^{-rs}\text dW_s$. Now we can apply your intended form of Ito's lemma:
Notice, from (1), that the non-zero partial derivatives are $\displaystyle \frac{\partial f}{\partial t} = rf\ $ and $\ \displaystyle \frac{\partial f}{\partial x} = \sigma e^{rt}$. Also, by definition of stochastic differential equations, $\text dX_t = e^{-rt}\text dW_t$. Therefore, using these in (2) implies