summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/literaltoboolconversion.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'compilerplugins/clang/literaltoboolconversion.cxx')
-rw-r--r--compilerplugins/clang/literaltoboolconversion.cxx20
1 files changed, 13 insertions, 7 deletions
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;
}