[clang] [Concepts] Avoid substituting into constraints for invalid TemplateDecls (PR #75697)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 18 21:31:12 PST 2023


================
@@ -353,6 +353,10 @@ static ExprResult calculateConstraintSatisfaction(
           if (Inst.isInvalid())
             return ExprError();
 
+          // An empty expression for substitution failure messages.
+          if (Template && Template->isInvalidDecl())
+            return ExprEmpty();
----------------
zyn0217 wrote:

My initial thought was to emit substitution details (`[T = double]` here). But now I feel like this is puzzling since we're now giving "constraints not satisfied" rather than "constraint must be of type 'bool'" in the case.

I'm a bit torn here: either we lose substitution details or produce inaccurate error-recovery messages. The latter matches what we're doing now in assertion-free builds. https://cpp1.godbolt.org/z/3KzPEYhn3

https://github.com/llvm/llvm-project/pull/75697


More information about the cfe-commits mailing list