I see the differential operator both with upright and italic d in different books/articles. So I'm curious about $$ \int x^2 \, dx \quad \text{vs.} \quad \int x^2\, \mathrm{d}x,$$ and $$\frac{d}{dx}f(x) \quad \text{vs.} \quad \frac{\mathrm{d}}{\mathrm{d}x}f(x).$$
Is there a convention which of these notations should be used?
Quick answer: there is a standard to follow.
Longer answer: while physicists write differential operators in upright fonts (because they follow the standards), mathematicians tend to typeset differential operators as variables (because we are lazy). I am joking, but it should be clear that $dx$ is not $d \cdot x$, and that $d$ is essentially an operator: therefore it is always preferable to write $\mathrm{d}x$ instead. Many journals change $dx$ to $\mathrm{d}x$ after accepting a manuscript for publications.