In VisitNonTypeTemplateParamDecl, before SubstExpr with the default argument,
we should create a ConstantEvaluated ExpressionEvaluationContext. Without this,
it is possible to use a PotentiallyEvaluated ExpressionEvaluationContext; and
MaybeODRUseExprs will not be cleared when popping the context, causing
assertion failure.
This is similar to how we handle the context before SubstExpr with the
default argument, in SubstDefaultTemplateArgument.
Part of PR13986.
rdar://24480205
Looks reasonable to me - since it is consistent with the other changes I had made. But somewhat orthogonal to your fix, I wouldn't mind Richard commenting on why constant expression evaluation does not have IsPotentiallyEvaluatedContext return false (and avoid adding an entry to MaybeODRUse)
Also, just as SubstituteDefaultTemplateArgument does, Perhaps we should add an InstantiatingTemplate on the stack that marks this as a substitution into default arguments. It would be nice if we could refactor both into a call to the same function (i.e SubstittueDefaultTempalteArgument) - but looking at the code for it, that would be a little tricky.
My 2 cents.