summaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2014-11-19 06:08:18 +0000
committerRichard Trieu <rtrieu@google.com>2014-11-19 06:08:18 +0000
commitb4adcf5e119cfd1e20040ee974c598a435a7c17f (patch)
treef23c9615371425865f27176cb3f877f23354bbb7 /lib/Sema/SemaChecking.cpp
parent8945a699131159a70cc74a6a14f6d888517a6582 (diff)
Add the exception for strings in logical and expressions to -Wstring-conversion
for C code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222327 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r--lib/Sema/SemaChecking.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index aa6bf1760d..91ba91e4f5 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -6613,10 +6613,17 @@ void AnalyzeImplicitConversions(Sema &S, Expr *OrigE, SourceLocation CC) {
continue;
AnalyzeImplicitConversions(S, ChildExpr, CC);
}
+
if (BO && BO->isLogicalOp()) {
- ::CheckBoolLikeConversion(S, BO->getLHS(), BO->getLHS()->getExprLoc());
- ::CheckBoolLikeConversion(S, BO->getRHS(), BO->getRHS()->getExprLoc());
+ Expr *SubExpr = BO->getLHS()->IgnoreParenImpCasts();
+ if (!IsLogicalAndOperator || !isa<StringLiteral>(SubExpr))
+ ::CheckBoolLikeConversion(S, SubExpr, SubExpr->getExprLoc());
+
+ SubExpr = BO->getRHS()->IgnoreParenImpCasts();
+ if (!IsLogicalAndOperator || !isa<StringLiteral>(SubExpr))
+ ::CheckBoolLikeConversion(S, SubExpr, SubExpr->getExprLoc());
}
+
if (const UnaryOperator *U = dyn_cast<UnaryOperator>(E))
if (U->getOpcode() == UO_LNot)
::CheckBoolLikeConversion(S, U->getSubExpr(), CC);