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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user