summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/implicitboolconversion.cxx30
1 files changed, 30 insertions, 0 deletions
diff --git a/compilerplugins/clang/implicitboolconversion.cxx b/compilerplugins/clang/implicitboolconversion.cxx
index 65db49650135..a804b0d1d70e 100644
--- a/compilerplugins/clang/implicitboolconversion.cxx
+++ b/compilerplugins/clang/implicitboolconversion.cxx
@@ -405,6 +405,16 @@ bool ImplicitBoolConversion::TraverseBinAndAssign(CompoundAssignOperator * expr)
}
}
nested.pop();
+ if (!ignoreLocation(expr) && isBool(expr->getLHS(), false)
+ && !isBool(expr->getRHS()->IgnoreParenImpCasts(), false))
+ {
+ report(
+ DiagnosticsEngine::Warning, "mix of %0 and %1 in operator &=",
+ expr->getRHS()->getLocStart())
+ << expr->getLHS()->getType()
+ << expr->getRHS()->IgnoreParenImpCasts()->getType()
+ << expr->getSourceRange();
+ }
return ret;
}
@@ -421,6 +431,16 @@ bool ImplicitBoolConversion::TraverseBinOrAssign(CompoundAssignOperator * expr)
}
}
nested.pop();
+ if (!ignoreLocation(expr) && isBool(expr->getLHS(), false)
+ && !isBool(expr->getRHS()->IgnoreParenImpCasts(), false))
+ {
+ report(
+ DiagnosticsEngine::Warning, "mix of %0 and %1 in operator |=",
+ expr->getRHS()->getLocStart())
+ << expr->getLHS()->getType()
+ << expr->getRHS()->IgnoreParenImpCasts()->getType()
+ << expr->getSourceRange();
+ }
return ret;
}
@@ -437,6 +457,16 @@ bool ImplicitBoolConversion::TraverseBinXorAssign(CompoundAssignOperator * expr)
}
}
nested.pop();
+ if (!ignoreLocation(expr) && isBool(expr->getLHS(), false)
+ && !isBool(expr->getRHS()->IgnoreParenImpCasts(), false))
+ {
+ report(
+ DiagnosticsEngine::Warning, "mix of %0 and %1 in operator ^=",
+ expr->getRHS()->getLocStart())
+ << expr->getLHS()->getType()
+ << expr->getRHS()->IgnoreParenImpCasts()->getType()
+ << expr->getSourceRange();
+ }
return ret;
}