Fix horrible GRExprEngine bug where switch statements with no 'case:' statements would cause the path to get prematurely aborted.  Fixes <rdar://problem/8360854>.

llvm-svn: 112233
diff --git a/clang/include/clang/Checker/PathSensitive/GRCoreEngine.h b/clang/include/clang/Checker/PathSensitive/GRCoreEngine.h
index 4f9f2d8..216ecac 100644
--- a/clang/include/clang/Checker/PathSensitive/GRCoreEngine.h
+++ b/clang/include/clang/Checker/PathSensitive/GRCoreEngine.h
@@ -407,7 +407,8 @@
 
   public:
     iterator& operator++() { ++I; return *this; }
-    bool operator!=(const iterator& X) const { return I != X.I; }
+    bool operator!=(const iterator &X) const { return I != X.I; }
+    bool operator==(const iterator &X) const { return I == X.I; }
 
     const CaseStmt* getCase() const {
       return llvm::cast<CaseStmt>((*I)->getLabel());
diff --git a/clang/lib/Checker/GRExprEngine.cpp b/clang/lib/Checker/GRExprEngine.cpp
index 3578483..c9173aa 100644
--- a/clang/lib/Checker/GRExprEngine.cpp
+++ b/clang/lib/Checker/GRExprEngine.cpp
@@ -1489,9 +1489,11 @@
   DefinedOrUnknownSVal CondV = cast<DefinedOrUnknownSVal>(CondV_untested);
 
   const GRState *DefaultSt = state;
-  bool defaultIsFeasible = false;
+  
+  iterator I = builder.begin(), EI = builder.end();
+  bool defaultIsFeasible = I == EI;
 
-  for (iterator I = builder.begin(), EI = builder.end(); I != EI; ++I) {
+  for ( ; I != EI; ++I) {
     const CaseStmt* Case = I.getCase();
 
     // Evaluate the LHS of the case value.
diff --git a/clang/test/Analysis/misc-ps.m b/clang/test/Analysis/misc-ps.m
index b4fa77e..ced08535 100644
--- a/clang/test/Analysis/misc-ps.m
+++ b/clang/test/Analysis/misc-ps.m
@@ -1045,3 +1045,14 @@
   if (y == -20 && b != 0)
     (void)*(char*)0; // no-warning
 }
+
+// <rdar://problem/8360854> - Test that code after a switch statement with no 
+// 'case:' labels is correctly evaluated.
+void r8360854(int n) {
+  switch (n) {
+   default: ;
+  }
+  int *p = 0;
+  *p = 0xDEADBEEF; // expected-warning{{null pointer}}
+}
+