Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang] Choose non-templated ctor as deduction guide unambiguously #66487

Merged
merged 8 commits into from
Oct 4, 2023

Conversation

HoBoIs
Copy link
Contributor

@HoBoIs HoBoIs commented Sep 15, 2023

If there are two guides, one of them generated from a non-templated constructor
and the other from a templated constructor, then the standard gives priority to
the first. Clang detected ambiguity before, now the correct guide is chosen.
The correct behavior is described in this paper: http://wg21.link/P0620R0

Example for the bug: http://godbolt.org/z/ee3e9qG78

As an unrelated minor change, fix the issue #64020,
which could've led to incorrect behavior if further development inserted code after a call to
isAddressSpaceSubsetOf(), which specified the two parameters in the wrong order.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Sep 15, 2023
If there are two guides, one of them generated from a non-templated constructor
and the other from a templated constructor, then the standard gives priority to
the first. Clang detected ambiguity before, now the correct guide is chosen.

As an unrelated minor change, fix the issue llvm#64020, which could've led to
incorrect behavior if further development inserted code after a call to
isAddressSpaceSubsetOf() which specified the two parameters in the wrong order.
@HoBoIs HoBoIs marked this pull request as ready for review September 15, 2023 12:41
@HoBoIs
Copy link
Contributor Author

HoBoIs commented Sep 15, 2023

@zygoloid @yuanfang-chen @faisalv @OleStrohm
Could you review my commit and/or suggest more appropriate reviewers?
Thanks in advance!

@cor3ntin
Copy link
Contributor

cor3ntin commented Oct 2, 2023

@erichkeane

Copy link
Collaborator

@erichkeane erichkeane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems right to me, however we need to do 2 things:

1- This needs a release note.

2- We need to track down when this changed in the standard, and why. If it was a DR, we need to do make sure we update that we've implemented that DR. If it was a normal paper, we need to figure out which versions of the standard it applies to and do THAT correctly. Either way, we'd have to update the paper tracking doc.

@shafik
Copy link
Collaborator

shafik commented Oct 2, 2023

I added a comment in the issue her: #67959 (comment)

Please make sure to add references to the standard in appropriate places in this PR.

@HoBoIs
Copy link
Contributor Author

HoBoIs commented Oct 3, 2023

The paper where this came from is: https://wg21.link/P0620R0. most of this paper was already implemented.
Where is the paper tracking doc I need to update? https://clang.llvm.org/cxx_status.html claims this paper is implemented.
Sorry if the following questions are trivial, I'm new to this.
In the release note should I put it under Bug Fixes to C++ Support or Bug Fixes in This Version?

Where should I reference the standard in the PR? In the Description?

@HoBoIs
Copy link
Contributor Author

HoBoIs commented Oct 3, 2023

Deduction guides were added in C++17, and This paper is also in C++17, so I don't think we need to check for versions in the code (I don't create any deduction guides I just use them so before C++17 my code is never used).

@erichkeane
Copy link
Collaborator

The paper where this came from is: https://wg21.link/P0620R0. most of this paper was already implemented. Where is the paper tracking doc I need to update? https://clang.llvm.org/cxx_status.html claims this paper is implemented. Sorry if the following questions are trivial, I'm new to this. In the release note should I put it under Bug Fixes to C++ Support or Bug Fixes in This Version?

Where should I reference the standard in the PR? In the Description?

cxx_status.html is the paper tracking doc, if we claim it was already implemented than there is nothing to do there.

For release notes, ForC++Support seems like the right area for me.

I've confirmed that P06020R0 is in N4659 (Final draft for C++17), so you're right, there is no version checking we have to do. Thanks for doing the leg work here!

Copy link
Collaborator

@erichkeane erichkeane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just need a period after the note, otherwise LGTM!

Copy link
Collaborator

@shafik shafik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the follow-up work.

LGTM

@HoBoIs
Copy link
Contributor Author

HoBoIs commented Oct 4, 2023

@erichkeane @shafik I don't have write access. Could you merge if there is nothing to be done?

@HoBoIs HoBoIs requested a review from whisperity October 4, 2023 15:48
@whisperity whisperity removed their request for review October 4, 2023 15:59
Copy link
Member

@whisperity whisperity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with previous discussion. I will do the commit... On the UI... 🙂

Copy link
Member

@whisperity whisperity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL there is no way to resign a review here like there was on Phab...

@whisperity whisperity changed the title Bugfix for chosing the correct deduction guide [clang] Choose non-templated ctor as deduction guide unambiguously Oct 4, 2023
@erichkeane erichkeane merged commit 66c1916 into llvm:main Oct 4, 2023
3 checks passed
@erichkeane
Copy link
Collaborator

I had permissions, so I squash/merged.

@whisperity
Copy link
Member

whisperity commented Oct 4, 2023

It looks like the authorship metadata was set up incorrectly in the commits, note the typo: @gmial.com. I was in the process of fixing the things locally.

@erichkeane
Copy link
Collaborator

Ah, I see, apologies. I thought you meant the resign/etc complaint meant you couldn't commit through the UI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants