summaryrefslogtreecommitdiffstats
path: root/compilerplugins/clang/unusedfields.py
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2016-09-20 12:13:42 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2016-09-20 10:45:14 +0000
commitb18e1bc61ccba9d0c74274e2fe45b2b422c601cf (patch)
tree13d90e6939c5d152c30b948148125be7b0cb6f22 /compilerplugins/clang/unusedfields.py
parentRelated: rhbz#1362451 avoid recursive ownerchanged handling during ownerchange (diff)
downloadcore-b18e1bc61ccba9d0c74274e2fe45b2b422c601cf.tar.gz
core-b18e1bc61ccba9d0c74274e2fe45b2b422c601cf.zip
loplugin:unusedfields
Change-Id: I852e98b16fdcb88b04e39d11e3101d502c918c24 Reviewed-on: https://gerrit.libreoffice.org/29078 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins/clang/unusedfields.py')
-rwxr-xr-xcompilerplugins/clang/unusedfields.py53
1 files changed, 30 insertions, 23 deletions
diff --git a/compilerplugins/clang/unusedfields.py b/compilerplugins/clang/unusedfields.py
index c3b51457ff58..be5a5ca54351 100755
--- a/compilerplugins/clang/unusedfields.py
+++ b/compilerplugins/clang/unusedfields.py
@@ -10,10 +10,6 @@ definitionToTypeMap = dict()
callSet = set()
readFromSet = set()
sourceLocationSet = set()
-# things we need to exclude for reasons like :
-# - it's a weird template thingy that confuses the plugin
-exclusionSet = set([
- ])
# clang does not always use exactly the same numbers in the type-parameter vars it generates
# so I need to substitute them to ensure we can match correctly.
@@ -27,18 +23,24 @@ with io.open("loplugin.unusedfields.log", "rb", buffering=1024*1024) as txt:
for line in txt:
tokens = line.strip().split("\t")
if tokens[0] == "definition:":
- funcInfo = (normalizeTypeParams(tokens[1]), tokens[2])
- definitionSet.add(funcInfo)
- definitionToTypeMap[funcInfo] = tokens[3]
- definitionToSourceLocationMap[funcInfo] = tokens[4]
+ fieldInfo = (normalizeTypeParams(tokens[1]), tokens[2])
+ definitionSet.add(fieldInfo)
+ definitionToTypeMap[fieldInfo] = tokens[3]
+ definitionToSourceLocationMap[fieldInfo] = tokens[4]
elif tokens[0] == "touch:":
- callInfo = (normalizeTypeParams(tokens[1]), tokens[2])
- callSet.add(callInfo)
+ if len(tokens) == 3:
+ callInfo = (normalizeTypeParams(tokens[1]), tokens[2])
+ callSet.add(callInfo)
+ else:
+ callInfo = (normalizeTypeParams(tokens[1]), "")
+ callSet.add(callInfo)
elif tokens[0] == "read:":
- idx1 = line.find("\t",6)
- readInfo = (normalizeTypeParams(tokens[1]), tokens[2])
- readFromSet.add(readInfo)
-
+ if len(tokens) == 3:
+ readInfo = (normalizeTypeParams(tokens[1]), tokens[2])
+ readFromSet.add(readInfo)
+ else:
+ readInfo = (normalizeTypeParams(tokens[1]), "")
+ readFromSet.add(readInfo)
# 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
@@ -53,9 +55,6 @@ for k, definitions in sourceLocationToDefinitionMap.iteritems():
untouchedSet = set()
for d in definitionSet:
- clazz = d[0] + " " + d[1]
- if clazz in exclusionSet:
- continue
if d in callSet:
continue
srcLoc = definitionToSourceLocationMap[d];
@@ -86,9 +85,22 @@ for d in definitionSet:
or srcLoc.startswith("vcl/inc/unx/gtk/gloactiongroup.h")
or srcLoc.startswith("include/svl/svdde.hxx")
or srcLoc.startswith("lotuswordpro/source/filter/lwpsdwdrawheader.hxx")
+ or srcLoc.startswith("hwpfilter/")
+ or srcLoc.startswith("embeddedobj/source/inc/")
or srcLoc.startswith("svtools/source/dialogs/insdlg.cxx")):
+ or srcLoc.startswith("bridges/")):
+ continue
+ if d[0] in set([ "AtkObjectWrapperClass", "AtkObjectWrapper", "GLOMenu", "GLOAction", "_XRegion", "SalMenuButtonItem", "Vertex",
+ "OOoMountOperationClass", "SwCSS1ItemIds", "ScCompiler::AddInMap", "MemoryByteGrabber", "textcat_t", "fp_t", "ngram_t",
+ "ImplPPTParaPropSet", "DataNode"]):
continue
- untouchedSet.add((clazz + " " + definitionToTypeMap[d], srcLoc))
+ # unit testing code
+ if (srcLoc.startswith("cppu/source/uno/check.cxx"):
+ continue
+ fieldType = definitionToTypeMap[d]
+ if fieldType in set([ "class rptui::OModuleClient" ]):
+ continue
+ untouchedSet.add((d[0] + " " + d[1] + " " + fieldType, srcLoc))
writeonlySet = set()
for d in definitionSet:
@@ -147,9 +159,4 @@ with open("loplugin.unusedfields.report-writeonly", "wt") as f:
f.write( t[1] + "\n" )
f.write( " " + t[0] + "\n" )
-
-
-# add an empty line at the end to make it easier for the unusedFieldsremove plugin to mmap() the output file
-print
-