This is an archive of the discontinued LLVM Phabricator instance.

[clang] Compare constraints before diagnosing mismatched ref qualifiers (GH58962)
ClosedPublic

Authored by royjacobson on Nov 26 2022, 3:01 PM.

Details

Summary

As noticed in GH58962, we should only diagnose illegal overloads of member functions
when the ref qualifiers don't match if the trailing constraints are the same.

The fix is to move the existing constraints check earlier in Sema::IsOverload.

Closes https://github.com/llvm/llvm-project/issues/58962

Diff Detail

Event Timeline

royjacobson created this revision.Nov 26 2022, 3:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 26 2022, 3:01 PM
royjacobson requested review of this revision.Nov 26 2022, 3:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 26 2022, 3:01 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
cor3ntin added inline comments.
clang/lib/Sema/SemaOverload.cpp
1324

I know it's preexisting but, I'm not sure that comment adds anything.
If we want to keep it, "requires clauses are different, - these are overloads."

I can't find any example that breaks and needs the AreConstraintExpressionsEqual, so feel free to do it if you'd like.

clang/lib/Sema/SemaOverload.cpp
1324

The comment is definitely low quality here, I would probably prefer a little more elaboration if we're going to keep it.

1327

I did some work that extracted these at one point, and it matters because we have to 'fix' the depths sometimes. I suspect it wont' really come up here, since we have already checked that these are both the same 'type' of template parameter by now? But at some point (perhaps not in this patch?) we might find calling Sema::AreConstraintExpressionsEqual necessary.

erichkeane accepted this revision.Nov 28 2022, 6:09 AM

Feel free to clarify the comment yourself.

This revision is now accepted and ready to land.Nov 28 2022, 6:09 AM

Remove redundant comments, use Sema::AreConstraintExpressionsEqual instead.

royjacobson marked 3 inline comments as done.Nov 29 2022, 3:32 AM
royjacobson added inline comments.
clang/lib/Sema/SemaOverload.cpp
1324

removed it.

1327

Went for Sema::AreConstraintExpressionsEqual to reduce code duplication. Only drawback is calling CalculateTemplateDepthForConstraints unnecessarily which seems reasonable to me.

This revision was landed with ongoing or failed builds.Nov 29 2022, 4:57 AM
This revision was automatically updated to reflect the committed changes.
royjacobson marked 2 inline comments as done.