r224549 - [c Sema]. Patch fixes pointer-bool-conversion warning on C code

David Blaikie dblaikie at gmail.com
Fri Dec 19 10:51:19 PST 2014


On Thu, Dec 18, 2014 at 3:14 PM, Fariborz Jahanian <fjahanian at apple.com>
wrote:
>
> Author: fjahanian
> Date: Thu Dec 18 17:14:51 2014
> New Revision: 224549
>
> URL: http://llvm.org/viewvc/llvm-project?rev=224549&view=rev
> Log:
> [c Sema]. Patch fixes pointer-bool-conversion warning on C code
> when source range is incorrect causing the warning to be
> issued when it should not because expression is in a macro.
> rdar://19256338
>
> Modified:
>     cfe/trunk/lib/Sema/SemaChecking.cpp
>     cfe/trunk/test/Sema/warn-tautological-compare.c
>
> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=224549&r1=224548&r2=224549&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Dec 18 17:14:51 2014
> @@ -6685,11 +6685,11 @@ void AnalyzeImplicitConversions(Sema &S,
>    if (BO && BO->isLogicalOp()) {
>      Expr *SubExpr = BO->getLHS()->IgnoreParenImpCasts();
>      if (!IsLogicalAndOperator || !isa<StringLiteral>(SubExpr))
> -      ::CheckBoolLikeConversion(S, SubExpr, SubExpr->getExprLoc());
> +      ::CheckBoolLikeConversion(S, SubExpr, BO->getExprLoc());
>
>      SubExpr = BO->getRHS()->IgnoreParenImpCasts();
>      if (!IsLogicalAndOperator || !isa<StringLiteral>(SubExpr))
> -      ::CheckBoolLikeConversion(S, SubExpr, SubExpr->getExprLoc());
> +      ::CheckBoolLikeConversion(S, SubExpr, BO->getExprLoc());
>    }
>
>    if (const UnaryOperator *U = dyn_cast<UnaryOperator>(E))
>
> Modified: cfe/trunk/test/Sema/warn-tautological-compare.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-tautological-compare.c?rev=224549&r1=224548&r2=224549&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/Sema/warn-tautological-compare.c (original)
> +++ cfe/trunk/test/Sema/warn-tautological-compare.c Thu Dec 18 17:14:51
> 2014
> @@ -77,4 +77,18 @@ void test3() {
>         (!array && array[0])) {} // expected-warning {{address of array
> 'array' will always evaluate to 'true'}}
>   }
>
> -
> +// rdar://19256338
> +#define SAVE_READ(PTR, RESULT) if( (PTR) && *(PTR) ) *RESULT=*PTR;
> +
> +// Source
> +typedef unsigned char Boolean;
> +struct HTTPClientPrivate
> +{
> +   Boolean readSuspended;
> +};
> +typedef struct HTTPClientPrivate * HTTPClientRef;
> +static void _HTTPClientErrorHandler( HTTPClientRef me)
> +{
> +  Boolean result;
> +  SAVE_READ(&me->readSuspended, &result);
> +}
>

Could this test case be a bit simpler to highlight the specific issue being
tested/addressed here? (I assume the test case doesn't require a
class/struct, or two macro parameters, etc, etc... )


>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141219/21187f42/attachment.html>


More information about the cfe-commits mailing list