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

llvm-svn: 79941
This commit is contained in:
Douglas Gregor 2009-08-24 21:39:56 +00:00
parent d5ab926848
commit 4c95288f64
2 changed files with 8 additions and 2 deletions

View File

@ -158,7 +158,8 @@ private:
/// 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();

View File

@ -10,8 +10,13 @@ namespace std { class type_info {}; }
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;