[cfe-commits] r51377 - in /cfe/trunk: lib/Analysis/GRExprEngine.cpp test/Analysis/uninit-vals-ps.c

Ted Kremenek kremenek at apple.com
Wed May 21 08:48:33 PDT 2008


Author: kremenek
Date: Wed May 21 10:48:33 2008
New Revision: 51377

URL: http://llvm.org/viewvc/llvm-project?rev=51377&view=rev
Log:
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!


Modified:
    cfe/trunk/lib/Analysis/GRExprEngine.cpp
    cfe/trunk/test/Analysis/uninit-vals-ps.c

Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=51377&r1=51376&r2=51377&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Wed May 21 10:48:33 2008
@@ -1596,7 +1596,7 @@
         if (asLVal)
           MakeNode(Dst, U, *I, SetRVal(St, U, location));
         else
-          EvalLoad(Dst, Ex, *I, St, location);
+          EvalLoad(Dst, U, *I, St, location);
       } 
 
       return;

Modified: cfe/trunk/test/Analysis/uninit-vals-ps.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/uninit-vals-ps.c?rev=51377&r1=51376&r2=51377&view=diff

==============================================================================
--- cfe/trunk/test/Analysis/uninit-vals-ps.c (original)
+++ cfe/trunk/test/Analysis/uninit-vals-ps.c Wed May 21 10:48:33 2008
@@ -33,3 +33,11 @@
   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;
+}





More information about the cfe-commits mailing list