loplugin:unusedmethods

Remove a filtering step in the python script that was hiding some
results

Change-Id: Id94268f150902405ab197c077f18aaedf98845fc
Reviewed-on: https://gerrit.libreoffice.org/83256
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2019-11-20 09:21:03 +02:00
parent 1d69cf32a7
commit 98f2bd667c
44 changed files with 336 additions and 164 deletions

View File

@@ -33,7 +33,7 @@ def normalizeTypeParams( line ):
# primary input loop
# --------------------------------------------------------------------------------------------
with io.open("workdir/loplugin.unusedmethods.log", "rb", buffering=1024*1024) as txt:
with io.open("workdir/loplugin.unusedmethods.log", "rb", buffering=16*1024*1024) as txt:
for line in txt:
tokens = line.strip().split("\t")
if tokens[0] == "definition:":
@@ -68,16 +68,10 @@ with io.open("workdir/loplugin.unusedmethods.log", "rb", buffering=1024*1024) as
print( "unknown line: " + line)
# 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 it.
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)
def isOtherConstness( d, callSet ):
method = d[0] + " " + d[1]
@@ -162,6 +156,10 @@ for d in definitionSet:
continue
if d[0] == "basic_ostream<type-parameter-?-?, type-parameter-?-?> &" and d[1].startswith("operator<<(basic_ostream<type-parameter-?-?"):
continue
# ignore lambdas
if " ::operator " in method or " ::__invoke(" in method or " ::operator()" in method: continue
# stuff generated by Qt
if "::tr(" in method or "::trUtf8(" in method: continue
location = definitionToSourceLocationMap[d];
# whacky template stuff
@@ -174,6 +172,10 @@ for d in definitionSet:
if location.startswith("compilerplugins/clang/test"): continue
# leave this alone for now
if location.startswith("include/LibreOfficeKit"): continue
# template stuff
if location.startswith("include/vcl/vclptr.hxx"): continue
if location.startswith("include/oox/helper/refvector.hxx"): continue
if location.startswith("include/oox/drawingml/chart/modelbase.hxx"): continue
unusedSet.add(d) # used by the "unused return types" analysis
tmp1set.add((method, location))
@@ -232,11 +234,12 @@ for d in definitionSet:
if location.startswith("include/tools/stream.hxx"): continue
tmp2set.add((method, location))
#Disable this for now, not really using it
# print output, sorted by name and line number
with open("compilerplugins/clang/unusedmethods.unused-returns.results", "wt") as f:
for t in sort_set_by_natural_key(tmp2set):
f.write(t[1] + "\n")
f.write(" " + t[0] + "\n")
#with open("compilerplugins/clang/unusedmethods.unused-returns.results", "wt") as f:
# for t in sort_set_by_natural_key(tmp2set):
# f.write(t[1] + "\n")
# f.write(" " + t[0] + "\n")
# --------------------------------------------------------------------------------------------