Fixed bug in the transfer function for dereferences: the loaded value from EvalLoad should bind to the UnaryOperator*, not its subexpression.

Added test case to exercise this fix when checking for uses of uninitialized values.

Patch by Zhongxing Xu!

llvm-svn: 51377
This commit is contained in:
Ted Kremenek 2008-05-21 15:48:33 +00:00
parent 78d66e4ac1
commit b120ff1b95
2 changed files with 9 additions and 1 deletions

View File

@ -1596,7 +1596,7 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred,
if (asLVal)
MakeNode(Dst, U, *I, SetRVal(St, U, location));
else
EvalLoad(Dst, Ex, *I, St, location);
EvalLoad(Dst, U, *I, St, location);
}
return;

View File

@ -33,3 +33,11 @@ int f2_b() {
return ((x+1)+2+((x))) + 1 ? 1 : 2; // expected-warning{{Branch}}
}
int f3(void) {
int i;
int *p = &i;
if (*p > 0) // expected-warning{{Branch condition evaluates to an uninitialized value}}
return 0;
else
return 1;
}