In C++, assignment and compound assignment operators return an lvalue.

llvm-svn: 123158
This commit is contained in:
Zhongxing Xu 2011-01-10 03:54:19 +00:00
parent 1bf55f2af7
commit 5609e21337
2 changed files with 14 additions and 2 deletions

View File

@ -3241,8 +3241,14 @@ void ExprEngine::VisitBinaryOperator(const BinaryOperator* B,
LHSVal = svalBuilder.evalCast(Result, LTy, CTy);
}
evalStore(Tmp3, B, LHS, *I4, state->BindExpr(B, Result),
location, LHSVal);
// In C++, assignment and compound assignment operators return an
// lvalue.
if (B->isLValue())
state = state->BindExpr(B, location);
else
state = state->BindExpr(B, Result);
evalStore(Tmp3, B, LHS, *I4, state, location, LHSVal);
}
}
}

View File

@ -0,0 +1,6 @@
// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=region -verify %s
int f1() {
int x = 0, y = 1;
return x += y; // Should bind a location to 'x += y'. No crash.
}