bin/find-unused-using.sh | 42
++
chart2/source/controller/chartapiwrapper/AreaWrapper.cxx |1
chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx |1
chart2/source/controller/chartapiwrapper/LegendWrapper.cxx|1
chart2/source/controller/chartapiwrapper/TitleWrapper.cxx |1
chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx |1
chart2/source/tools/CachedDataSequence.cxx|2
comphelper/source/misc/docpasswordhelper.cxx |1
connectivity/source/drivers/postgresql/pq_driver.cxx |2
dbaccess/source/core/recovery/subcomponentrecovery.cxx|2
dbaccess/source/ui/misc/controllerframe.cxx |1
extensions/source/propctrlr/eventhandler.cxx |1
forms/source/xforms/submission.cxx|2
fpicker/source/office/contentenumeration.cxx |1
fpicker/source/win32/WinImplHelper.cxx|6 -
odk/examples/cpp/complextoolbarcontrols/ListenerHelper.cxx|1
odk/examples/cpp/complextoolbarcontrols/MyJob.cxx |3
sc/source/core/data/table5.cxx|2
sd/source/core/stlsheet.cxx |1
sfx2/source/doc/docundomanager.cxx|1
shell/source/win32/simplemail/smplmailclient.cxx |1
shell/source/win32/simplemail/smplmailsuppl.cxx |1
svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx |1
vcl/win/dtrans/MtaOleClipb.cxx|5 -
writerperfect/source/common/DocumentHandler.cxx |1
xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx |2
xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.cxx |2
xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx|3
xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx |1
29 files changed, 42 insertions(+), 48 deletions(-)
New commits:
commit 75ed56689427f972ce58e395af8aaf951dda7581
Author: Gabor Kelemen
AuthorDate: Sat Apr 15 21:22:45 2023 +0200
Commit: Miklos Vajna
CommitDate: Tue Apr 25 08:09:28 2023 +0200
Add script to find unused using declarations
As a complementer to clang-tidy-12 --checks="-*,misc-unused-using-decls"
Pros:
- simple, fast!
- finds some more unused declarations, somehow
- works on non-linux specific parts of the code
- clang-tidy (for me) trips on files with external headers, this does not
Change-Id: If2db989114ac5c2841ed2e89ff7bd7a9e419f567
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150612
Tested-by: Jenkins
Reviewed-by: Miklos Vajna
diff --git a/bin/find-unused-using.sh b/bin/find-unused-using.sh
new file mode 100755
index ..3521f64f49fd
--- /dev/null
+++ b/bin/find-unused-using.sh
@@ -0,0 +1,42 @@
+# 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/.
+#!/bin/bash
+
+# TODO search also for 'using namespace com/::com/css' - this is likely the
fattest target and clang-tidy can't do it
+for ns in accessibility basegfx chart com css cppu comphelper connectivity
formula dbtools editeng rtl sfx2 svt osl oox sax_fastparser sal sd ucbhelper
utl vcl xmloff; do
+echo "Searching for namespace: $ns";
+# search in cxx files, excluding URE headers, plus some files with false
positives
+for file in $(git grep -l "^\s*using :*$ns::" *hxx *cxx \
+':!include/com/' \
+':!include/cppu/' \
+':!include/cppuhelper/' \
+':!include/osl/' \
+':!include/rtl/' \
+':!include/sal/' \
+':!include/salhelper/' \
+':!include/systools/' \
+':!include/typelib/' \
+':!include/uno/' \
+':!include/sfx2/stbitem.hxx' \
+':!sw/source/uibase/inc/maildispatcher.hxx'
+) ; do
+for class in $(git grep -h "using :*$ns::" "$file" | rev | cut -d :
-f -1 | rev | cut -d " " -f 1 | tr -d ";") ; do
+if [ "$ns" == "com" ] ; then # com namespace may be mentioned in
relevant header name too
+if [[ $(grep -c "$class" "$file") -eq 1 || $(grep -c "$class"
"$file") -le 2 && $(grep -c -e "$class".hpp -e "$class".hxx -e "$class".h
"$file") -eq 1 ]]; then
+echo "$file";
+echo "Class name in above file is mentioned once or twice:
$class";
+fi
+