[PATCH] D57890: [analyzer] Fix in self assignment checker
Tibor Brunner via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 7 06:08:06 PST 2019
bruntib created this revision.
bruntib added reviewers: NoQ, george.karpenkov, Szelethus, xazax.hun, baloghadamsoftware.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet.
Herald added a project: clang.
For self assignment checker it was necessary to force checking of assignment operators even if those are not called. The reason of this is to check whether "this" is equal to the address of the assignee object.
The buffer overlap checker checks if the intervals of the arguments of a memcpy() call are disjoint. If a class has an array member then the compiler generated assignment operator copies it with memcpy() function without checking self assignment at the beginning. Since the analyzer forces the check of assignment operators, the buffer overflow checker reported a false positive on classes with compiler generated assignment operator and array member.
This commit prevents the forced check of compiler generated assignment operators.
Repository:
rC Clang
https://reviews.llvm.org/D57890
Files:
lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===================================================================
--- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -450,7 +450,7 @@
// where it may not. (cplusplus.SelfAssignmentChecker)
if (const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
if (MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator())
- return false;
+ return !MD->isUserProvided();
}
// Otherwise, if we visited the function before, do not reanalyze it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57890.185754.patch
Type: text/x-patch
Size: 575 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190207/357f098e/attachment-0001.bin>
More information about the cfe-commits
mailing list