[Libreoffice-commits] core.git: compilerplugins/clang editeng/source pyuno/source sdext/source sd/source svx/source sw/source unotools/source

Stephan Bergmann sbergman at redhat.com
Thu Aug 25 15:18:59 UTC 2016


 compilerplugins/clang/staticaccess.cxx             |   76 +++++++++++++++++++++
 compilerplugins/clang/staticcall.cxx               |   49 -------------
 editeng/source/misc/hangulhanja.cxx                |    8 +-
 pyuno/source/module/pyuno_module.cxx               |    2 
 sd/source/core/pglink.cxx                          |    4 -
 sdext/source/pdfimport/tree/drawtreevisiting.cxx   |    2 
 sdext/source/pdfimport/tree/writertreevisiting.cxx |    6 -
 svx/source/stbctrls/modctrl.cxx                    |    2 
 sw/source/filter/ww8/wrtww8.cxx                    |    4 -
 unotools/source/config/eventcfg.cxx                |    5 -
 10 files changed, 93 insertions(+), 65 deletions(-)

New commits:
commit 6810f00d09679644ec5971b235a0ec01dc572a8b
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Aug 25 17:16:14 2016 +0200

    loplugin:staticaccess: Extend loplugin:staticcall to cover all access...
    
    to static members (data, in addition to function) via class member access
    syntax.  Also covers the (somewhat obscure) access to enumerator members.
    
    Change-Id: Iec54b8df2fdb423c0caf21a0dd0f9fe8fdf33897

diff --git a/compilerplugins/clang/staticaccess.cxx b/compilerplugins/clang/staticaccess.cxx
new file mode 100644
index 0000000..7b825f3
--- /dev/null
+++ b/compilerplugins/clang/staticaccess.cxx
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <cassert>
+
+#include "plugin.hxx"
+
+namespace {
+
+bool isStatic(ValueDecl const * decl, bool * memberEnumerator) {
+    assert(memberEnumerator != nullptr);
+    // clang::MemberExpr::getMemberDecl is documented to return either a
+    // FieldDecl or a CXXMethodDecl, but can apparently also return a VarDecl
+    // (as C++ static data members are modeled by VarDecl, not FieldDecl) or an
+    // EnumConstantDecl (struct { enum {E}; } s; s.E;):
+    auto fd = dyn_cast<FieldDecl>(decl);
+    if (fd != nullptr) {
+        *memberEnumerator = false;
+        return false;
+    }
+    auto vd = dyn_cast<VarDecl>(decl);
+    if (vd != nullptr) {
+        *memberEnumerator = false;
+        return vd->isStaticDataMember();
+    }
+    auto md = dyn_cast<CXXMethodDecl>(decl);
+    if (md != nullptr) {
+        *memberEnumerator = false;
+        return md->isStatic();
+    }
+    assert(dyn_cast<EnumConstantDecl>(decl) != nullptr);
+    *memberEnumerator = true;
+    return true;
+}
+
+class StaticAccess:
+    public RecursiveASTVisitor<StaticAccess>, public loplugin::Plugin
+{
+public:
+    explicit StaticAccess(InstantiationData const & data): Plugin(data) {}
+
+    void run() override
+    { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
+
+    bool VisitMemberExpr(MemberExpr const * expr);
+};
+
+bool StaticAccess::VisitMemberExpr(MemberExpr const * expr) {
+    if (ignoreLocation(expr)) {
+        return true;
+    }
+    auto decl = expr->getMemberDecl();
+    bool me;
+    if (!isStatic(decl, &me)) {
+        return true;
+    }
+    report(
+        DiagnosticsEngine::Warning,
+        ("accessing %select{static class member|member enumerator}0 through"
+         " class member access syntax, use a qualified name like '%1' instead"),
+        expr->getLocStart())
+        << me << decl->getQualifiedNameAsString() << expr->getSourceRange();
+    return true;
+}
+
+loplugin::Plugin::Registration<StaticAccess> X("staticaccess");
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/staticcall.cxx b/compilerplugins/clang/staticcall.cxx
deleted file mode 100644
index 8bbfcb6..0000000
--- a/compilerplugins/clang/staticcall.cxx
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#include "plugin.hxx"
-
-namespace {
-
-class StaticCall:
-    public RecursiveASTVisitor<StaticCall>, public loplugin::Plugin
-{
-public:
-    explicit StaticCall(InstantiationData const & data): Plugin(data) {}
-
-    void run() override
-    { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
-
-    bool VisitCallExpr(CallExpr const * expr);
-};
-
-bool StaticCall::VisitCallExpr(CallExpr const * expr) {
-    if (ignoreLocation(expr)
-        || !isa<MemberExpr>(expr->getCallee()->IgnoreImpCasts()))
-    {
-        return true;
-    }
-    CXXMethodDecl const * decl = dyn_cast_or_null<CXXMethodDecl>(
-        expr->getDirectCallee());
-    if (decl != nullptr && decl->isStatic()) {
-        report(
-            DiagnosticsEngine::Warning,
-            ("calling static member function through member call syntax, use"
-             " '%0' instead"),
-            expr->getLocStart())
-            << decl->getQualifiedNameAsString() << expr->getSourceRange();
-    }
-    return true;
-}
-
-loplugin::Plugin::Registration<StaticCall> X("staticcall");
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/source/misc/hangulhanja.cxx b/editeng/source/misc/hangulhanja.cxx
index 374463d..b9d34a0 100644
--- a/editeng/source/misc/hangulhanja.cxx
+++ b/editeng/source/misc/hangulhanja.cxx
@@ -457,8 +457,8 @@ namespace editeng
             }
 
             // save currently used value for possible later use
-            m_pAntiImpl->m_bTryBothDirectionsSave = m_bTryBothDirections;
-            m_pAntiImpl->m_ePrimaryConversionDirectionSave = m_eCurrentConversionDirection;
+            HangulHanjaConversion::m_bTryBothDirectionsSave = m_bTryBothDirections;
+            HangulHanjaConversion::m_ePrimaryConversionDirectionSave = m_eCurrentConversionDirection;
         }
 
         bool bFoundAny = implUpdateSuggestions( true, _nStartAt );
@@ -652,8 +652,8 @@ namespace editeng
 
             if (HangulHanjaConversion::IsUseSavedConversionDirectionState())
             {
-                m_ePrimaryConversionDirection = m_pAntiImpl->m_ePrimaryConversionDirectionSave;
-                m_bTryBothDirections = m_pAntiImpl->m_bTryBothDirectionsSave;
+                m_ePrimaryConversionDirection = HangulHanjaConversion::m_ePrimaryConversionDirectionSave;
+                m_bTryBothDirections = HangulHanjaConversion::m_bTryBothDirectionsSave;
                 if( m_bTryBothDirections )
                     m_eCurrentConversionDirection = eDirection;
                 else
diff --git a/pyuno/source/module/pyuno_module.cxx b/pyuno/source/module/pyuno_module.cxx
index e3ab5d7..000b63d 100644
--- a/pyuno/source/module/pyuno_module.cxx
+++ b/pyuno/source/module/pyuno_module.cxx
@@ -268,7 +268,7 @@ static PyObject* getComponentContext(
             iniFileName.append( SAL_CONFIGFILE( "pyuno" ) );
             iniFile = iniFileName.makeStringAndClear();
             osl::DirectoryItem item;
-            if( osl::DirectoryItem::get( iniFile, item ) == item.E_None )
+            if( osl::DirectoryItem::get( iniFile, item ) == osl::FileBase::E_None )
             {
                 // in case pyuno.ini exists, use this file for bootstrapping
                 PyThreadDetach antiguard;
diff --git a/sd/source/core/pglink.cxx b/sd/source/core/pglink.cxx
index 6f54c58..83587d3 100644
--- a/sd/source/core/pglink.cxx
+++ b/sd/source/core/pglink.cxx
@@ -96,7 +96,7 @@ SdPageLink::~SdPageLink()
             bool bNoDialogs = false;
             bool bCopy = false;
 
-            if (pDoc->s_pDocLockedInsertingLinks)
+            if (SdDrawDocument::s_pDocLockedInsertingLinks)
             {
                 // resolving links while loading pDoc
                 bNoDialogs = true;
@@ -106,7 +106,7 @@ SdPageLink::~SdPageLink()
             pDoc->InsertBookmarkAsPage(aBookmarkList, nullptr, bLink, bReplace,
                                        nInsertPos, bNoDialogs, nullptr, bCopy, true, true);
 
-            if (!pDoc->s_pDocLockedInsertingLinks)
+            if (!SdDrawDocument::s_pDocLockedInsertingLinks)
                 pDoc->CloseBookmarkDoc();
         }
     }
diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx b/sdext/source/pdfimport/tree/drawtreevisiting.cxx
index 5eae94a..6da5e7d 100644
--- a/sdext/source/pdfimport/tree/drawtreevisiting.cxx
+++ b/sdext/source/pdfimport/tree/drawtreevisiting.cxx
@@ -170,7 +170,7 @@ void DrawXmlEmitter::visit( ParagraphElement& elem, const std::list< Element* >:
         aProps[ "text:style-name" ] = m_rEmitContext.rStyles.getStyleName( elem.StyleId );
     }
     const char* pTagType = "text:p";
-    if( elem.Type == elem.Headline )
+    if( elem.Type == ParagraphElement::Headline )
         pTagType = "text:h";
     m_rEmitContext.rEmitter.beginTag( pTagType, aProps );
 
diff --git a/sdext/source/pdfimport/tree/writertreevisiting.cxx b/sdext/source/pdfimport/tree/writertreevisiting.cxx
index 9e946e4..5184ea84 100644
--- a/sdext/source/pdfimport/tree/writertreevisiting.cxx
+++ b/sdext/source/pdfimport/tree/writertreevisiting.cxx
@@ -91,7 +91,7 @@ void WriterXmlEmitter::visit( ParagraphElement& elem, const std::list< Element*
         aProps[ "text:style-name" ] = m_rEmitContext.rStyles.getStyleName( elem.StyleId );
     }
     const char* pTagType = "text:p";
-    if( elem.Type == elem.Headline )
+    if( elem.Type == ParagraphElement::Headline )
         pTagType = "text:h";
     m_rEmitContext.rEmitter.beginTag( pTagType, aProps );
 
@@ -456,7 +456,7 @@ void WriterXmlOptimizer::visit( ParagraphElement& elem, const std::list< Element
                         // check for larger font
                         if( head_line_height > elem.getLineHeight( m_rProcessor ) )
                         {
-                            pPrevPara->Type = elem.Headline;
+                            pPrevPara->Type = ParagraphElement::Headline;
                         }
                         else
                         {
@@ -469,7 +469,7 @@ void WriterXmlOptimizer::visit( ParagraphElement& elem, const std::list< Element
                                 const FontAttributes& rPrevFont = m_rProcessor.getFont( pPrevText->FontId );
                                 const FontAttributes& rThisFont = m_rProcessor.getFont( pThisText->FontId );
                                 if( rPrevFont.isBold && ! rThisFont.isBold )
-                                    pPrevPara->Type = elem.Headline;
+                                    pPrevPara->Type = ParagraphElement::Headline;
                             }
                         }
                     }
diff --git a/svx/source/stbctrls/modctrl.cxx b/svx/source/stbctrls/modctrl.cxx
index b11a832..a838f88 100644
--- a/svx/source/stbctrls/modctrl.cxx
+++ b/svx/source/stbctrls/modctrl.cxx
@@ -69,7 +69,7 @@ SvxModifyControl::SvxModifyControl( sal_uInt16 _nSlotId, sal_uInt16 _nId, Status
 //#ifndef MACOSX
     if ( rStb.GetDPIScaleFactor() > 1 )
     {
-        for (int i = 0; i < mxImpl->MODIFICATION_STATE_SIZE; i++)
+        for (int i = 0; i < ImplData::MODIFICATION_STATE_SIZE; i++)
         {
             BitmapEx b = mxImpl->maImages[i].GetBitmapEx();
             b.Scale(rStb.GetDPIScaleFactor(), rStb.GetDPIScaleFactor(), BmpScaleFlag::Fast);
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index 947646d..843f45c 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -717,14 +717,14 @@ void WW8Export::ExportDopTypography(WW8DopTypography &rTypo)
                             (
                                 pForbidden->endLine,
                                 WW8DopTypography::GetJapanNotEndLevel1(),
-                                rTypo.nMaxLeading * sizeof(sal_Unicode)
+                                WW8DopTypography::nMaxLeading * sizeof(sal_Unicode)
                             )
                         &&
                           !lcl_CmpBeginEndChars
                             (
                                 pForbidden->beginLine,
                                 WW8DopTypography::GetJapanNotBeginLevel1(),
-                                rTypo.nMaxFollowing * sizeof(sal_Unicode)
+                                WW8DopTypography::nMaxFollowing * sizeof(sal_Unicode)
                             )
                         )
                     {
diff --git a/unotools/source/config/eventcfg.cxx b/unotools/source/config/eventcfg.cxx
index 19226c22e..353d107 100644
--- a/unotools/source/config/eventcfg.cxx
+++ b/unotools/source/config/eventcfg.cxx
@@ -26,7 +26,7 @@
 #include <cppuhelper/weakref.hxx>
 #include <o3tl/enumarray.hxx>
 #include <o3tl/enumrange.hxx>
-
+#include <rtl/ref.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <osl/diagnose.h>
 
@@ -389,7 +389,8 @@ OUString GlobalEventConfig::GetEventName( GlobalEventId nIndex )
 {
     if (utl::ConfigManager::IsAvoidConfig())
         return OUString();
-    return GlobalEventConfig().m_pImpl->GetEventName( nIndex );
+    rtl::Reference<GlobalEventConfig> createImpl(new GlobalEventConfig);
+    return GlobalEventConfig::m_pImpl->GetEventName( nIndex );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list