For the assertion, you can probably teach addInstantiatedParametersToScope() to cope with getNumArgumentsInExpansion() returning an empty optional: in that case, use Scope.InstantiatedLocal rather than Scope.MakeInstantiatedLocalArgPack/Scope.InstantiatedLocalPackArg. http://llvm-reviews.chandlerc.com/D1784