12. Let the function $f(x)$ be a differentiable function defined on the interval $(-\infty, 0)$, with its derivative being $f^{\prime}(x)$, and $2 f(x) + x f^{\prime}(x) > x^{2}$. Then
$$
(x+2017)^{2} f(x+2017)-f(-1)>0
$$

The solution set is $\qquad$ .
12. $(-\infty,-2018)$.

Transform the original inequality into
$$
(x+2017)^{2} f(x+2017)>(-1)^{2} f(-1) \text {. }
$$

Construct $F(x)=x^{2} f(x)$, so that equation (1) becomes
$$
F(x+2017)>F(-1) \text {. }
$$

Given the condition $2 f(x)+x f^{\prime}(x)>x^{2}$, multiply both sides by $x (x<0)$, we get
$$
F^{\prime}(x)=2 x f(x)+x^{2} f^{\prime}(x)<x^{3}<0 \text {. }
$$

Thus, $F(x)$ is a decreasing function on the interval $(-\infty, 0)$.
From equation (2), we have
$$
x+2017<-1 \Rightarrow x<-2018 \text {. }
$$

Therefore, the solution set of the inequality is $(-\infty,-2018)$.