Avoid loplugin:redundantcast from within qWarning macro
...as seen with qt5-qtbase-devel-5.13.2-1.fc31.x86_64: > vcl/unx/gtk3_kde5/kde5_filepicker_ipc.cxx:367:5: error: redundant static_cast from 'const char [65]' to 'const char *' [loplugin:redundantcast] > qWarning() << "unhandled command " << static_cast<uint16_t>(command); > ^~~~~~~~ > /usr/include/qt5/QtCore/qlogging.h:167:33: note: expanded from macro 'qWarning' > #define qWarning QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC).warning > ^~~~~~~~~~~~~~~~~~ > /usr/include/qt5/QtCore/qlogging.h:156:30: note: expanded from macro 'QT_MESSAGELOG_FILE' > #define QT_MESSAGELOG_FILE static_cast<const char *>(__FILE__) > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Change-Id: I9578b07cfd1a2de570ae2ab5842d65ef708f5d6a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86802 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
@@ -155,6 +155,12 @@ private:
|
||||
bool visitBinOp(BinaryOperator const * expr);
|
||||
void visitAssign(QualType lhs, Expr const * rhs);
|
||||
bool isOverloadedFunction(FunctionDecl const * decl);
|
||||
|
||||
bool isInIgnoredMacroBody(Expr const * expr) {
|
||||
auto const loc = compat::getBeginLoc(expr);
|
||||
return compiler.getSourceManager().isMacroBodyExpansion(loc)
|
||||
&& ignoreLocation(compiler.getSourceManager().getSpellingLoc(loc));
|
||||
}
|
||||
};
|
||||
|
||||
bool RedundantCast::VisitImplicitCastExpr(const ImplicitCastExpr * expr) {
|
||||
@@ -435,7 +441,8 @@ bool RedundantCast::VisitCXXStaticCastExpr(CXXStaticCastExpr const * expr) {
|
||||
|| loplugin::isSamePathname(
|
||||
fn, SRCDIR "/sal/qa/rtl/strings/test_oustring_concat.cxx")
|
||||
|| loplugin::isSamePathname(
|
||||
fn, SRCDIR "/sal/qa/rtl/strings/test_oustring_stringliterals.cxx")))
|
||||
fn, SRCDIR "/sal/qa/rtl/strings/test_oustring_stringliterals.cxx")
|
||||
|| isInIgnoredMacroBody(expr)))
|
||||
{
|
||||
report(
|
||||
DiagnosticsEngine::Warning, "redundant static_cast from %0 to %1",
|
||||
|
Reference in New Issue
Block a user