[PATCH] D119544: Deferred Concept Instantiation Implementation

Chuanqi Xu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 31 20:17:11 PDT 2022


ChuanqiXu added a comment.

BTW, it looks like the patch needs to rebase with main so that other people could play it self if interested.



================
Comment at: clang/lib/Sema/SemaConcept.cpp:489
+  // Attn Reviewers: we need to do this for the function constraints for
+  // comparison of constraints to work, but do we also need to do it for
+  // CheckInstantiatedFunctionConstraints?  That one is more difficult, but we
----------------
erichkeane wrote:
> ChuanqiXu wrote:
> > Would you mind to elaborate for the issue "function constraints for comparison of constraints to work" more? Maybe it is said in previous messages, but the history is hard to follow...
> Yep, this one is difficult :/  Basically, when we instantiate the constraints at 'checking' time, if the function is NOT a template, we call `CheckFunctionConstraints`. When we go to check the 'subsumption' type things with a fully instantiated version, they fail if they are dependent (as it is expected that way).  See the `setTrailingRequiresClause` here.
> 
> HOWEVER, it seems we ALWAYS pick constraints off the primary template, rather than the 'stored' version of the constraint on the current declaration.  I tried to do something similar here for those cases, but 1: it had no effect seemingly, and 2: it ended up getting complicated in many cases (as figuring out the relationship between the constraints in the two nodes was difficult/near impossible).
> 
> I opted to not do it, and I don't THINK it needs to happen over there, but I wanted to point out that I was skipping it in case reviewers had a better idea.
> 
> 
Let me ask some questions to get in consensus for the problem:

> Basically, when we instantiate the constraints at 'checking' time, if the function is NOT a template, we call CheckFunctionConstraints.

I think the function who contains a trailing require clause should be template one. Do you want to say independent ? Or do you refer the following case?

```C++
template<typename T> struct A {
  static void f(int) requires xxxx;
};
```

And the related question would be what's the cases that `CheckFunctionConstraints` would be called and what's the cases that `CheckinstantiatedFunctionTemplateConstraints` would be called?

> When we go to check the 'subsumption' type things with a fully instantiated version, they fail if they are dependent (as it is expected that way).

If it is fully instantiated, how could it be dependent?

> HOWEVER, it seems we ALWAYS pick constraints off the primary template, rather than the 'stored' version of the constraint on the current declaration.

1. What is `we`? I mean what's the function would pick up the constraints from the primary template.
2. Does `the stored version of the constraint` means the trailing require clause of FD? Would it be the original one or `Converted[0]`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119544/new/

https://reviews.llvm.org/D119544



More information about the cfe-commits mailing list