[PATCH] D119544: Deferred Concept Instantiation Implementation

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 20 10:06:38 PDT 2022


erichkeane planned changes to this revision.
erichkeane added a comment.

If anyone can help here, it would be vastly appreciated... I'm simply out of ideas on how to make this work.



================
Comment at: clang/lib/Sema/SemaConcept.cpp:496
+llvm::Optional<MultiLevelTemplateArgumentList>
+Sema::SetupConstraintCheckingTemplateArgumentsAndScope(
+    FunctionDecl *FD, llvm::Optional<ArrayRef<TemplateArgument>> TemplateArgs,
----------------
Ugh... it looks like all of this might just be 'wrong', and I have no idea how to fix it.  @rsmith  ANY advise you could give here would be unbelievably appreciated.

Basically, anything involving variables besides ParmVarDecls seems to be broken in some way:



```
template<typename T>
void foo(T x) {

// This asserts because 'y' is not in the Scope's "FindInstantiationOf"
[y = x]() requires(constraint<decltype(y)>){}


// This asserts because 'Local' is not in the Scope's "FindInstantiationOf"
T Local;
[]() requires(constraint<decltype(Local)>){}

// This gives a "stack nearly exhausted" error, followed by a bunch of "while checking constraint satisfaction for function 'foo' required here'", THEN crashes checking Constraints due to MLTAL being empty at one point (or perhaps just corrupt?). BUT the stack is only 40 deep at the crash.
struct S {
int local;
void foo() requires(constraint<decltype(local)>){}
}
```

FURTHER, this is also broken by this patch:
```
template<typename T>
struct S {
T t;
void foo() requires(constraint<decltype(t)>){}
};
void use() {
S<int> s;
s.foo();
```
With "constraints not satisfied" "because substituted constraint expression is ill-formed: 'S::t' is not a member of 'class S<int>'"

Curiously, it works if 'foo' is itself a template.




I can't help but think that this attempt to re-generate the instantiation is just BROKEN, and I have no idea how to fix it, or what the right approach is.  BUT I cannot help but think that I'm doing the 'wrong thing'.



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

https://reviews.llvm.org/D119544



More information about the cfe-commits mailing list