Fix recursive error for constraints depending on itself incorrectly
authorErich Keane <erich.keane@intel.com>
Fri, 27 Jan 2023 19:06:07 +0000 (11:06 -0800)
committerErich Keane <erich.keane@intel.com>
Fri, 27 Jan 2023 19:11:53 +0000 (11:11 -0800)
commit42667563721e139a93ab886119ea2780ebc3fecc
treec3b942724432a48bb034f9bb217112b1ebb6e97a
parent9f307a02bebf9029079f3d13c8b0ccd3b09c5241
Fix recursive error for constraints depending on itself incorrectly

Fixes: #60323

https://github.com/llvm/llvm-project/issues/60323

The problem is that we are profiling the 'Expr' components directly,
however when they contain an unresolved lookup, those canonicalize
identically.  The result was the two versions of calls to 'go' were
canonicalized identically.

This patch fixes this by ensuring we consider the declaration the
constraint is attached to, when possible.  When not, we skip the
diagnostic.

The result is that we are relaxing our diagnostic in some cases (Of
which I couldn't come up with a reproducer), such that we might see
overflows when evaluating constraints that depend on themselves in a way
that they are not attached to a declaration directly, such as if
they are nested requirements, though the hope is this won't be a
problem, since the 'parent' named constraint would catch this.  I'm
hopeful that the 'worst case' is that we catch recursion 'later' in the
process, instead of immediately.
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaConcept.cpp
clang/test/SemaTemplate/concepts-recursive-inst.cpp