[Libreoffice-commits] core.git: bin/find-can-be-private-symbols.py include/basic include/sfx2 include/svtools include/vcl sc/inc sc/qa sfx2/inc svtools/source sw/inc vcl/inc xmlsecurity/inc xmlsecurity/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri Nov 29 12:16:39 UTC 2019


 bin/find-can-be-private-symbols.py          |   29 ++++++++++++++++++++++------
 include/basic/sbuno.hxx                     |    2 -
 include/sfx2/dockwin.hxx                    |    2 -
 include/svtools/sampletext.hxx              |    3 --
 include/vcl/builder.hxx                     |    2 -
 sc/inc/scresid.hxx                          |    2 -
 sc/qa/unit/helper/qahelper.cxx              |    2 -
 sc/qa/unit/helper/qahelper.hxx              |   14 +++++--------
 sfx2/inc/fwkhelper.hxx                      |    2 -
 svtools/source/misc/sampletext.cxx          |    6 ++---
 sw/inc/pam.hxx                              |    2 -
 vcl/inc/salinst.hxx                         |    2 -
 xmlsecurity/inc/xmlsec/errorcallback.hxx    |    4 +--
 xmlsecurity/source/xmlsec/errorcallback.cxx |    4 +--
 14 files changed, 44 insertions(+), 32 deletions(-)

New commits:
commit 5e55f7a54170b25aaf82520c1cde307ece362eef
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Nov 28 20:32:19 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Nov 29 13:15:28 2019 +0100

    make some function symbols module private
    
    improve the script to filter out more noise generated by library symbols
    
    Change-Id: I22bf6037d56bc4015001825c3fb3b21a39d85e07
    Reviewed-on: https://gerrit.libreoffice.org/84022
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/bin/find-can-be-private-symbols.py b/bin/find-can-be-private-symbols.py
index 0ff17072361a..a795abdb9208 100755
--- a/bin/find-can-be-private-symbols.py
+++ b/bin/find-can-be-private-symbols.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python2
 #
 # Find exported symbols that can be made non-exported.
 #
@@ -22,6 +22,21 @@ import re
 
 exported_symbols = set()
 imported_symbols = set()
+# standalone functions that are exported but not imported
+unused_function_exports = set()
+classes_with_exported_symbols = set()
+classes_with_imported_symbols = set()
+# all names that exist in the source code
+all_source_names = set()
+
+
+# look for imported symbols in executables
+subprocess_find_all_source_names = subprocess.Popen("git grep -oh -P '\\b\\w\\w\\w+\\b' -- '*.h*'", stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
+with subprocess_find_all_source_names.stdout as txt:
+    for line in txt:
+        line = line.strip()
+        all_source_names.add(line)
+subprocess_find_all_source_names.terminate()
 
 subprocess_find = subprocess.Popen("find ./instdir -name *.so && find ./workdir/LinkTarget/CppunitTest -name *.so", stdout=subprocess.PIPE, shell=True)
 with subprocess_find.stdout as txt:
@@ -76,11 +91,6 @@ print("exported = " + str(len(exported_symbols)))
 print("imported = " + str(len(imported_symbols)))
 print("diff     = " + str(len(diff)))
 
-# standalone functions that are exported but not imported
-unused_function_exports = set()
-classes_with_exported_symbols = set()
-classes_with_imported_symbols = set()
-
 for sym in exported_symbols:
     filtered_sym = subprocess.check_output(["c++filt", sym]).strip()
     if filtered_sym.startswith("non-virtual thunk to "): filtered_sym = filtered_sym[21:]
@@ -106,6 +116,11 @@ for sym in imported_symbols:
         classname = filtered_sym[:i]
         classes_with_imported_symbols.add(classname)
 
+def extractFunctionNameFromSignature(sym):
+    i = sym.find("(")
+    if i == -1: return sym
+    return sym[:i]
+
 with open("bin/find-can-be-private-symbols.functions.results", "wt") as f:
     for sym in sorted(unused_function_exports):
         # Filter out most of the noise.
@@ -189,6 +204,8 @@ with open("bin/find-can-be-private-symbols.functions.results", "wt") as f:
         elif sym.startswith("typelib_"): continue
         elif sym.startswith("typereg_"): continue
         elif sym.startswith("uno_"): continue
+        # remove things we found that do not exist in our source code, they're not ours
+        if not(extractFunctionNameFromSignature(sym) in all_source_names): continue
         f.write(sym + "\n")
 
 with open("bin/find-can-be-private-symbols.classes.results", "wt") as f:
diff --git a/include/basic/sbuno.hxx b/include/basic/sbuno.hxx
index 4029d9032f99..4c53215d9c88 100644
--- a/include/basic/sbuno.hxx
+++ b/include/basic/sbuno.hxx
@@ -38,7 +38,7 @@ BASIC_DLLPUBLIC void createAllObjectProperties( SbxObject* pObj );
 BASIC_DLLPUBLIC void SetSbUnoObjectDfltPropName( SbxObject* pObj );
 
 BASIC_DLLPUBLIC css::uno::Any sbxToUnoValue( const SbxValue* pVar );
-BASIC_DLLPUBLIC css::uno::Any sbxToUnoValue( const SbxValue* pVar, const css::uno::Type& rType, css::beans::Property const * pUnoProperty = nullptr );
+css::uno::Any sbxToUnoValue( const SbxValue* pVar, const css::uno::Type& rType, css::beans::Property const * pUnoProperty = nullptr );
 
 BASIC_DLLPUBLIC void unoToSbxValue( SbxVariable* pVar, const css::uno::Any& aValue );
 
diff --git a/include/sfx2/dockwin.hxx b/include/sfx2/dockwin.hxx
index d22052efd60b..aa4865c37e77 100644
--- a/include/sfx2/dockwin.hxx
+++ b/include/sfx2/dockwin.hxx
@@ -35,7 +35,7 @@ class SfxDockingWindow_Impl;
 enum class SplitWindowItemFlags;
 
 void SfxDockingWindowFactory( const css::uno::Reference< css::frame::XFrame >& rFrame, const OUString& rDockingWindowName );
-bool SFX2_DLLPUBLIC IsDockingWindowVisible( const css::uno::Reference< css::frame::XFrame >& rFrame, const OUString& rDockingWindowName );
+bool IsDockingWindowVisible( const css::uno::Reference< css::frame::XFrame >& rFrame, const OUString& rDockingWindowName );
 
 class SFX2_DLLPUBLIC SfxDockingWindow : public DockingWindow
 {
diff --git a/include/svtools/sampletext.hxx b/include/svtools/sampletext.hxx
index 08ef22fdfa0b..9c32cba7b545 100644
--- a/include/svtools/sampletext.hxx
+++ b/include/svtools/sampletext.hxx
@@ -35,9 +35,6 @@ OUString makeShortMinimalTextForScript(UScriptCode eScript);
 
 //These ones are typically for use in the font preview window in format character
 SVT_DLLPUBLIC OUString makeRepresentativeTextForFont(sal_Int16 nScriptType, const vcl::Font &rFont);
-SVT_DLLPUBLIC OUString makeRepresentativeTextForLanguage(LanguageType eLang);
-SVT_DLLPUBLIC OUString makeRepresentativeTextForScript(UScriptCode eScript);
-SVT_DLLPUBLIC OUString makeMinimalTextForScript(UScriptCode eScript);
 
 
 #endif
diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx
index 0d18c85523dd..0dea516c7f2a 100644
--- a/include/vcl/builder.hxx
+++ b/include/vcl/builder.hxx
@@ -506,7 +506,7 @@ protected:
 /*
  * @return true if rValue is "True", "true", "1", etc.
  */
-bool VCL_DLLPUBLIC toBool(const OUString &rValue);
+bool toBool(const OUString &rValue);
 
 #endif
 
diff --git a/sc/inc/scresid.hxx b/sc/inc/scresid.hxx
index 5a63bd809fb5..a9b7f2798a6d 100644
--- a/sc/inc/scresid.hxx
+++ b/sc/inc/scresid.hxx
@@ -24,7 +24,7 @@
 #include "scdllapi.h"
 
 OUString SC_DLLPUBLIC ScResId(const char* pId);
-OUString SC_DLLPUBLIC ScResId(const char* pId, int nCardinality);
+OUString ScResId(const char* pId, int nCardinality);
 
 #endif // SC_SCRESMGR_HXX
 
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index b1d70b3e30d3..73540c9a4233 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -343,7 +343,7 @@ const SdrOle2Obj* getSingleChartObject(ScDocument& rDoc, sal_uInt16 nPage)
     return pObj;
 }
 
-std::vector<OUString> getChartRangeRepresentations(const SdrOle2Obj& rChartObj)
+static std::vector<OUString> getChartRangeRepresentations(const SdrOle2Obj& rChartObj)
 {
     std::vector<OUString> aRangeReps;
 
diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx
index fa284defb7a8..3e8e5d455484 100644
--- a/sc/qa/unit/helper/qahelper.hxx
+++ b/sc/qa/unit/helper/qahelper.hxx
@@ -115,7 +115,7 @@ SCQAHELPER_DLLPUBLIC std::ostream& operator<<(std::ostream& rStrm, const OpCode&
 // eventually perhaps iOS) special cases here, too)?  Please move this to osl,
 // it sure looks generally useful. Or am I missing something?
 
-SCQAHELPER_DLLPUBLIC void loadFile(const OUString& aFileName, std::string& aContent);
+void loadFile(const OUString& aFileName, std::string& aContent);
 
 SCQAHELPER_DLLPUBLIC void testFile(const OUString& aFileName, ScDocument& rDoc, SCTAB nTab, StringType aStringFormat = StringType::StringValue);
 
@@ -126,17 +126,15 @@ SCQAHELPER_DLLPUBLIC const SdrOle2Obj* getSingleOleObject(ScDocument& rDoc, sal_
 
 SCQAHELPER_DLLPUBLIC const SdrOle2Obj* getSingleChartObject(ScDocument& rDoc, sal_uInt16 nPage);
 
-SCQAHELPER_DLLPUBLIC std::vector<OUString> getChartRangeRepresentations(const SdrOle2Obj& rChartObj);
-
 SCQAHELPER_DLLPUBLIC ScRangeList getChartRanges(ScDocument& rDoc, const SdrOle2Obj& rChartObj);
 
-SCQAHELPER_DLLPUBLIC bool checkFormula(ScDocument& rDoc, const ScAddress& rPos, const char* pExpected);
+bool checkFormula(ScDocument& rDoc, const ScAddress& rPos, const char* pExpected);
 
-SCQAHELPER_DLLPUBLIC bool checkFormulaPosition(ScDocument& rDoc, const ScAddress& rPos);
-SCQAHELPER_DLLPUBLIC bool checkFormulaPositions(
+bool checkFormulaPosition(ScDocument& rDoc, const ScAddress& rPos);
+bool checkFormulaPositions(
     ScDocument& rDoc, SCTAB nTab, SCCOL nCol, const SCROW* pRows, size_t nRowCount);
 
-SCQAHELPER_DLLPUBLIC std::unique_ptr<ScTokenArray> compileFormula(
+std::unique_ptr<ScTokenArray> compileFormula(
     ScDocument* pDoc, const OUString& rFormula,
     formula::FormulaGrammar::Grammar eGram = formula::FormulaGrammar::GRAM_NATIVE );
 
@@ -144,7 +142,7 @@ SCQAHELPER_DLLPUBLIC bool checkOutput(
     const ScDocument* pDoc, const ScRange& aOutRange,
     const std::vector<std::vector<const char*>>& aCheck, const char* pCaption );
 
-SCQAHELPER_DLLPUBLIC void clearFormulaCellChangedFlag( ScDocument& rDoc, const ScRange& rRange );
+void clearFormulaCellChangedFlag( ScDocument& rDoc, const ScRange& rRange );
 
 /**
  * Check if the cell at specified position is a formula cell that doesn't
diff --git a/sfx2/inc/fwkhelper.hxx b/sfx2/inc/fwkhelper.hxx
index d92deb0e7b29..bb37cab3f0f3 100644
--- a/sfx2/inc/fwkhelper.hxx
+++ b/sfx2/inc/fwkhelper.hxx
@@ -27,7 +27,7 @@
 
 #include <rtl/ustring.hxx>
 
-SFX2_DLLPUBLIC void RefreshToolbars(
+void RefreshToolbars(
     css::uno::Reference< css::frame::XFrame > const & rFrame
 );
 
diff --git a/svtools/source/misc/sampletext.cxx b/svtools/source/misc/sampletext.cxx
index 23d4f237b73a..1d85d4a94d87 100644
--- a/svtools/source/misc/sampletext.cxx
+++ b/svtools/source/misc/sampletext.cxx
@@ -530,7 +530,7 @@ OUString makeShortRepresentativeTextForScript(UScriptCode eScript)
     return sSampleText;
 }
 
-OUString makeRepresentativeTextForScript(UScriptCode eScript)
+static OUString makeRepresentativeTextForScript(UScriptCode eScript)
 {
     OUString sSampleText;
     switch (eScript)
@@ -602,7 +602,7 @@ OUString makeShortMinimalTextForScript(UScriptCode eScript)
     return sSampleText;
 }
 
-OUString makeMinimalTextForScript(UScriptCode eScript)
+static OUString makeMinimalTextForScript(UScriptCode eScript)
 {
     return makeShortMinimalTextForScript(eScript);
 }
@@ -615,7 +615,7 @@ OUString makeMinimalTextForScript(UScriptCode eScript)
 
 //Currently we fall back to makeShortRepresentativeTextForScript when we don't
 //have suitable strings
-OUString makeRepresentativeTextForLanguage(LanguageType eLang)
+static OUString makeRepresentativeTextForLanguage(LanguageType eLang)
 {
     OUString sRet;
     LanguageType pri = primary(eLang);
diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx
index 07ca7ff949a2..f94c796d1bfb 100644
--- a/sw/inc/pam.hxx
+++ b/sw/inc/pam.hxx
@@ -277,7 +277,7 @@ public:
 
 SW_DLLPUBLIC std::ostream &operator <<(std::ostream& s, const SwPaM& pam);
 
-SW_DLLPUBLIC bool CheckNodesRange(const SwNodeIndex&, const SwNodeIndex&, bool bChkSection);
+bool CheckNodesRange(const SwNodeIndex&, const SwNodeIndex&, bool bChkSection);
 
 #endif // INCLUDED_SW_INC_PAM_HXX
 
diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx
index f8935baf218a..0f8af0b200d3 100644
--- a/vcl/inc/salinst.hxx
+++ b/vcl/inc/salinst.hxx
@@ -212,7 +212,7 @@ void DestroySalInstance( SalInstance* pInst );
 
 void SalAbort( const OUString& rErrorText, bool bDumpCore );
 
-VCL_DLLPUBLIC const OUString& SalGetDesktopEnvironment();
+const OUString& SalGetDesktopEnvironment();
 
 #endif // INCLUDED_VCL_INC_SALINST_HXX
 
diff --git a/xmlsecurity/inc/xmlsec/errorcallback.hxx b/xmlsecurity/inc/xmlsec/errorcallback.hxx
index afb17b0da189..511d20ae1840 100644
--- a/xmlsecurity/inc/xmlsec/errorcallback.hxx
+++ b/xmlsecurity/inc/xmlsec/errorcallback.hxx
@@ -23,10 +23,10 @@
 #include <xsecxmlsecdllapi.h>
 
 // Only used for logging
-XSECXMLSEC_DLLPUBLIC void setErrorRecorder();
+void setErrorRecorder();
 //ToDo
 //void setErrorRecorder(const css::uno::Reference< css::xml::crypto::XXMLEncryptionTemplate >& xTemplate);
-XSECXMLSEC_DLLPUBLIC void clearErrorRecorder();
+void clearErrorRecorder();
 
 #endif
 
diff --git a/xmlsecurity/source/xmlsec/errorcallback.cxx b/xmlsecurity/source/xmlsec/errorcallback.cxx
index c621c1bf715c..0749524056cb 100644
--- a/xmlsecurity/source/xmlsec/errorcallback.cxx
+++ b/xmlsecurity/source/xmlsec/errorcallback.cxx
@@ -54,12 +54,12 @@ static void errorCallback(const char* file,
 
 }
 
-XSECXMLSEC_DLLPUBLIC void setErrorRecorder()
+void setErrorRecorder()
 {
     xmlSecErrorsSetCallback(errorCallback);
 }
 
-XSECXMLSEC_DLLPUBLIC void clearErrorRecorder()
+void clearErrorRecorder()
 {
     xmlSecErrorsSetCallback(nullptr);
 }


More information about the Libreoffice-commits mailing list