[cfe-commits] r79941 - in /cfe/trunk: lib/Analysis/CFG.cpp test/SemaTemplate/fun-template-def.cpp

Chris Lattner clattner at apple.com
Mon Aug 24 15:38:01 PDT 2009


On Aug 24, 2009, at 2:39 PM, Douglas Gregor wrote:

> Author: dgregor
> Date: Mon Aug 24 16:39:56 2009
> New Revision: 79941
>
> URL: http://llvm.org/viewvc/llvm-project?rev=79941&view=rev
> Log:
> Don't try to evaluate an expression that is type- or value-dependent  
> while building the CFG

Does it really make sense to build a CFG of an uninstantiated template?

-Chris

>
> Modified:
>    cfe/trunk/lib/Analysis/CFG.cpp
>    cfe/trunk/test/SemaTemplate/fun-template-def.cpp
>
> Modified: cfe/trunk/lib/Analysis/CFG.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=79941&r1=79940&r2=79941&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/Analysis/CFG.cpp (original)
> +++ cfe/trunk/lib/Analysis/CFG.cpp Mon Aug 24 16:39:56 2009
> @@ -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();
>
> Modified: cfe/trunk/test/SemaTemplate/fun-template-def.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/fun-template-def.cpp?rev=79941&r1=79940&r2=79941&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/test/SemaTemplate/fun-template-def.cpp (original)
> +++ cfe/trunk/test/SemaTemplate/fun-template-def.cpp Mon Aug 24  
> 16:39:56 2009
> @@ -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;
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list