Add mangled type for auto template parameter to differentiate different types of template integer arguments, as MSVC does: https://godbolt.org/z/6FMZbF
Bug filed here: https://bugs.llvm.org/show_bug.cgi?id=45969 which is caused by missing mangled type for template integer argument.
I see you need an optional QualType here. Can you do this: QualType TemplateArgType = QualType()? I believe it will create a null QualType, which you can then check for with .isNull().
QualType is pointer-sized and is generally passed by value. I think it will help make the other call sites shorter, so they don't need to take the address of a local variable.