bump product version to 6.3.0.0.beta1
[LibreOffice.git] / compilerplugins / clang / virtualdown.py
blob9c1346ff28312c912f9c27ad5917cc424dedc111
1 #!/usr/bin/python
3 import io
4 import re
5 import sys
7 definitionSet = set()
8 definitionToSourceLocationMap = dict()
9 callSet = set()
12 with io.open("workdir/loplugin.virtualdown.log", "rb", buffering=1024*1024) as txt:
13 for line in txt:
14 tokens = line.strip().split("\t")
15 if tokens[0] == "definition:":
16 fullMethodName = tokens[1]
17 sourceLocation = tokens[2]
18 definitionSet.add(fullMethodName)
19 definitionToSourceLocationMap[fullMethodName] = sourceLocation
20 elif tokens[0] == "call:":
21 fullMethodName = tokens[1]
22 callSet.add(fullMethodName)
23 else:
24 print( "unknown line: " + line)
26 unnecessaryVirtualSet = set()
28 for clazz in (definitionSet - callSet):
29 # if clazz.startswith("canvas::"): continue
30 # if clazz == "basegfx::unotools::UnoPolyPolygon::void-modifying()const": continue
31 # ignore external code
32 if definitionToSourceLocationMap[clazz].startswith("external/"): continue
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)]
42 # sort results by name and line number
43 tmp1list = sorted(unnecessaryVirtualSet, key=lambda v: natural_sort_key(v[1]))
45 with open("compilerplugins/clang/virtualdown.results", "wt") as f:
46 for t in tmp1list:
47 f.write( t[1] + "\n" )
48 f.write( " " + t[0] + "\n" )
49 # add an empty line at the end to make it easier for the removevirtuals plugin to mmap() the output file
50 f.write("\n")