[PATCH] D126534: [analyzer] Deadstore static analysis: Fix false positive on C++17 assignments
Balázs Benics via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri May 27 07:33:00 PDT 2022
steakhal added a comment.
I haven't checked the implementation; the Deadstores checker was always a nemesis for me.
Off the top of my head, I think in the analyzer we have the `elide-constructors=true/false` analyzer config option, which quotes:
> Whether elidable C++ copy-constructors and move-constructors should be actually elided during analysis. Both behaviors are allowed by the C++ standard, and the analyzer, like CodeGen, defaults to eliding. Starting with C++17 some elisions become mandatory, and in these cases the option will be ignored.
You also mentioned this copy elision, but I don't see anywhere checks for the standard version in code. I would expect that your change should apply only to C++17 and above.
================
Comment at: clang/test/Analysis/dead-stores.cpp:63-68
+void copy(int x) {
+ TestConstructor tc1 = x; // no-warning
+ TestConstructor tc2 = TestConstructor(x); // no-warning
+ TestConstructor tc3 = (TestConstructor(x)); // no-warning
+ TestConstructor tc4 = (TestConstructor)(x); // no-warning
+}
----------------
So we don't warn for these since the opaque ctor call might introduce some side-effects.
Please note this after the `no-warning` tag.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126534/new/
https://reviews.llvm.org/D126534
More information about the cfe-commits
mailing list