[Analyzer] Incorrect behavior of implicit copy assignment

Hi All,

I am analyzing the following code:

struct S1 {
S1() {}
S1(int x, int y, int z) : a(x), b(y), c(z) {}
int a;
int b;
int c;
};

void foo() {
S1 s2;
S1 s1(3, 0, 4);
s2 = s1;
}

with three callbacks: checkPostStmt, checkPreCall, and checkEndFunction. I would expect the general order of analysis to go something like this:

PreCall(S1 default constructor)
EndFunction(S1 default constructor)
PreCall(S1 constructor)
Evaluate(S1 constructor)
EndFunction(S1 constructor)
PreCall(S1 copy assignment)
Evaluate(S1 copy assignment)
EndFunction(S1 copy assignment)
EndFunction(foo)

where Evaluate() is shorthand for a series of PostStmt’s. If I write out an explicit copy assignment operator:

S1 operator=(const S1 &s) {
a = s.a; b = s.b; c = s.c;
}

then the analysis runs in the expected sequence. But when the copy assignment operator is left implicit, I observe the following sequence:

PreCall(S1 default constructor)
EndFunction(S1 default constructor)
PreCall(S1 constructor)
Evaluate(S1 constructor)
EndFunction(S1 constructor)
PreCall(S1 copy assignment)
EndFunction(foo)

Evaluate(S1 copy assignment)
EndFunction(S1 copy assignment)

So the implicit copy assignment operator is actually being evaluated AFTER foo() terminates. This in turn throws off my analyses.

~Scott Constable