As the there is support for BinaryOperator in order to see that it's of assignment type, this patch adds the same logic for the cases when assignment operators have been overloaded and used in different expressions.
For example:
class Number { int number; public: Number& operator=(int a) { number = a; return *this; } }; int main(int argc, const char * argv[]) { Number a; a = 2; }
The AST node that will get generated for the assignment is of type CXXOperatorCallExpr so calling HasSideEffects on that expression would have resulted in a false return since CXXOperatorCallExpr was not considered to have a possible side effect when it's underlying operator type is assignment.
This patch addresses this exact issue and checks the underlying kind and if it's assignment it returns true, otherwise it continues the execution.
Well, this is true for any overloaded operator. Perhaps something like
"When looking for potential side-effects, we assume that an overloaded assignment operator is intended to have a side-effect and other overloaded operators are not."