]> granicus.if.org Git - clang/commitdiff
Fixed bug in the transfer function for dereferences: the loaded value from EvalLoad...
authorTed Kremenek <kremenek@apple.com>
Wed, 21 May 2008 15:48:33 +0000 (15:48 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 21 May 2008 15:48:33 +0000 (15:48 +0000)
Added test case to exercise this fix when checking for uses of uninitialized values.

Patch by Zhongxing Xu!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51377 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/GRExprEngine.cpp
test/Analysis/uninit-vals-ps.c

index 71d7ed34035564d076b950a465a9bf4cac19b622..ce64875797c6b7884483754778efc8ad11929ea1 100644 (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;
index 503ab1abbccfddc5c3f6eef574ecc520abccec0c..707f78a96bd40a6af7cc987680f43e27d4b7e054 100644 (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;
+}