[cfe-commits] r44058 - in /cfe/trunk: Sema/SemaExpr.cpp test/Sema/floating-point-compare.c

Chris Lattner clattner at apple.com
Tue Nov 13 14:22:52 PST 2007


On Nov 13, 2007, at 11:17 AM, Ted Kremenek wrote:

> Author: kremenek
> Date: Tue Nov 13 13:17:00 2007
> New Revision: 44058
>
> URL: http://llvm.org/viewvc/llvm-project?rev=44058&view=rev
> Log:
> Modified -Wfloat-equal logic to suppress warnings where floating  
> point values
> are compared against builtins such as __builtin_inf.

Hey Ted,


> @@ -1254,11 +1281,27 @@
>        // Special case: check for x == x (which is OK).
>        bool EmitWarning = true;
>
> -      if (DeclRefExpr* DRL = dyn_cast<DeclRefExpr>(IgnoreParen(lex)))
> -        if (DeclRefExpr* DRR = dyn_cast<DeclRefExpr>(IgnoreParen 
> (rex)))
> +      Expr* LeftExprSansParen = IgnoreParen(lex);
> +      Expr* RightExprSansParen = IgnoreParen(rex);
> +
> +      // Look for x == x.  Do not emit warnings for such cases.
> +      if (DeclRefExpr* DRL = dyn_cast<DeclRefExpr> 
> (LeftExprSansParen))
> +        if (DeclRefExpr* DRR = dyn_cast<DeclRefExpr> 
> (RightExprSansParen))
>            if (DRL->getDecl() == DRR->getDecl())
>              EmitWarning = false;

Please pull this logic out into a separate function, something like:

if (reallyemitwarning(lex, rex))
   do it

That allows you to turn the "EmitWarning" bool into a "return false".

-Chris






More information about the cfe-commits mailing list