compilerplugins/clang/redundantcast.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
New commits: commit a0b220b3a6946e54136c47acab587c3993dae6fa Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Tue Jan 14 19:52:56 2020 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Tue Jan 14 21:41:23 2020 +0100 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 <sberg...@redhat.com> diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx index 1f7765b8978d..862410c6484d 100644 --- a/compilerplugins/clang/redundantcast.cxx +++ b/compilerplugins/clang/redundantcast.cxx @@ -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", _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits