From 216bcceee1ba908f617deb3f2404aff8085d5358 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 21 Feb 2014 23:42:46 +0100 Subject: Special handling of __builtin_expect in boolean expressions ...as found in Mac OS X' assert macro definition, __builtin_expect(!(e), 0) ? ... : ... with type long __builtin_expect(long, long) The code in literaltoboolconversion.cxx is needed for assert(false); Change-Id: I42f87482c56986af74b2ec849db9852f74c7c938 --- compilerplugins/clang/literaltoboolconversion.cxx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'compilerplugins/clang/literaltoboolconversion.cxx') 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 /* -*- 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(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; } -- cgit