Speaking more of St. Thomas Aquinas’ opinion, which is not dogma of the Church or binding, keep in mind he never finished the Summa Theologica. He did hold that children who died in the womb would be resurrected.
Reply to Objection 5. We are born again by the grace of Christ whereby it came about that He took our nature, since it is by this that we are conformed to Him in natural things. Hence those who die in their mother’s womb, although they are not born again by receiving grace, will nevertheless rise again on account of the conformity of their nature with Him, which conformity they acquired by attaining to the perfection of the human species.
The Appendix, Question One, seems to address this more fully.
But [unbaptized] children were never adapted to possess eternal life, since neither was this due to them by virtue of their natural principles, for it surpasses the entire faculty of nature, nor could they perform acts of their own whereby to obtain so great a good . Hence they will nowise grieve for being deprived of the divine vision; nay, rather will they rejoice for that they will have a large share of God’s goodness and their own natural perfections. Nor can it be said that they were adapted to obtain eternal life, not indeed by their own action, but by the actions of others around them, since they could be baptized by others, like other children of the same condition who have been baptized and obtained eternal life: for this is of superabundant grace that one should be rewarded without any act of one’s own. Wherefore the lack of such a grace will not cause sorrow in children who die without Baptism, any more than the lack of many graces accorded to others of the same condition makes a wise man to grieve.
…
Reply to Objection 5. Although unbaptized children are separated from God as regards the union of glory, they are not utterly separated from Him: in fact they are united to Him by their share of natural goods, and so will also be able to rejoice in Him by their natural knowledge and love.
http://www.newadvent.org/summa/6001.htm
There is a lot more text to it than that, but I believe that captures St. Thomas Aquinas’ view.