[Libreoffice-commits] core.git: compilerplugins/clang

Stephan Bergmann sbergman at redhat.com
Tue Apr 17 18:46:53 UTC 2018


 compilerplugins/clang/casttovoid.cxx |    5 +++++
 1 file changed, 5 insertions(+)

New commits:
commit cb06f61967850f7c3bbaaf3575901d6a18b94c96
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Apr 17 17:13:50 2018 +0200

    More containsPreprocessingConditionalInclusion checking in loplugin:casttovoid
    
    ...to avoid false positive with --disable-dbgutil in SfxApplication ctor
    (sfx2/source/appl/app.cxx), which contains
    
        bool bOk = InitializeDde();
      #ifdef DBG_UTIL
        ...
      #else
        (void)bOk;
      #endif
    
    Change-Id: I4de6322a848a9c6aea3057e4598b2161888dee6a
    Reviewed-on: https://gerrit.libreoffice.org/53051
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/compilerplugins/clang/casttovoid.cxx b/compilerplugins/clang/casttovoid.cxx
index c67d7ca10870..e8b080dab2a5 100644
--- a/compilerplugins/clang/casttovoid.cxx
+++ b/compilerplugins/clang/casttovoid.cxx
@@ -380,6 +380,11 @@ private:
                 } else if (!i.second.castToVoid.empty()
                            && !isWarnUnusedType(i.first->getType()))
                 {
+                    auto const fun = dyn_cast_or_null<FunctionDecl>(i.first->getDeclContext());
+                    assert(fun != nullptr);
+                    if (containsPreprocessingConditionalInclusion(fun->getSourceRange())) {
+                        continue;
+                    }
                     report(
                         DiagnosticsEngine::Warning,
                         "unused variable %select{declaration|name}0",


More information about the Libreoffice-commits mailing list