Add "KnownSVal" to represent SVals that cannot be UnknownSVal.

This provides a few sundry cleanups, and allows us to provide
a compile-time check for a case that was a runtime assertion.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175987 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp b/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp
index 3f83637..f0ca8a8 100644
--- a/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp
@@ -75,9 +75,8 @@
       continue;
 
     // Get the VarRegion associated with VD in the local stack frame.
-    SVal VRVal = state->getSVal(I.getOriginalRegion());
-
-    if (VRVal.isUndef())
+    if (Optional<UndefinedVal> V =
+          state->getSVal(I.getOriginalRegion()).getAs<UndefinedVal>()) {
       if (ExplodedNode *N = C.generateSink()) {
         if (!BT)
           BT.reset(new BuiltinBug("uninitialized variable captured by block"));
@@ -92,11 +91,12 @@
         BugReport *R = new BugReport(*BT, os.str(), N);
         if (const Expr *Ex = FindBlockDeclRefExpr(BE->getBody(), VD))
           R->addRange(Ex->getSourceRange());
-        R->addVisitor(new FindLastStoreBRVisitor(VRVal, VR));
+        R->addVisitor(new FindLastStoreBRVisitor(*V, VR));
         R->disablePathPruning();
         // need location of block
         C.emitReport(R);
       }
+    }
   }
 }