Remove warning in dead stores checker for
dead stores within nested assignments.  I have
never seen an actual bug found by this specific
warning, and it can lead to many false positives.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123394 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/StaticAnalyzer/Checkers/CheckDeadStores.cpp b/lib/StaticAnalyzer/Checkers/CheckDeadStores.cpp
index 1fe40c5..96c0dd4 100644
--- a/lib/StaticAnalyzer/Checkers/CheckDeadStores.cpp
+++ b/lib/StaticAnalyzer/Checkers/CheckDeadStores.cpp
@@ -1,4 +1,4 @@
-//==- DeadStores.cpp - Check for stores to dead variables --------*- C++ -*-==//
+//==- DeadStoresChecker.cpp - Check for stores to dead variables -*- C++ -*-==//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -70,11 +70,10 @@
         break;
 
       case Enclosing:
-        BugType = "Dead nested assignment";
-        msg = "Although the value stored to '" + name +
-          "' is used in the enclosing expression, the value is never actually"
-          " read from '" + name + "'";
-        break;
+        // Don't report issues in this case, e.g.: "if (x = foo())",
+        // where 'x' is unused later.  We have yet to see a case where 
+        // this is a real bug.
+        return;
     }
 
     BR.EmitBasicReport(BugType, "Dead store", msg, L, R);
diff --git a/test/Analysis/dead-stores.c b/test/Analysis/dead-stores.c
index c150fa0..a07138e 100644
--- a/test/Analysis/dead-stores.c
+++ b/test/Analysis/dead-stores.c
@@ -75,9 +75,11 @@
   return 1;
 }
 
+// Don't warn for dead stores in nested expressions.  We have yet
+// to see a real bug in this scenario.
 int f8(int *p) {
   extern int *baz();
-  if ((p = baz())) // expected-warning{{Although the value}}
+  if ((p = baz())) // no-warning
     return 1;
   return 0;
 }
@@ -148,9 +150,11 @@
   int z[count]; // expected-warning{{unused variable 'z'}}
 }
 
+// Don't warn for dead stores in nested expressions.  We have yet
+// to see a real bug in this scenario.
 int f16(int x) {
   x = x * 2;
-  x = sizeof(int [x = (x || x + 1) * 2]) // expected-warning{{Although the value stored to 'x' is used}} expected-warning{{The left operand to '*' is always 1}} expected-warning{{The left operand to '+' is always 0}}
+  x = sizeof(int [x = (x || x + 1) * 2]) // expected-warning{{The left operand to '+' is always 0}} expected-warning{{The left operand to '*' is always 1}}
       ? 5 : 8;
   return x;
 }
@@ -175,7 +179,9 @@
       x = 10;   // expected-warning{{Value stored to 'x' is never read}}
    while (1);
 
-   return (x = 10); // expected-warning{{Although the value stored to 'x' is used in the enclosing expression, the value is never actually read from 'x'}}
+   // Don't warn for dead stores in nested expressions.  We have yet
+   // to see a real bug in this scenario.
+   return (x = 10); // no-warning
 }
 
 // PR 3514: false positive `dead initialization` warning for init to global