summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-07-17 13:08:16 +0200
committerNoel Grandin <noelgrandin@gmail.com>2015-07-20 06:33:44 +0000
commit9f4f237a3834e5d58a87296424db5428f68d1550 (patch)
tree9e3e2fa55dc1a4d673d4c12e2af297bf32140204 /compilerplugins
parentfcdddbd30a8b5cf6a5cc4d2ff28b7d4a20f8ec6b (diff)
loplugin:unusedmethods svl
Change-Id: If86cc43fda4d138cf7f678d81fa2b35f68f3c03b Reviewed-on: https://gerrit.libreoffice.org/17162 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/unusedmethods.cxx9
-rwxr-xr-xcompilerplugins/clang/unusedmethods.py35
2 files changed, 35 insertions, 9 deletions
diff --git a/compilerplugins/clang/unusedmethods.cxx b/compilerplugins/clang/unusedmethods.cxx
index a137a216cfc6..6627fe90a0cc 100644
--- a/compilerplugins/clang/unusedmethods.cxx
+++ b/compilerplugins/clang/unusedmethods.cxx
@@ -124,12 +124,19 @@ static bool startsWith(const std::string& s, const char* other)
return s.compare(0, strlen(other), other) == 0;
}
-static bool isStandardStuff(const std::string& s)
+static bool isStandardStuff(const std::string& input)
{
+ std::string s = input;
+ if (startsWith(s,"class "))
+ s = s.substr(6);
+ else if (startsWith(s,"struct "))
+ s = s.substr(7);
// ignore UNO interface definitions, cannot change those
return startsWith(s, "com::sun::star::")
// ignore stuff in the C++ stdlib and boost
|| startsWith(s, "std::") || startsWith(s, "boost::") || startsWith(s, "class boost::") || startsWith(s, "__gnu_debug::")
+ // external library
+ || startsWith(s, "mdds::")
// can't change our rtl layer
|| startsWith(s, "rtl::")
// ignore anonymous namespace stuff, it is compilation-unit-local and the compiler will detect any
diff --git a/compilerplugins/clang/unusedmethods.py b/compilerplugins/clang/unusedmethods.py
index 2790408d89aa..27118b286c8b 100755
--- a/compilerplugins/clang/unusedmethods.py
+++ b/compilerplugins/clang/unusedmethods.py
@@ -57,6 +57,7 @@ exclusionSet = set([
# instantiated from templates, not sure why it is not being picked up
"class basegfx::B2DPolygon OutputDevice::PixelToLogic(const class basegfx::B2DPolygon &,const class MapMode &) const",
"type-parameter-0-0 * detail::cloner::clone(type-parameter-0-0 *const)",
+ "const class rtl::OUString writerperfect::DocumentHandlerFor::name()",
# only used by OSX build
"void StyleSettings::SetHideDisabledMenuItems(_Bool)",
])
@@ -87,20 +88,38 @@ for clazz in sorted(definitionSet - callSet - exclusionSet):
or (clazz.find("::Type()") != -1)):
continue
# if this method is const, and there is a non-const variant of it, and the non-const variant is in use, then leave it alone
- if (clazz.endswith(" const")
- and clazz[6:len(clazz)-6] in definitionSet
- and clazz[6:len(clazz)-6] in callSet):
- continue
+ if (clazz.startswith("const ") and clazz.endswith(" const")):
+ clazz2 = clazz[6:len(clazz)-12]
+ if (clazz2 in callSet):
+ continue
+ elif (clazz.endswith(" const")):
+ clazz2 = clazz[:len(clazz)-6]
+ if (clazz2 in callSet):
+ continue
+ if (clazz.endswith(" const") and clazz.find("::iterator") != -1):
+ clazz2 = clazz.replace("::const_iterator", "::iterator")
+ clazz2 = clazz2[:len(clazz)-6] # strip off " const"
+ if (clazz2 in callSet):
+ continue
# if this method is non-const, and there is a const variant of it, and the const variant is in use, then leave it alone
- if ((not clazz.endswith(" const"))
- and ("const " + clazz + " const") in definitionSet
- and ("const " + clazz + " const") in callSet):
+ if ((not clazz.endswith(" const")) and ("const " + clazz + " const") in callSet):
continue
+ if ((not clazz.endswith(" const")) and clazz.find("::iterator") != -1):
+ clazz2 = clazz.replace("::iterator", "::const_iterator") + " const"
+ if (clazz2 in callSet):
+ continue
# There is lots of macro magic going on in /home/noel/libo4/include/sax/fshelper.hxx that should be using C++11 varag templates
if clazz.startswith("void sax_fastparser::FastSerializerHelper::"):
continue
# used by Windows build
- if clazz.find("DdeTopic::") != -1 or clazz.find("DdeData::") != -1 or clazz.find("DdeService::") != -1:
+ if (clazz.find("DdeTopic::") != -1
+ or clazz.find("DdeData::") != -1
+ or clazz.find("DdeService::") != -1
+ or clazz.find("DdeTransaction::") != -1
+ or clazz.find("DdeConnection::") != -1
+ or clazz.find("DdeLink::") != -1
+ or clazz.find("DdeItem::") != -1
+ or clazz.find("DdeGetPutItem::") != -1):
continue
print clazz