2 from __future__
import print_function
6 datacl = re.compile(
"^class ")
7 bfunc = re.compile(
"^function ")
8 mbcl = re.compile(
"(base|data|flagged) class")
9 farg = re.compile(
r"(.*)\(\w+\)")
10 nsep = re.compile(
r"\:\:")
12 r"::(produce|analyze|filter|beginLuminosityBlock|beginRun|beginStream)\(")
13 baseclass = re.compile(
14 r"edm::(one::|stream::|global::)?ED(Producer|Filter|Analyzer)(Base)?")
15 globalclass = re.compile(
"^edm::global::ED(Producer|Filter|Analyzer)$")
17 r"edm::eventsetup::EventSetupRecord::get<.*>\((.*)&\) const")
18 handle = re.compile(
"(.*),?class edm::ES(.*)Handle<(.*)>")
20 r"edm::serviceregistry::ServicesManager::MakerHolder::add() const")
21 rootclass = re.compile(
"T(H1|Tree|Enum|DataType|Class|Branch|Named|File)")
22 stdcl = re.compile(
"^std::(.*)[^>]$")
23 stdptr = re.compile(
"(.*)_ptr$")
27 dataclassfuncs = set()
35 flaggedclasses = set()
41 f = open(
'class-checker.txt')
44 fields = line.split(
"'")
47 badclasses.add(classname)
48 badfuncs.add(funcname)
51 f = open(
'const-checker.txt')
54 fields = line.split(
"'")
56 badclasses.add(classname)
60 f = open(
'classes.txt.dumperall')
63 fields = line.split(
"'")
64 if fields[2] ==
' member data class ':
65 Hdg.add_edge(fields[1], fields[3], kind=fields[2])
66 if fields[2] ==
' templated member data class ':
67 Hdg.add_edge(fields[1], fields[3], kind=fields[2])
68 if fields[2] ==
' base class ':
69 Hdg.add_edge(fields[1], fields[3], kind=fields[2])
70 Idg.add_edge(fields[3], fields[1], kind=
' derived class')
71 if globalclass.match(fields[3]):
72 globalclasses.add(fields[1])
73 print(
"class '"+fields[1]+
"' base class '"+fields[3]+
"'")
76 for line
in fileinput.input(files=(
'function-statics-db.txt',
'function-calls-db.txt')):
77 if not bfunc.search(line):
79 fields = line.split(
"'")
80 if skip.search(fields[1])
or skip.search(fields[3]):
82 if fields[2] ==
' calls function ':
83 Gdg.add_edge(fields[1], fields[3], kind=
' calls function ')
84 if getfunc.search(fields[3]):
85 dataclassfuncs.add(fields[3])
86 m = getfunc.match(fields[3])
87 n = handle.match(m.group(1))
92 p = re.sub(
"class ",
"", o)
93 dataclass = re.sub(
"struct ",
"", p)
94 dataclasses.add(dataclass)
95 if fields[2] ==
' overrides function ':
96 if baseclass.search(fields[3]):
97 Gdg.add_edge(fields[1], fields[3], kind=
' overrides function ')
98 if topfunc.search(fields[3]):
99 toplevelfuncs.add(fields[1])
101 Gdg.add_edge(fields[3], fields[1], kind=
' calls override function ')
102 if fields[2] ==
' static variable ':
103 Gdg.add_edge(fields[1], fields[3], kind=
' static variable ')
104 statics.add(fields[3])
108 for n, nbrdict
in Gdg.adjacency():
109 for nbr, eattr
in nbrdict.items():
110 if n
in badfuncs
or nbr
in badfuncs:
111 if 'kind' in eattr
and eattr[
'kind'] ==
' overrides function ':
112 print(
"'"+n+
"'"+eattr[
'kind']+
"'"+nbr+
"'")
116 print(
"-----------------------------------------------")
117 print(
"flagged functions found by checker")
118 print(
"-----------------------------------------------")
119 for dfunc
in sorted(badfuncs):
123 print(
"-----------------------------------------------")
124 print(
"flagged classes found by checker ")
125 print(
"-----------------------------------------------")
126 for dclass
in sorted(badclasses):
130 nodes = sorted(badclasses)
137 stack = [(node, iter(Hdg[node]))]
139 Qdg = nx.dfs_preorder_nodes(Idg, node)
142 stack.append((q, iter(Hdg[q])))
144 parent, children = stack[-1]
147 if globalclass.search(child):
149 if rootclass.search(child):
151 if child
not in visited:
153 stack.append((child, iter(Hdg[child])))
154 kind = Hdg[parent][child][
'kind']
155 if stdptr.search(kind):
157 Qdg = nx.dfs_preorder_nodes(Idg, child)
160 stack.append((q, iter(Hdg[q])))
161 except StopIteration:
163 print(
"flagged class " + node +
" contains or inherits from classes ", end=
' ')
165 print(v +
",", end=
' ')
167 for v
in sorted(visited):
168 if v
in globalclasses:
169 print(
"EDM global class '" + v +
170 "' is flagged because it is connected to flagged class '" + node +
"'")
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)