summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-10-07 16:28:27 +0200
committerNoel Grandin <noelgrandin@gmail.com>2015-10-27 08:20:43 +0000
commit644487a1152c7586a7f20c7f372572a71d8494d5 (patch)
tree683cdbd755ec1660e75f930e5be4cd6867e3e734 /compilerplugins
parent1b4dff2c371d31c99f34324c3f6f31888bdc34d7 (diff)
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>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/unusedmethods.cxx2
-rwxr-xr-xcompilerplugins/clang/unusedmethods.py17
2 files changed, 18 insertions, 1 deletions
diff --git a/compilerplugins/clang/unusedmethods.cxx b/compilerplugins/clang/unusedmethods.cxx
index a5550312e155..3a9209b69b2b 100644
--- a/compilerplugins/clang/unusedmethods.cxx
+++ b/compilerplugins/clang/unusedmethods.cxx
@@ -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;
}
diff --git a/compilerplugins/clang/unusedmethods.py b/compilerplugins/clang/unusedmethods.py
index fd17cb5c2f7d..0c2cdff7f640 100755
--- a/compilerplugins/clang/unusedmethods.py
+++ b/compilerplugins/clang/unusedmethods.py
@@ -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]))