There was a missing isInvalid() check leading to an attempt to instantiate template with an empty instantiation stack. Differential Revision: https://reviews.llvm.org/D100675