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>
This commit is contained in:
Noel Grandin
2016-09-20 12:13:42 +02:00
parent 8a382d4ad1
commit b18e1bc61c
30 changed files with 97 additions and 148 deletions

View File

@@ -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
untouchedSet.add((clazz + " " + definitionToTypeMap[d], srcLoc))
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
# 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