This is an archive of the discontinued LLVM Phabricator instance.

[Clang] use non-instantiated function declaration for constraints partial ordering
ClosedPublic

Authored by ychen on Oct 22 2022, 9:30 PM.

Details

Summary

Per wordings in

constraints partial ordering should use the unsubstituted template
parameters of the constrained entity, not the instantiated entity.

Fix #56154

Diff Detail

Event Timeline

ychen created this revision.Oct 22 2022, 9:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 22 2022, 9:30 PM
ychen requested review of this revision.Oct 22 2022, 9:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 22 2022, 9:30 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
ychen added inline comments.Oct 22 2022, 9:42 PM
clang/test/CXX/over/over.match/over.match.best/p2.cpp
10

Remove this case because it compiles by accident. https://eel.is/c++draft/over.match#best.general-2.6 take precedence over https://eel.is/c++draft/over.match#best.general-2.8.

ychen updated this revision to Diff 469963.Oct 22 2022, 10:43 PM
  • add a release note.
royjacobson accepted this revision.Oct 23 2022, 12:17 PM

LGTM, thanks for picking it up! I wonder how much effect this has on compilation times given that SubsumptionCache caches subsumption by the Decl * pair...

One Q - do you think that adding an assert to IsAtLeastAsConstrained to not accept 'instantiated' functions/structs again is possible somehow?

This revision is now accepted and ready to land.Oct 23 2022, 12:17 PM
erichkeane accepted this revision.Oct 24 2022, 6:18 AM
erichkeane added inline comments.
clang/test/CXX/over/over.match/over.match.best/p2.cpp
10

Could you instead replace it with a better comment + a 'fixme' or something if we need to fix it in the future? I don't want to lose the test.

mizvekov accepted this revision.Oct 24 2022, 6:24 AM

LGTM as well!

ychen updated this revision to Diff 470374.EditedOct 24 2022, 10:35 PM
ychen marked an inline comment as done.
  • do the same when 1. taking the address of a non-template function (with a test) 2. computing SMF eligibility (unfortunately it's hard to compose a test, suggestions are appreciated).
  • restore the removed test case

LGTM, thanks for picking it up! I wonder how much effect this has on compilation times given that SubsumptionCache caches subsumption by the Decl * pair...

It seems neutral https://llvm-compile-time-tracker.com/compare.php?from=0ec6373e29f4c129490abef9d38015e9ec0b10ce&to=060fafdcf819578b89505c73d3235e44f56caa60&stat=instructions

One Q - do you think that adding an assert to IsAtLeastAsConstrained to not accept 'instantiated' functions/structs again is possible somehow?

Great idea. For sure. I added the assertion and found two more places needing updates.

ychen retitled this revision from [Clang] use non-template function declaration for constraints partial ordering to [Clang] use non-instantiated function declaration for constraints partial ordering.Oct 24 2022, 10:36 PM
ychen added inline comments.Oct 24 2022, 10:38 PM
clang/test/CXX/over/over.match/over.match.best/p2.cpp
10

Sure. I restored the test.

ychen updated this revision to Diff 470546.Oct 25 2022, 10:14 AM
  • rebase
chapuni added inline comments.
clang/lib/Sema/SemaConcept.cpp
1310

IsExpectedEntity, FD2, (and possibly FD1) are used only in assert.