Skip to content

Commit

Permalink
Add check for func name in graph before calling has_path
Browse files Browse the repository at this point in the history
  • Loading branch information
gartung committed Feb 28, 2021
1 parent 2ee8e79 commit 95911c1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Utilities/StaticAnalyzers/scripts/callgraph.py
Expand Up @@ -43,7 +43,7 @@
callstacks=set()
for tfunc in sorted(toplevelfuncs):
for epfunc in sorted(epfuncs):
if nx.has_path(G,tfunc,epfunc) :
if tfunc in G and epfunc in G and nx.has_path(G,tfunc,epfunc) :
path = nx.shortest_path(G,tfunc,epfunc)
cs=""
previous=str("")
Expand Down
Expand Up @@ -50,6 +50,7 @@ if [ ! -f ./callgraph.py ]
cp -pv ${CMSSW_BASE}/src/Utilities/StaticAnalyzers/scripts/callgraph.py .
cp -pv ${CMSSW_BASE}/src/Utilities/StaticAnalyzers/scripts/modules_in_ib.txt .
fi
touch eventsetuprecord-get-all.txt eventsetuprecord-get.txt
./callgraph.py 2>&1 > eventsetuprecord-get-all.txt
grep -f modules_in_ib.txt eventsetuprecord-get-all.txt | awk '{print $0"\n"}' > eventsetuprecord-get.txt

4 changes: 2 additions & 2 deletions Utilities/StaticAnalyzers/scripts/data-class-funcs.py
Expand Up @@ -150,7 +150,7 @@

for badclass in sorted(badclasses):
for dataclass in sorted(dataclasses):
if H.has_node(badclass) and H.has_node(dataclass):
if tfunc in H and dataclassfunc in H and H.has_node(badclass) and H.has_node(dataclass):
if nx.has_path(H,dataclass, badclass) :
print("Event setup data class '"+dataclass+"' contains or inherits from flagged class '"+badclass+"'.")
flaggedclasses.add(dataclass)
Expand All @@ -160,7 +160,7 @@

for dataclassfunc in sorted(dataclassfuncs):
for tfunc in sorted(toplevelfuncs):
if nx.has_path(G,tfunc,dataclassfunc):
if tfunc in G and dataclassfunc in G and nx.has_path(G,tfunc,dataclassfunc):
m = getfunc.match(dataclassfunc)
n = handle.match(m.group(1))
if n : o = n.group(3)
Expand Down
2 changes: 1 addition & 1 deletion Utilities/StaticAnalyzers/scripts/statics.py
Expand Up @@ -40,7 +40,7 @@

for tfunc in sorted(toplevelfuncs):
for static in sorted(statics):
if nx.has_path(G,tfunc,static):
if tfunc in G and static in G and nx.has_path(G,tfunc,static):
path = nx.shortest_path(G,tfunc,static)

print("Non-const static variable \'"+re.sub(farg,"()",static)+"' is accessed in call stack '", end=' ')
Expand Down

0 comments on commit 95911c1

Please sign in to comment.