-Wuninitialized: Split the classification of DeclRefExprs as initialization or
use out of TransferFunctions, and compute it in advance rather than on-the-fly.

This allows us to handle compound assignments with DeclRefExprs on the RHS
correctly, and also makes it trivial to treat const& function parameters as not
initializing the argument. The patch also makes both of those changes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160330 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Sema/uninit-variables.c b/test/Sema/uninit-variables.c
index 2630b70..4e3d74b 100644
--- a/test/Sema/uninit-variables.c
+++ b/test/Sema/uninit-variables.c
@@ -33,8 +33,8 @@
 
 int test6() {
   int x; // expected-note{{initialize the variable 'x' to silence this warning}}
-  x += 2; // expected-warning{{variable 'x' is uninitialized when used here}}
-  return x;
+  x += 2;
+  return x; // expected-warning{{variable 'x' is uninitialized when used here}}
 }
 
 int test7(int y) {
@@ -485,3 +485,16 @@
   }
   return a;
 }
+
+int compound_assign(int *arr, int n) {
+  int sum; // expected-note {{initialize}}
+  for (int i = 0; i < n; ++i)
+    sum += arr[i];
+  return sum / n; // expected-warning {{variable 'sum' is uninitialized}}
+}
+
+void compound_assign_2(int n) {
+  volatile int ignore;
+  for (int j = 0; j < n; ++j)
+    ignore += test1(); // ok
+}