diff options
-rw-r--r-- | compilerplugins/clang/implicitboolconversion.cxx | 4 | ||||
-rw-r--r-- | compilerplugins/clang/literaltoboolconversion.cxx | 20 |
2 files changed, 16 insertions, 8 deletions
diff --git a/compilerplugins/clang/implicitboolconversion.cxx b/compilerplugins/clang/implicitboolconversion.cxx index b03a32e68a35..0327f9fbbef0 100644 --- a/compilerplugins/clang/implicitboolconversion.cxx +++ b/compilerplugins/clang/implicitboolconversion.cxx @@ -192,7 +192,9 @@ bool ImplicitBoolConversion::TraverseCallExpr(CallExpr * expr) { && !(compat::getParamType(*t, n)->isSpecificBuiltinType( BuiltinType::Int) || (compat::getParamType(*t, n)->isSpecificBuiltinType( - BuiltinType::UInt)))) + BuiltinType::UInt)) + || (compat::getParamType(*t, n)->isSpecificBuiltinType( + BuiltinType::Long)))) { reportWarning(i); } diff --git a/compilerplugins/clang/literaltoboolconversion.cxx b/compilerplugins/clang/literaltoboolconversion.cxx index d156e9bba186..1bbdc0550194 100644 --- a/compilerplugins/clang/literaltoboolconversion.cxx +++ b/compilerplugins/clang/literaltoboolconversion.cxx @@ -1,3 +1,4 @@ +#include<iostream> /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. @@ -135,13 +136,18 @@ bool LiteralToBoolConversion::VisitImplicitCastExpr( << expr->getType() << expr->getSourceRange(); #endif } else if (sub->isIntegerConstantExpr(compiler.getASTContext())) { - report( - DiagnosticsEngine::Warning, - ("implicit conversion (%0) of integer constant expression of type" - " %1 to %2"), - expr->getLocStart()) - << expr->getCastKindName() << expr->getSubExpr()->getType() - << expr->getType() << expr->getSourceRange(); + CallExpr const * ce = dyn_cast<CallExpr>(sub); + if (ce == nullptr + || ce->getBuiltinCallee() != Builtin::BI__builtin_expect) + { + report( + DiagnosticsEngine::Warning, + ("implicit conversion (%0) of integer constant expression of" + " type %1 to %2"), + expr->getLocStart()) + << expr->getCastKindName() << expr->getSubExpr()->getType() + << expr->getType() << expr->getSourceRange(); + } } return true; } |