Query module AV Rule 82

name
Overloaded assignment does not return ‘this’
description
An assignment operator should return a reference to *this. Both the standard library types and the built-in types behave in this manner.
kind
problem
problem.severity
warning
precision
high
id
cpp/assignment-does-not-return-this
tags
reliability readability language-features external/jsf

Imports

cpp

Provides classes and predicates for working with C/C++/ObjC/ObjC++ code.

Predicates

assignOperatorWithWrongResult
assignOperatorWithWrongType
callOnThis
dereferenceThis
pointerThis
returnsDereferenceThis

Holds if all return statements in f return a reference to *this, possibly indirectly. This includes functions whose body is not in the database.

returnsPointerThis

Holds if all return statements in f return this, possibly indirectly. This includes functions whose body is not in the database.