Kaydet (Commit) 216bccee authored tarafından Stephan Bergmann's avatar Stephan Bergmann

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
üst 33162028
...@@ -192,7 +192,9 @@ bool ImplicitBoolConversion::TraverseCallExpr(CallExpr * expr) { ...@@ -192,7 +192,9 @@ bool ImplicitBoolConversion::TraverseCallExpr(CallExpr * expr) {
&& !(compat::getParamType(*t, n)->isSpecificBuiltinType( && !(compat::getParamType(*t, n)->isSpecificBuiltinType(
BuiltinType::Int) BuiltinType::Int)
|| (compat::getParamType(*t, n)->isSpecificBuiltinType( || (compat::getParamType(*t, n)->isSpecificBuiltinType(
BuiltinType::UInt)))) BuiltinType::UInt))
|| (compat::getParamType(*t, n)->isSpecificBuiltinType(
BuiltinType::Long))))
{ {
reportWarning(i); reportWarning(i);
} }
......
#include<iostream>
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* /*
* This file is part of the LibreOffice project. * This file is part of the LibreOffice project.
...@@ -135,13 +136,18 @@ bool LiteralToBoolConversion::VisitImplicitCastExpr( ...@@ -135,13 +136,18 @@ bool LiteralToBoolConversion::VisitImplicitCastExpr(
<< expr->getType() << expr->getSourceRange(); << expr->getType() << expr->getSourceRange();
#endif #endif
} else if (sub->isIntegerConstantExpr(compiler.getASTContext())) { } else if (sub->isIntegerConstantExpr(compiler.getASTContext())) {
report( CallExpr const * ce = dyn_cast<CallExpr>(sub);
DiagnosticsEngine::Warning, if (ce == nullptr
("implicit conversion (%0) of integer constant expression of type" || ce->getBuiltinCallee() != Builtin::BI__builtin_expect)
" %1 to %2"), {
expr->getLocStart()) report(
<< expr->getCastKindName() << expr->getSubExpr()->getType() DiagnosticsEngine::Warning,
<< expr->getType() << expr->getSourceRange(); ("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; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment