]> granicus.if.org Git - clang/commitdiff
Changed merge operation for uninitialized values analysis to "intersect" (previous...
authorTed Kremenek <kremenek@apple.com>
Sat, 22 Mar 2008 20:11:00 +0000 (20:11 +0000)
committerTed Kremenek <kremenek@apple.com>
Sat, 22 Mar 2008 20:11:00 +0000 (20:11 +0000)
The effect is that if a variable is uninitialized along a branch (but initialized along another), at merge points it is considered uninitialized.  Previously we had the opposite behavior.  The new behavior is more conservative, and more in line with gcc's behavior.

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

lib/Analysis/UninitializedValues.cpp
test/Analysis/uninit-vals.c

index 25a5ecb48370133e4496bdf7702c62c5a277add1..3edf04ddb65adee9227059425c532091092943be 100644 (file)
@@ -223,7 +223,7 @@ bool TransferFuncs::BlockStmt_VisitExpr(Expr* E) {
 //===----------------------------------------------------------------------===//      
 
 namespace {
-  typedef ExprDeclBitVector_Types::Union Merge;
+  typedef ExprDeclBitVector_Types::Intersect Merge;
   typedef DataflowSolver<UninitializedValues,TransferFuncs,Merge> Solver;
 }
 
index 041c946fb0c52532a183b8b7735d9f2e7abb9058..fa6d0fc481b48095107d5dd32107d4a4207220c7 100644 (file)
@@ -20,7 +20,7 @@ int f3(int x) {
 int f4(int x) {
   int y;
   if (x) y = 1;
-  return y; // no-warning
+  return y; // expected-warning {{use of uninitialized variable}}
 }
 
 int f5() {