HomePhabricator

[analyzer] Add checker modeling potential C++ self-assignment

Authored by dcoughlin on Jul 21 2016, 4:42 PM.

Description

[analyzer] Add checker modeling potential C++ self-assignment

This checker checks copy and move assignment operators whether they are
protected against self-assignment. Since C++ core guidelines discourages
explicit checking for &rhs==this in general we take a different approach: in
top-frame analysis we branch the exploded graph for two cases, where &rhs==this
and &rhs!=this and let existing checkers (e.g. unix.Malloc) do the rest of the
work. It is important that we check all copy and move assignment operator in top
frame even if we checked them already since self-assignments may happen
undetected even in the same translation unit (e.g. using random indices for an
array what may or may not be the same).

This reapplies r275820 after fixing a string-lifetime issue discovered by the
bots.

A patch by Ádám Balogh!

Differential Revision: https://reviews.llvm.org/D19311

llvm-svn: 276365

Details

Committed
dcoughlinJul 21 2016, 4:42 PM
Differential Revision
D19311: [analyzer] Self Assignment Checker
Parents
rGc107a4875e40: GVN-hoist: add missing check for all GEP operands available
Branches
Unknown
Tags
Unknown