[PATCH] D44883: [Sema] Extend -Wself-assign and -Wself-assign-field to warn on overloaded self-assignment (classes)
Roman Lebedev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 3 16:36:09 PDT 2018
lebedev.ri added a comment.
In https://reviews.llvm.org/D44883#1054326, @thakis wrote:
> In https://reviews.llvm.org/D44883#1048751, @dblaikie wrote:
>
> > Historically Clang's policy on warnings was, I think, much more
> > conservative than it seems to be today. There was a strong desire not to
> > implement off-by-default warnings, and to have warnings with an
> > exceptionally low false-positive rate - maybe the user-defined operator
> > detection was either assumed to, or demonstrated to, have a sufficiently
> > high false positive rate to not meet that high bar.
>
>
> This is still the case. For a new warning, you should evaluate some large open-source codebase and measure true positive and false positive rate and post the numbers here.
Just finished running it on chrome: (wow, that took a while!)
$ cat /tmp/test.cpp
struct S {};
void test (S a) {
a = a;
}
$ /build/llvm-build-Clang-release/bin/clang++ -c /tmp/test.cpp -Wall
/tmp/test.cpp:4:5: warning: explicitly assigning value of variable of type 'S' to itself [-Wself-assign]
a = a;
~ ^ ~
1 warning generated.
$ ninja -C out/ClangStage2 chrome
ninja: Entering directory `out/ClangStage2'
[31309/31309] LINK ./chrome
Config: F5937598: args.gn <https://reviews.llvm.org/F5937598>
So unless the config ^ is wrong, there have been no occurrences, no false-positives.
Down to one [trivial] prerequisite - https://reviews.llvm.org/D45082 - would be super nice if someone could review/accept it :)
Repository:
rC Clang
https://reviews.llvm.org/D44883
More information about the cfe-commits
mailing list