2015-06-20 22:06:22 +02:00
|
|
|
#/usr/bin/python
|
|
|
|
#
|
|
|
|
# This script analyses Cppcheck dump files to locate threadsafety issues
|
|
|
|
# - warn about static local objects
|
|
|
|
#
|
|
|
|
|
|
|
|
import cppcheckdata
|
|
|
|
import sys
|
|
|
|
|
2015-08-21 10:55:19 +02:00
|
|
|
|
2015-06-20 22:06:22 +02:00
|
|
|
def reportError(token, severity, msg):
|
2015-12-14 09:37:26 +01:00
|
|
|
sys.stderr.write(
|
|
|
|
'[' + token.file + ':' + str(token.linenr) + '] (' + severity + ') threadsafety.py: ' + msg + '\n')
|
2015-08-21 10:55:19 +02:00
|
|
|
|
2015-06-20 22:06:22 +02:00
|
|
|
|
|
|
|
def checkstatic(data):
|
2015-08-21 10:55:19 +02:00
|
|
|
for var in data.variables:
|
|
|
|
if var.isStatic == True and var.isLocal == True and var.isClass == True:
|
2016-01-12 20:31:18 +01:00
|
|
|
reportError(var.typeStartToken, 'warning', ('Local static object: ' + var.nameToken.str) )
|
2015-06-20 22:06:22 +02:00
|
|
|
|
|
|
|
for arg in sys.argv[1:]:
|
2015-08-21 10:55:19 +02:00
|
|
|
print('Checking ' + arg + '...')
|
|
|
|
data = cppcheckdata.parsedump(arg)
|
2015-12-14 09:37:26 +01:00
|
|
|
for cfg in data.configurations:
|
|
|
|
if len(data.configurations) > 1:
|
|
|
|
print('Checking ' + arg + ', config "' + cfg.name + '"...')
|
|
|
|
checkstatic(cfg)
|