r224549 - [c Sema]. Patch fixes pointer-bool-conversion warning on C code
Fariborz Jahanian
fjahanian at apple.com
Thu Dec 18 15:14:51 PST 2014
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);
+}
More information about the cfe-commits
mailing list