[PATCH] D44883: [Sema] Extend -Wself-assign with -Wself-assign-overloaded to warn on overloaded self-assignment (classes)
Roman Lebedev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 26 12:03:40 PDT 2018
lebedev.ri added a comment.
Ok, once we understand why "field" diag is separate, and why since initial implementation it only warned for "builtin" operators, i'll work on the code further.
In https://reviews.llvm.org/D44883#1048485, @rjmccall wrote:
> That's an interesting question! You're absolutely right, I do think we should warn about trivial C++ assignments as part of the builtin group. If a C program includes a self-assignment that happens to be of struct type, we'll warn about that, and it seems to be that we shouldn't lose the warning just because that code is compiled as C++ instead.
>
> As for your example, I think it should be based on whether the assignment operator selected is trivial. If it's non-trivial, even if it's defaulted, we should warn about it as a "user-defined" operator, since ultimately it does involve calling such an operator.
To summarize:
https://godbolt.org/g/gwDASe - `A`, `B` and `C` case should be treated as built-in, and `D`, `E` and `F` as user-defined.
Repository:
rC Clang
https://reviews.llvm.org/D44883
More information about the cfe-commits
mailing list