This is an archive of the discontinued LLVM Phabricator instance.

Delay trailing constraing evaluation so we short-circuit
AbandonedPublic

Authored by erichkeane on Oct 8 2021, 11:52 AM.

Details

Summary

As reported as a part of PR47508 (and somewhat confirmed in PR44833),
our behavior to fully instantiate the constraint before checking it is
not compliant with the standard.

I found that by delaying this checking until after the function-decl is
created and we CheckInstantiatedFunctionTemplateConstraints, we can take
advantage of its ability to partially instantiate as we short-circuit.

Diff Detail

Event Timeline

erichkeane requested review of this revision.Oct 8 2021, 11:52 AM
erichkeane created this revision.

The implementation seems to have tried checking this constraint 2x, and the first time required fully instantiating the constraint. The only condition in the check is PartialOrdering here: https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaTemplateDeduction.cpp#L3654

I wasn't able to get that trigger in any case where constraints mattered, and we don't fail any tests here, so I'm at a loss as to in which way this would not work. I'm hoping to get feedback on the direction if it is wrong.

So debugging a DIFFERENT issue, I found that this is likely incomplete since we likely have a similar problem in VisitCXXMethodDecl below this. I can extend the tests here/fix easily enough, if we decide this is the right way around this.

erichkeane abandoned this revision.Oct 8 2021, 1:42 PM

Looking into my other issue, I think I'm reasonably convinced this is wrong. I was looking into the PR44833 blocker for 'ranges' which hits the VisitCXXRecordMethod part, and removing THAT breaks the constraint entirely, so I think the answer is a better way of checking these constraints without having to fully instantiate them, not delaying until later