7 definitionToSourceLocationMap
= dict()
11 with io
.open("workdir/loplugin.virtualdown.log", "rb", buffering
=1024*1024) as txt
:
13 tokens
= line
.strip().split("\t")
14 if tokens
[0] == "definition:":
15 fullMethodName
= tokens
[1]
16 sourceLocation
= tokens
[2]
17 definitionSet
.add(fullMethodName
)
18 definitionToSourceLocationMap
[fullMethodName
] = sourceLocation
19 elif tokens
[0] == "call:":
20 fullMethodName
= tokens
[1]
21 callSet
.add(fullMethodName
)
23 print( "unknown line: " + line
)
25 unnecessaryVirtualSet
= set()
27 for clazz
in (definitionSet
- callSet
):
28 # if clazz.startswith("canvas::"): continue
29 # if clazz == "basegfx::unotools::UnoPolyPolygon::void-modifying()const": continue
30 # ignore external code
31 if definitionToSourceLocationMap
[clazz
].startswith("external/"):
34 unnecessaryVirtualSet
.add((clazz
,definitionToSourceLocationMap
[clazz
] ))
37 # sort the results using a "natural order" so sequences like [item1,item2,item10] sort nicely
38 def natural_sort_key(s
, _nsre
=re
.compile('([0-9]+)')):
39 return [int(text
) if text
.isdigit() else text
.lower()
40 for text
in re
.split(_nsre
, s
)]
41 # sort by both the source-line and the datatype, so the output file ordering is stable
42 # when we have multiple items on the same source line
44 return natural_sort_key(v
[1]) + [v
[0]]
46 # sort results by name and line number
47 tmp1list
= sorted(unnecessaryVirtualSet
, key
=lambda v
: v_sort_key(v
))
49 with
open("compilerplugins/clang/virtualdown.results", "wt") as f
:
51 f
.write( t
[1] + "\n" )
52 f
.write( " " + t
[0] + "\n" )
53 # add an empty line at the end to make it easier for the removevirtuals plugin to mmap() the output file