-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[EquivClasses] Fix signature of copy-assignment operator #130140
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
Conversation
@llvm/pr-subscribers-llvm-adt Author: Ramkumar Ramachandra (artagnon) ChangesFull diff: https://github.com/llvm/llvm-project/pull/130140.diff 1 Files Affected:
diff --git a/llvm/include/llvm/ADT/EquivalenceClasses.h b/llvm/include/llvm/ADT/EquivalenceClasses.h
index 4f98b84cf97d2..c375d6e77b12a 100644
--- a/llvm/include/llvm/ADT/EquivalenceClasses.h
+++ b/llvm/include/llvm/ADT/EquivalenceClasses.h
@@ -144,7 +144,7 @@ class EquivalenceClasses {
operator=(RHS);
}
- const EquivalenceClasses &operator=(const EquivalenceClasses &RHS) {
+ EquivalenceClasses &operator=(const EquivalenceClasses &RHS) {
TheMapping.clear();
for (iterator I = RHS.begin(), E = RHS.end(); I != E; ++I)
if (I->isLeader()) {
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add more description in the commit message explaining why the previous signature was incorrect? It's not obvious to me at least.
The current signature is incorrect per the C++ operator overloading spec. https://en.cppreference.com/w/cpp/language/operators Also added to description. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be missing something, but as per my reading of https://en.cppreference.com/w/cpp/language/copy_assignment the current definition should be ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. The current operator is valid (I think the return value can be arbitrary), but it's certainly unusual.
Sounds good to me, but please update the commit message |
I'd expect coverage for this in the unit tests? |
The patch is a NFC. |
NFC in the sense that it doesn't change the behavior of any LLVM programs, but we generally treat NFC a bit differently when it comes to ADTs or anything that's similarly/more unit testable. In which case we mostly test anything that can be observed on the API surface area. And this can be observed and tested. Potentially modifying the existing unit test (assuming this function has existing unit test coverage, if not, it should be added) to initialize a non-const ref from the result of the assignment (& existing test coverage should be checking that resulting reference has the same address as the object) |
Fixed, thanks. |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/155/builds/7303 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/55/builds/8118 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/85/builds/6279 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/193/builds/6150 Here is the relevant piece of the build log for the reference
|
The current signature is unusual, and deviates from the C++ operator overloading spec.
https://en.cppreference.com/w/cpp/language/copy_assignment