[analyzer] Fix an assertion failure triggered by the analyzer buildbot.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155964 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/StaticAnalyzer/Core/SValBuilder.cpp b/lib/StaticAnalyzer/Core/SValBuilder.cpp
index 4ce9d09..4c021a4 100644
--- a/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ b/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -196,25 +196,24 @@
 //===----------------------------------------------------------------------===//
 
 SVal SValBuilder::makeSymExprValNN(ProgramStateRef State,
-                                 BinaryOperator::Opcode Op,
-                                 NonLoc LHS, NonLoc RHS,
-                                 QualType ResultTy) {
-  const SymExpr *symLHS;
-  const SymExpr *symRHS;
+                                   BinaryOperator::Opcode Op,
+                                   NonLoc LHS, NonLoc RHS,
+                                   QualType ResultTy) {
+  const SymExpr *symLHS = LHS.getAsSymExpr();
+  const SymExpr *symRHS = RHS.getAsSymExpr();
 
-  if (const nonloc::ConcreteInt *rInt = dyn_cast<nonloc::ConcreteInt>(&RHS)) {
-    symLHS = LHS.getAsSymExpr();
-    return makeNonLoc(symLHS, Op, rInt->getValue(), ResultTy);
-  }
+  if (symLHS && symRHS)
+    return makeNonLoc(symLHS, Op, symRHS, ResultTy);
 
-  if (const nonloc::ConcreteInt *lInt = dyn_cast<nonloc::ConcreteInt>(&LHS)) {
-    symRHS = RHS.getAsSymExpr();
-    return makeNonLoc(lInt->getValue(), Op, symRHS, ResultTy);
-  }
+  if (symLHS)
+    if (const nonloc::ConcreteInt *rInt = dyn_cast<nonloc::ConcreteInt>(&RHS))
+      return makeNonLoc(symLHS, Op, rInt->getValue(), ResultTy);
 
-  symLHS = LHS.getAsSymExpr();
-  symRHS = RHS.getAsSymExpr();
-  return makeNonLoc(symLHS, Op, symRHS, ResultTy);
+  if (symRHS)
+    if (const nonloc::ConcreteInt *lInt = dyn_cast<nonloc::ConcreteInt>(&LHS))
+      return makeNonLoc(lInt->getValue(), Op, symRHS, ResultTy);
+
+  return UnknownVal();
 }
 
 
diff --git a/test/Analysis/svalbuilder-logic.c b/test/Analysis/svalbuilder-logic.c
new file mode 100644
index 0000000..bc79f85
--- /dev/null
+++ b/test/Analysis/svalbuilder-logic.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix -verify %s
+
+// Testing core functionality of the SValBuilder.
+
+int SValBuilderLogicNoCrash(int *x) {
+  return 3 - (int)(x +3);
+}