diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index b358993665d62784d9dd045e5b7820c707e80150..b56b050c144374efe856d01c4145d01f7ae7df7c 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -197,8 +197,10 @@ int CodeGenFunction::ConstantFoldsToSimpleInteger(const Expr *Cond) {
   
   // FIXME: Rename and handle conversion of other evaluatable things
   // to bool.
-  if (!Cond->Evaluate(V, getContext()) || !V.isInt())
-    return 0;  // Not foldable or not integer.
+  bool isEvaluated;
+  if (!Cond->Evaluate(V, getContext(), &isEvaluated) || !V.isInt() ||
+      !isEvaluated)
+    return 0;  // Not foldable, not integer or not fully evaluatable.
   
   if (CodeGenFunction::ContainsLabel(Cond))
     return 0;  // Contains a label.