From 2e12d210cac8d031c21cdda9c37c1551f967ddc4 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 5 Aug 2020 09:58:34 +0200 Subject: Silence loplugin:staticmethods when the definition involves preprocessing ...to help avoid false positives. (Another option to silence such warnings is to add (void) this; to false-positive function bodies, but this new approach may be more natural in certain cases.) Change-Id: Ie6ea908730c596dbfb62ff42ae60dbd0a00a8fc9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100152 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- compilerplugins/clang/staticmethods.cxx | 4 ++++ emfio/source/reader/emfreader.cxx | 8 ++++---- vcl/inc/skia/salbmp.hxx | 6 ++++-- vcl/skia/gdiimpl.cxx | 7 +++++-- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/compilerplugins/clang/staticmethods.cxx b/compilerplugins/clang/staticmethods.cxx index 9b631c7eb659..86206022496f 100644 --- a/compilerplugins/clang/staticmethods.cxx +++ b/compilerplugins/clang/staticmethods.cxx @@ -218,6 +218,10 @@ bool StaticMethods::TraverseCXXMethodDecl(const CXXMethodDecl * pCXXMethodDecl) return true; } + if (containsPreprocessingConditionalInclusion((pCXXMethodDecl->getSourceRange()))) { + return true; + } + report( DiagnosticsEngine::Warning, "this member function can be declared static", diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index 5d2749d16356..8c128d2965c6 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -386,9 +386,11 @@ namespace emfio const sal_uInt32 EMR_COMMENT_ENDGROUP = 0x00000003; const sal_uInt32 EMR_COMMENT_MULTIFORMATS = 0x40000004; const sal_uInt32 EMR_COMMENT_WINDOWS_METAFILE = 0x80000001; +#endif void EmfReader::ReadGDIComment(sal_uInt32 nCommentId) { +#if OSL_DEBUG_LEVEL > 0 sal_uInt32 nPublicCommentIdentifier; mpInputStream->ReadUInt32(nPublicCommentIdentifier); @@ -442,12 +444,10 @@ namespace emfio SAL_WARN("emfio", "\t\tEMR_COMMENT_PUBLIC not implemented, id: 0x" << std::hex << nCommentId << std::dec); break; } - } #else - void EmfReader::ReadGDIComment(sal_uInt32) - { - } + (void) nCommentId; #endif + } void EmfReader::ReadEMFPlusComment(sal_uInt32 length, bool& bHaveDC) { diff --git a/vcl/inc/skia/salbmp.hxx b/vcl/inc/skia/salbmp.hxx index 3725c9f9a8ec..6ce94aad1b01 100644 --- a/vcl/inc/skia/salbmp.hxx +++ b/vcl/inc/skia/salbmp.hxx @@ -101,10 +101,12 @@ private: bool ComputeScanlineSize(); void EraseInternal(); SkBitmap GetAsSkBitmap() const; + void verify() const #ifdef DBG_UTIL - void verify() const; + ; #else - void verify() const {}; + { + } #endif template diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index 066311e97c2b..c092bb549a22 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -176,17 +176,20 @@ public: } #ifndef NDEBUG virtual ~SkiaFlushIdle() { free(debugname); } +#endif const char* get_debug_name(SkiaSalGraphicsImpl* pGraphics) { +#ifndef NDEBUG // Idle keeps just a pointer, so we need to store the string debugname = strdup( OString("skia idle 0x" + OString::number(reinterpret_cast(pGraphics), 16)) .getStr()); return debugname; - } #else - const char* get_debug_name(SkiaSalGraphicsImpl*) { return "skia idle"; } + (void)pGraphics; + return "skia idle"; #endif + } virtual void Invoke() override { -- cgit