In addition to having and integral type the expression needs to be evaluatable.
I'm not too happy with how GetInt function looks... one idea would be to return a bool and take APInt as an output parameter, in that case the function would look something like this:
bool GetInt(const TSTiterator &Iter, Expr *ArgExpr, llvm::APInt &Int) { // Default, value-depenedent expressions require fetching // from the desugared TemplateArgument if (Iter.isEnd() && ArgExpr->isValueDependent()) { switch (Iter.getDesugar().getKind()) { case TemplateArgument::Integral: Int = Iter.getDesugar().getAsIntegral(); case TemplateArgument::Expression: ArgExpr = Iter.getDesugar().getAsExpr(); Int = ArgExpr->EvaluateKnownConstInt(Context); default: llvm_unreachable("Unexpected template argument kind"); } return true; } else if (ArgExpr->isEvaluatable(Context)) { Int = ArgExpr->EvaluateKnownConstInt(Context); return true; } return false; }
This needs another case here, (HasFromInt || HasToInt). Use same SetNode and SetKind as above, but use SetSame(false).