forked from danmar/cppcheck
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththreadsafety.py
More file actions
27 lines (21 loc) · 849 Bytes
/
threadsafety.py
File metadata and controls
27 lines (21 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#/usr/bin/python
#
# This script analyses Cppcheck dump files to locate threadsafety issues
# - warn about static local objects
#
import cppcheckdata
import sys
def reportError(token, severity, msg):
sys.stderr.write(
'[' + token.file + ':' + str(token.linenr) + '] (' + severity + ') threadsafety.py: ' + msg + '\n')
def checkstatic(data):
for var in data.variables:
if var.isStatic == True and var.isLocal == True and var.isClass == True:
reportError(var.typeStartToken, 'warning', ('Local static object: ' + var.nameToken.str) )
for arg in sys.argv[1:]:
print('Checking ' + arg + '...')
data = cppcheckdata.parsedump(arg)
for cfg in data.configurations:
if len(data.configurations) > 1:
print('Checking ' + arg + ', config "' + cfg.name + '"...')
checkstatic(cfg)