Don't try to evaluate an expression that is type- or value-dependent while building the CFG

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79941 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp
index 08a13c4..3677f7e 100644
--- a/lib/Analysis/CFG.cpp
+++ b/lib/Analysis/CFG.cpp
@@ -158,7 +158,8 @@
   /// if we can evaluate to a known value, otherwise return -1.
   TryResult TryEvaluateBool(Expr *S) {
     Expr::EvalResult Result;
-    if (S->Evaluate(Result, *Context) && Result.Val.isInt())
+    if (!S->isTypeDependent() && !S->isValueDependent() &&
+        S->Evaluate(Result, *Context) && Result.Val.isInt())
       return Result.Val.getInt().getBoolValue();
 
     return TryResult();
diff --git a/test/SemaTemplate/fun-template-def.cpp b/test/SemaTemplate/fun-template-def.cpp
index 8833ef4..dee4250 100644
--- a/test/SemaTemplate/fun-template-def.cpp
+++ b/test/SemaTemplate/fun-template-def.cpp
@@ -10,8 +10,13 @@
 
 struct dummy {};
 
+template<typename T>
+int f0(T x) {
+  return (sizeof(x) == sizeof(int))? 0 : (sizeof(x) == sizeof(double))? 1 : 2;
+}
+
 template <typename T, typename U>
-T f(T t1, U u1, int i1)
+T f1(T t1, U u1, int i1)
 {
   T t2 = i1;
   t2 = i1 + u1;