loplugin:unusedmethods

Change-Id: I161cd52606c11b6008f5d8b1d8ee391692f91861
Reviewed-on: https://gerrit.libreoffice.org/19231
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
This commit is contained in:
Noel Grandin
2015-10-07 16:28:27 +02:00
committed by Noel Grandin
parent 1b4dff2c37
commit 644487a115
86 changed files with 74 additions and 2630 deletions

View File

@@ -251,7 +251,7 @@ bool UnusedMethods::VisitFunctionDecl( const FunctionDecl* functionDecl )
if (isa<CXXConstructorDecl>(functionDecl)) {
return true;
}
if (methodDecl && methodDecl->isDeleted()) {
if (functionDecl && functionDecl->isDeleted()) {
return true;
}

View File

@@ -7,6 +7,7 @@ import io
definitionSet = set()
definitionToSourceLocationMap = dict()
callSet = set()
sourceLocationSet = set()
# things we need to exclude for reasons like :
# - it's a weird template thingy that confuses the plugin
exclusionSet = set([
@@ -101,6 +102,8 @@ exclusionSet = set([
"void ImportXE(class SwDoc &,class SwPaM &,const class rtl::OUString &)",
"_Bool TestImportDOC(const class rtl::OUString &,const class rtl::OUString &)",
"class vcl::Window * CreateWindow(class VCLXWindow **,const struct com::sun::star::awt::WindowDescriptor *,class vcl::Window *,long)",
# only used when the ODBC driver is enabled
"_Bool getImplementation(type-parameter-?-? *&,const class com::sun::star::uno::Reference<class com::sun::star::uno::XInterface> &)",
])
# clang does not always use exactly the same numbers in the type-parameter vars it generates
@@ -123,6 +126,18 @@ with io.open(sys.argv[1], "rb", buffering=1024*1024) as txt:
idx1 = line.find("\t",6)
callSet.add((normalizeTypeParams(line[6:idx1]), normalizeTypeParams(line[idx1+1:].strip())))
# Invert the definitionToSourceLocationMap
# If we see more than one method at the same sourceLocation, it's being autogenerated as part of a template
# and we should just ignore
sourceLocationToDefinitionMap = {}
for k, v in definitionToSourceLocationMap.iteritems():
sourceLocationToDefinitionMap[v] = sourceLocationToDefinitionMap.get(v, [])
sourceLocationToDefinitionMap[v].append(k)
for k, definitions in sourceLocationToDefinitionMap.iteritems():
if len(definitions) > 1:
for d in definitions:
definitionSet.remove(d)
tmp1set = set()
for d in definitionSet:
clazz = d[0] + " " + d[1]
@@ -199,6 +214,8 @@ for d in definitionSet:
# ignore methods used to dump objects to stream - normally used for debugging
if d[0] == "class std::basic_ostream<char> &" and d[1].startswith("operator<<(class std::basic_ostream<char> &"):
continue
if d[0] == "basic_ostream<type-parameter-?-?, type-parameter-?-?> &" and d[1].startswith("operator<<(basic_ostream<type-parameter-?-?"):
continue
tmp1set.add((clazz, definitionToSourceLocationMap[d]))