The current implementation to judge the similarity of TypeConstraint in ASTContext::isSameTemplateParameter is problematic, it couldn't handle the following case:
C++ template <__integer_like _Tp, C<_Tp> Sentinel> constexpr _Tp operator()(_Tp &&__t, Sentinel &&last) const { return __t; }
When we see 2 such declarations from different modules, we would judge their similarity by ASTContext::isSame* methods. But problems come for the TypeConstraint. Originally, we would profile each argument one by one. But it is not right. Since the profiling result of _Tp would refer to two different template type declarations. So it would get different results. It is right since the _Tp in different modules refers to different declarations indeed. So the same declaration in different modules would meet incorrect our-checking results.
It is not the thing we want. We want to know if the TypeConstraint have the same expression.
Do we even want to compare the template argument sizes here?
Would comparing only getImmediatelyDeclaredConstraint produce the same results?
If that's a performance optimization, we are probably better off moving it inside isSameConstraintExpr.