设 $f(x)=\left\{\begin{array}{ll}x^2, & x \leq 0 \\ x^2+x, & x>0\end{array}\right.$ ,则
A. $f(-x)=\left\{\begin{array}{cc}-x^2, & x \leq 0 \\ -\left(x^2+x\right), & x>0\end{array}\right.$
B. $f(-x)= \begin{cases}-\left(x^2+x\right), & x < 0 \\ -x^2, & x \geq 0\end{cases}$
C. $f(-x)= \begin{cases}x^2, & x \leq 0 \\ x^2-x, & x>0\end{cases}$
D. $f(-x)= \begin{cases}x^2-x, & x < 0 \\ x^2, & x \geq 0\end{cases}$